HPWM confusion


Closed Thread
Results 1 to 13 of 13

Thread: HPWM confusion

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default HPWM confusion

    Hi,

    I am learning the HPWM command.. mainly because I need a PWM for my motors. But I was wandering what the command ccp1 does in the Pic16f876a chip does. At first I thought I needed it, but then i saw that the Pic16F84 dont have one and it is possible to have PWM, Actually I guess its a question of, what pin is turning on and off at a specific duty cycle. So what is the PWM mode in the pic16F876a with the CCP0, CCP1, What does it give more then the 16F84 chip.

    thanks

    ken

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    The PWM command in PBP is a software pwm generator. When this command is running nothing else is workin until the pwm genarator is ready, because you give the dutycycle and the number of cycles of this pwm to the genarator.
    When the cycles are done then the next command is working.
    The HPWM command is a command what goes directly to the hardware buils in pwm generator. When it is started is will work until you give a command to stop or to give it another dutycycle. Meanwhile your programm is doing then next instructions without concirning about the pwmgenerator.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    For CCP1, I also would like to ask a question in addition to lerameur's, as I am also having new experiences with PWM.

    1. When setting PR2 and CCP1, say we set CCP1 for a fixed number. Then we play with PR2 to get the correct freq (in brief I say it this way).

    2. But, when I set PR2=255 fixed, and then play with CCP1, I also get the same freqs as in number 1 above.


    So what should be my question here, I am not sure.


    -----------------------
    Last edited by sayzer; - 3rd November 2006 at 09:58.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    >> But I was wandering what the command ccp1 does in the Pic16f876a chip does.

    CCP1 is NOT a command, but a REGISTER within your PIC.

    To discover what it does, download and read the Datasheet for your PIC16F876A. A really good place to start is section 8 - Capture/Compare/PWM Modules.

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Welcome back Melanie!



    ----------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    So grossely, I am doing a line following robot, if I use PWM, then the sensors are not working. Also, I only have two channel to use PWM, so only two motors can use HPWM on one chip. right?

    k

  7. #7
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Thats wright.
    A 16F87(3)6 should do it. It has 2 Hpwm outputs.

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    HI,

    I am using an H-bridge L293. It seems that there are thre wires per motor for control. 1 for neg. , 1 for pos. and one for the HPWM. The PWM is put on the CCP1, while the other do not matter, as long as they are configured as 1 or 0 right ? well thats what I concluded from what I read. Is there any reason why this code would not work ? I am not getting any output

    if right > left Then
    temp =right-left
    temp= temp * 254
    temp= temp/right
    PORTC.4=0
    PORTC.5=1
    HPWM 1,255-temp,1000
    HPWM 2,255,1000

    Else
    temp =left-right
    temp= temp * 254
    temp= temp/left
    PORTC.4=1
    PORTC.5=0
    HPWM 2,255-temp,1000
    HPWM 1,255,1000
    Endif

  9. #9
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    To be more precise, the circuit seems to wok without the motor connected. when i conencted the motor, then the LCD screens shows very low numbers, and the motor might turn just for 1-2 seconds, otherwise it makes a noise, I guess thats my 2000hz
    Just one time the motor turned on and changes direction 3 times very quickly.

    Should my power supply for the L293 be different then for the pic ?

    k

  10. #10
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    last code still not working
    Again i hear a buzz, and sometime the motor turns a little.
    Also on the oscilloscope, sometime he output is sitting at zero, or when its oscillating, it looks like its going from -4 to 1volt

    if right > left Then
    temp =right-left
    temp= temp * 254
    temp= temp/right
    PORTC.4=0
    PORTC.5=1
    HPWM 1,255-temp,2000
    HPWM 2,255,2000
    Endif

    if left >= right then
    temp =left-right
    temp= temp * 254
    temp= temp/left
    PORTC.6=0
    PORTC.7=1
    HPWM 2,255-temp,2000
    HPWM 1,255,2000
    Endif

  11. #11
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    lerameur,

    Why don't you create an excel sheet and see all numbers?

    Have all possible right and left values in a row, and do the formula, put the result in another row.

    Then you can see how the numbers behave, from a possible minimum value to a possible maximum value.


    -------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default

    Should my power supply for the L293 be different then for the pic ?
    It's usualy a good pratice to split your PSU lines. You could use one regulator/line.

    Also, when dealing with POWER, you should split your GND lines (analog, Digital, PowerDevices) then tie them at them at a single point.

    It's also good practice to isolate POWER from Logic. OPTO couplers come handy in those case.

    Be sure ALL psu line are well filtered and noise free.

    Another things... be sure you Motor don't need much current than regulator can give.

    last code still not working
    Again i hear a buzz, and sometime the motor turns a little.
    Also on the oscilloscope, sometime he output is sitting at zero, or when its oscillating, it looks like its going from -4 to 1volt
    O.K, could you provide more details, wich motor model you use and post your schematic here.

    Personnally i hate guessing. I'm sure we could find the solution faster if you posted the whole thing on your first post.

    Please for the next(s) time(s) give us all you have. A schematic is often a MUST. If you have a board layout too.
    Steve

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

  13. #13
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I am going out of town for a few days, I will post again when I come back

    k

Similar Threads

  1. HPWM Confusion in spec sheet
    By lerameur in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th September 2008, 01:48
  2. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 16:05
  3. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 15:14
  4. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 03:43
  5. HPWM confusion
    By rossfree in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd November 2005, 17:50

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