PWM locked-Antiphase

Discussion in 'Programmer's Corner' started by MCrowe, Nov 23, 2011.

  1. MCrowe

    Thread Starter Member

    May 29, 2011
    So I take it someone here as probably heard of / used lockled antiphase PWM?

    Im kind of lost trying to find more info on this. I had trouble finding enough information to actually use it. What I have discovered ive put together into a resonable guess as to how it works...

    My guess... You use one PWM output, but split the line, invert one, and feed the normal line to one side of your H-bridge, and the Inverted line to the other side of the H-bridge / driver chip.

    Therfor, at 50% the high will cancel out, any movement either way of 50% will increas the high one one side AND the low on the other, leading to motor movement. Is this correct?

    And if so, how do you go about generating an inverted PWM? Is it a software thing usually or a hardware thing? And is this method of control bad for the motor / power consumption?

    Also, I found lots of references saying you must use a relatively high frequency PWM. Relative to what??? How high is high? my servos opperate at 50Hz so is anything over this relatively high? Will 100Hz be high enough?

    Ah too many questions. Help...

    Thanks All.
  2. MCrowe

    Thread Starter Member

    May 29, 2011
    Ok, so still dont know what im doing but going to go ahead and try this out any way. tomorrow...

    The problem im facing is I dont really know how Locked-antiphase works, I dont know what frequency I need to use, If my L298 chip can do it, or if the motors will work with it. Oh, or if my code works. :D

    Code ( (Unknown Language)):
    1.   MOVFW NormPORTD     ;Contains normal PWM values in highest 4 bits
    2.   XORLW b'11111111'   ;Will invert the results of PORTD and store in W
    3.   MOVWF InvPORTD     ;Now contains Inverted PWM values in highest 4 bits.
    5.   MOVFW NormPORTD
    6.   IORLW b'00001111'
    7.   MOVWF NormPORTD     ;Guarantees NormPORTD High nibble PWM, low nibble all HIGH.  
    8.   SWAPF InvPORTD,W    ;Will swap highest 4 bit with Lowest 4 bits.
    9.   IORLW b'11110000'   ;Sets high nibble HIGH low nibble Inverted to PORTD PWM, in W
    10.   ANDWF NormPORTD,W   ;AND InvPORTD with NormPORTD to get upper nibble PWM lower nibble Inverted PWM
    11.   MOVWF PORTD       ;And move result to PORTD
    But hey, where would the fun be in knowing everything. If any one has any suggestions, comments, or detects potentially catastrophic failures that could occur from this, please, feel free to chime in. Cheers.

    P.S. If someone could tell me weather or not my code looks correct for locked-antphase PWM that would also be neat.
  3. John P

    AAC Fanatic!

    Oct 14, 2008
    100Hz is nowhere near enough. You need to be up in the KHz, maybe above the audio range, to use this technique. What you'll be doing is rapidly cycling between forward and reverse, so that a 50% duty cycle says "stop". The inductance of the motor keeps the current near zero then. But you need a driver that can deal with the rapid reversals, and you need to prevent shoot-through (high-side and low-side transistors on at the same time).

    It's asking a bit much to expect people to work their way through assembly language.
  4. MCrowe

    Thread Starter Member

    May 29, 2011
    Thanks, Guess Ill have to skip that idea then. I couldnt get it working.

    Work there way through assembly? a: so far assembly is all I know, kinda new at this. b: its only 10 lines. c: its pretty simple isn't it?

    The comments tell you what each line does, and its almost all boolean logic. AND this with that, OR that with something else.

    Any who, Thanks heaps for the reply. Ill move on to some other idea. maybe RC car ESC's. They opperate at 50Hz already, can get 20 amp controllers for about $10, and they work like I want with 50% PWM being stop on the motor. They only thing I dont like is the 50hz opperation that leads to lots of motor noise.
  5. Gandalf_Sr

    New Member

    Jun 3, 2011
    IF you use one of the new PICs with high speed PWM, and ploughed through the manual(s), you would find that this can be set up very easily in hardware including dead time to avoid shoot through.

    Don't give up. That's the thing with electronics, it can be made to work, you just have to find out why it doesn't. Run the simulator and see if the registers do what you expect.

    Go here and search for the word 'staggered'. I adapted CE022 to run on a dsPIC33EP256MU806 with very few changes.