HPWM Control


Closed Thread
Results 1 to 4 of 4

Thread: HPWM Control

  1. #1
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    24

    Default HPWM Control

    I have an H-Bridge that can run under joystick control or R/C Transmitter Control.
    While running under R/C Transmitter Control, I want the PWM to go to zero if the transmitter is accidentally shutoff or batteries go dead (i.e loss of good pulse signal from the receiver.
    I have attached the code I'm working with below. Using a 16f877A@20MHZ.
    Right now, when you shutoff the transmitter, the motor goes wild. Full speed to zero speed and back and forth. My last attempt to solve this was to add the line "if duty0>260 then duty0=0" just before the jump to genpwm2: which runs the HPWM command. Note, duty0=255 is max duty cycle. I'm working in the LOOP2: section of the code only right now.
    Thanks,
    John
    Attached Files Attached Files
    JRudd

  2. #2
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I took a look at what you are doing and I have a thought. (Keep in mind I'm still kind of a newbie, but hey, sometimes a second pair of eyes can help If I'm totally off, I'm sorry - just trying to help.

    In your lines-

    loop2:
    pulsin portb.0,1,rcin
    rcin2=((rcin-536)*10)/17

    Being that you have a word variable for rcin, the result is going to be a 16 bit number (between 0-1024,) but the math seems to need a number greater than 536 or it is going to have some trouble going negative won't it? When your transmitter is on, it is probably OK, but when it is off, wouldn't it read close to zero and end up negative?

    I was under the impression that would cause some difficulty. Maybe a test right there would do the trick.

    Good luck,

    Chris

  3. #3
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default HPWM going bonkers

    I think Chris H is right.

    1. Assume that your transmitter has failed/turned off

    2. The receiver never puts out a pulse.

    3. If the pulse never happens the variable is set to zero (PBP manual page120)

    4. So rcin= - 5360/17 = - 315 and the PBP will turn this into a two's compliment number: 65,221 or $FEC5 or %1111 1110 1100 0101 (if I've got my maths right?) and this is larger than 300 so your code will loop back to 'loop2.'

    5. Meanwhile, the PHWM will continue to follow the previous command.

    Actually, I suspect that once the transmitter dies and the carrier is lost, the receiver outpus noise and it is this noise, misinterpreted by your software that causes the motor to surge around.

    I've not given it much thought but, assuming the problem is not noise and is caused by rcin = 0 because no pulse is ever received then putting

    IF rcin < 2 THEN
    ....kill the HPWM etc...
    ENDIF

    just after 'the loope2' PULSIN may fix the problem?

    Regards Bill legge

  4. #4
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    24


    Did you find this post helpful? Yes | No

    Default RC Drive

    Thanks for the help guys.
    After studying further, when I shut the transmitter off, I realized that some values for duty cycle were correct and would fall through to the HPWM Command. The trouble was that one time it may be full on(255) and the next time zero, thus causing the motor to jerk on and off.
    So I setup a routine(testsignal to watch 10 straight rcin values. If they were all within +/-5 of each other, I assume that we have a good signal again and jump back to loop2: otherwise, it would keep checking while forcing duty cycle to zero. So now, I can flip the transmitter on and off and the motor stays rock solid at zero speed.
    John
    Attached Files Attached Files
    JRudd

Similar Threads

  1. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05
  2. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  3. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  4. RC H-bridge control
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th March 2006, 14:10
  5. HPWM Motor Control
    By hughgoodbody in forum General
    Replies: 7
    Last Post: - 30th January 2005, 22:41

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