18f4431 pwm4 and pwm 5 issues


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2009
    Posts
    4

    Default 18f4431 pwm4 and pwm 5 issues

    Hello All,

    I have a brushless DC motor and want to build my own drive control for the unit. I can get the device to throw out PWM's on ports 0,1,2,3 but nothing on 4 or 5. I am getting something from portb.4 and portb.5 but it is not the pwm's i have on the lower ports.

    My code is a mish mash of others to get something working to build upon but hopefully someone can spot my error.

    Device 18F4431
    XTAL = 20

    Dim Duty As Word
    Duty = 800
    PORTB = 0 ' clear port latch

    TRISB = %11000000

    PTCON0=$00 timebase
    PTPERL=$A0 ' $01A0 = 12kHz
    PTPERH=$01

    PWMCON0=%01010111
    PWMCON1=%00000001
    DTCON=$00
    OVDCOND = %00000000
    OVDCONS = %00000000 PORT PINS

    SEVTCMPL=$00
    SEVTCMPH=$00

    PDC0L=$00
    PDC0H=$00
    PDC1L=$00
    PDC1H=$00
    PDC2L=$00
    PDC2H=$00

    PDC0L = Duty.LowByte
    PDC0H = Duty.HighByte

    PDC1L = Duty.LowByte
    PDC1H = Duty.HighByte

    PDC2L = Duty.LowByte
    PDC2L = Duty.HighByte


    PTCON1=%10000000

    MAIN:

    OVDCOND = %00111111
    DelayMS 500
    OVDCOND = %00000000
    DelayMS 500

    GoTo MAIN

    Many thanks

    Lothar

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Have a look at this one
    http://www.picbasic.co.uk/forum/show...20&postcount=4

    PS: It's Melabs PICBasic forum here, Proton PDS is at the following
    http://www.picbasic.org/forum/
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    And check your config fuse setting. Seems you can move PWM4 on RB5 or on RD5. Possible that you have LVP enabled, if so it will screw up the signal on RB5 indeed!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Apr 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Apologies

    Hi Steve,

    Apologies for posting on the wrong forum. To be honest I stumbled across this picbasic forum through good old google. I also noticed that members like Bruce have had good results from this particular PIC and thought this the best location to post. I am not looking to upset anyone and if by posting on this forum I have done this then please accept my apologies. In the future I will post on the proton forum only.

    Thanks for the heads up on the LVP I will check on this and be on my merry way.

    Thanks again

    Lothar

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Don't worry about that, we are here to help each other!

    I think Bruce's post can help you. Easy to convert to PDS later anyways
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Apr 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Smile

    Steve you will be happy to know that i am currently checking the config settings within the datasheet as we speak/ type.

    I have Bruce's PWM scaling code working but needed to make the full step to using the override function for the PWM Brushless sequence output.

    I must add when I do crack it I will post on this forum to hopefully assist others who may be trying to get this pretty interesting PIC working.

    Anyway back to the datasheet....what joy

  7. #7
    Join Date
    Apr 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Red face the basics...its always the basics

    As promised I have found the resolution to my problem (the PWM issue not the posting on the wrong forum issue) after much soul searching and datasheet reading I tracked it down to be a typo.

    the line:

    PDC2L = Duty.LowByte
    PDC2L = Duty.HighByte
    should have been:

    PDC2L = Duty.LowByte
    PDC2H = Duty.HighByte
    the code works fine now and I can now move through the commutation pattern of the brushless motor drive. I cant believe it came to this damn you cut-copy-paste.

    Once again I apologies for posting here

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Thumbs up

    Glad to hear you have it working now!

    No need for apologies, your post will be useful for some.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts