Shop OBEX P1 Docs P2 Docs Learn Events
Running an AC Servo Motor from a propeller — Parallax Forums

Running an AC Servo Motor from a propeller

n_ermoshn_ermosh Posts: 294
edited 2013-12-04 06:20 in Propeller 1
I have an AC servo motor that I would like to build a controller for using a propeller. The motor is 24V and 2.1A, and I believe functions under the same principles as standard AC Induction motors. Is this possible? Essentially I need to generate 3 variable frequency waves between -12V and 12V. Ideally, they would be pure sine waves, but I'll start with plain square waves and work from there. I know for a DC motor, I would need an H-bridge, but does something like this exist for an AC motor? I know I can use an LC circuit with some transistors to generate the wave, but I can only get one frequency out of that.

Any help is appreciated
«1

Comments

  • kwinnkwinn Posts: 8,697
    edited 2013-11-21 18:49
    It is possible, and there are commercially available devices called VFD's that do this, but they are generally used for higher power/voltage motors. You can use the propeller to PWM 3 half bridges for producing a signal that looks like a sine wave to most motors.

    PS - Should have added that VFD stands for Variable Frequency Driver.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-22 02:59
    Thanks, I should have also mentioned: I've heard of VFDs and essentially I'm trying to make my own. Basically what would be the equivalent to the spark fun easy driver for stepper motors; this would be for AC motors. VFDs are very bulky and like you said, designed for high current applications.

    Could you go into some detail about using half bridges? That was my first instinct too, but that will only give me a signal between 0 and 12V but I need to go down to -12V
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-11-22 10:04
    The traditional half-bridge is half of an H-bridge or one PNP and one NPN transistor.

    It this context, you have three of them driving pulses that are 120 degrees apart in phase, or three phase.

    You could use TIP120 and TIP125 Darlingtons for this these, but they would be a bit hot and would drop about 2 volts off the supply voltage that is driving the motor (So for a 24 volt motor, you would ideally want a 26volt supply).

    To get around the heat and the voltage drops, manufacturers now prefer Power Mosfets.

    It may be easiest to drive the three pairs of Power Mosfet in a final stage from conventional small transistors. Conventional transistors work well with the 3.3volt logic of the Propeller and can boost the control voltage up to a level that the Power MOSfets are operating well. Trying to design an all MOSfet solution might be a bit more tedious than it is worth.

    I think you can use the half-bridge with a dual supply and have it swing from -12 to 12 to cover the 24 volt range. You might have a bit more complex front end and if you want sine wave, you may have to create it via PWM or another form of pulse modulation.

    You can monitor speed with hall-effect sensors for feedback as the Propeller has enough cogs to do that as well.

    The design process usually starts with the design of the final power stage, and then both ends of the design work toward resolving what is in the middle to make it work. A good power output stage is very important to a successful design.

    There are complete 3 phase half-bridge MOSfet output stages that come as one chunk of IC, but they might be a bit difficult to buy in small quantity.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-22 10:40
    I found this today: I think it might be what I need, but I'll have to do some more reading to make sure.

    http://www.digikey.com/product-detail/en/DRV8312DDW/296-27707-5-ND/2355295
  • kwinnkwinn Posts: 8,697
    edited 2013-11-22 16:20
    n_ermosh wrote: »
    I found this today: I think it might be what I need, but I'll have to do some more reading to make sure.

    http://www.digikey.com/product-detail/en/DRV8312DDW/296-27707-5-ND/2355295

    That chip may work. Depends on how your motor is wound and connected to the power.
  • Mark_TMark_T Posts: 1,981
    edited 2013-11-23 03:37
    Do you have the datasheet for the motor?
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-23 05:32
    Mark_T wrote: »
    Do you have the datasheet for the motor?

    This is the best I've found: http://www.yaskawa.com/site/dmservo.nsf/link2/MNEN-5CLKDZ/$file/SIE-S800-27.pdf

    Here is an update to my experiments: I have the VFD that Yaskawa sells for the motors, but its big and bulky, which is why I want to scale it down. I got the motor running and connected 6 LEDs between the phases, in both polarities, so I can see the signal running through the phases. When running at a slow speed, I can clearly see 3 sine waves oscillating between the LEDs, offset by 120 phase degrees, between -12V and 12V. So this is a standard AC motor. Now, how do I replicate those 3 sine waves (I bet even square waves will work), using the propeller? The above chip appears to be just to be 3 half-bridges with current and thermal protection. Any ideas?
  • kwinnkwinn Posts: 8,697
    edited 2013-11-23 11:30
    The commercial VFD's I deal with all use PWM to produce pseudo sine waves that drive the motor. Three square waves 120 degrees out of phase would work on a synchronous motor but the motion would not be very smooth. Think of it as a stepper motor with 3 steps per revolution. The windings in the motor are almost certainly connected in a delta configuration so you will need to provide a +- drive voltage to the windings.

    If you want nice smooth motion you will need to use 3 half bridges and a +-12V or 24V power supply.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-23 11:55
    24v power is no issue.

    The pseudo sine waves, do they use PWM to control the amplitude of the sine wave at time t? If so, sounds like all I need is 3 half bridges and some clever programming.
  • whickerwhicker Posts: 749
    edited 2013-11-23 11:57
    typical modulation frequency is 4 kiloHertz for the kiloWatt motors.
    So something like 8 kHz, 16 kHz would be a good modulation frequency.

    as for producing the sine waves, start out with just one PWM sine wave that you can adjust its frequency.
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-11-23 13:59
    The 8312 should work and also the 8313
    http://www.ti.com/product/drv8313

    I seen TI showing that perfect sine wave is not needed and that a trapezoid is just fine.
    Better than the only-3-levels ( +1 0 -1) cheap dc to ac converters do.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-23 17:53
    tonyp12 wrote: »
    The 8312 should work and also the 8313
    http://www.ti.com/product/drv8313

    I seen TI showing that perfect sine wave is not needed and that a trapezoid is just fine.
    Better than the only-3-levels ( +1 0 -1) cheap dc to ac converters do.

    Hm. I'll start with square waves, and see where it goes. Will the 8312 or 8313 create trapezoid waves for me? Or will I have to use PWM to do it?

    EDIT: I read the documentation, looks like both the 8312 and the 8313 are both essentially 3 half-bridges with current and temperature monitoring. I'm gonna order a few of these drivers and see what they do.
  • kwinnkwinn Posts: 8,697
    edited 2013-11-23 18:05
    You will need to do PWM. The good thing about using trapezoid waveforms is that you can use add/subtract to increment/decrement pulse width rather than a sine calculation.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-23 18:48
    kwinn wrote: »
    You will need to do PWM. The good thing about using trapezoid waveforms is that you can use add/subtract to increment/decrement pulse width rather than a sine calculation.

    Thanks, I'll play with it when the drivers come in from Digikey. Is there any optimal slope for the trapezoid? And a 50% duty cycle on the PWM would be the 0 point of the wave, right?
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-11-23 19:23
    in a 3phase, only two phases are ever energized at any one time, the one not used is connected to a comparator (warning voltage spike can be 100v)
    to sense that the motor have made it to this deg and then you start energize the next 2/3 and so on.
    http://www.ti.com/lit/ug/slvu815/slvu815.pdf

    But for testing and slow speed without ramping of speed etc, you can just guestimate.
    565 x 455 - 61K
  • rabaggettrabaggett Posts: 96
    edited 2013-11-24 06:40
    I am doing something similar. I started with the demo code from the pwmX8 object. (In the OBEX)
    It was pretty simple to modify the sine table to actual sine wave (The one in the demo is optimized for visual efffect for the LEDs), and for 3 phases instead of eight. I modified the WaitCnt value to provide the desired drive frequency. Looks good on the 'scope.

    I haven't explored the upper limit for the AC frequency yet (I have the PWM at 4 KHZ). I think I will need to do this in PASM ultimately. My next experiment will be with lowering the number of steps. My motor has a 1024 count encoder and I want to see how few sine steps I can get away with and still hold within a few counts once I get the control loop right.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-25 06:46
    I've ordered from Digikey a few different TI drivers. I'm working on writing the spin code now. How fast should the PWM cycle be? A few (maybe 10) ms?

    And one more question, what state should the phases be to stop the motor? It's a fairly low inertia motor, so will just putting 0 on each phase work?
  • kwinnkwinn Posts: 8,697
    edited 2013-11-25 21:16
    n_ermosh wrote: »
    I've ordered from Digikey a few different TI drivers. I'm working on writing the spin code now. How fast should the PWM cycle be? A few (maybe 10) ms?
    Depends on the max rpm you want and the minimum number of steps you want for the sine/trapezoid wave. Typical values seem to be in the 1mS to 50uS range (1KHz to 20KHz).
    And one more question, what state should the phases be to stop the motor? It's a fairly low inertia motor, so will just putting 0 on each phase work?

    Pulling all 3 phases to 0V (gnd) will short them together and provide a rapid stop. If you need to stop at a precise position you need a controlled deceleration.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-27 07:42
    kwinn wrote: »
    Depends on the max rpm you want and the minimum number of steps you want for the sine/trapezoid wave. Typical values seem to be in the 1mS to 50uS range (1KHz to 20KHz).

    Yesterday, I hooked up a QuickStart board and wrote the wave generating object, using LEDs as my 3 "phases" I found that spin alone isn't fast enough to pulse faster than about 200 Hz, which limits my wave frequency to about 75 Hz, which may be fast enough for what I'm doing.
  • kwinnkwinn Posts: 8,697
    edited 2013-11-27 10:21
    This is the kind of thing you use a separate cog and PASM for. Have the spin program tell the cog what pins to use and what variable holds the speed and direction of rotation. Once that is done spin updates that variable to control the motor. Not sure if there is a PASM driver for an AC synch. motor in the OBEX but a BLDC driver might provide a starting point.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-27 12:53
    The only issue with using PASM for pulsing is the lack of math capabilities (I'm also not super comfortable with PASM). I'll get the driver and motor hooked up next week and see what happens; my spin code might be enough. I'll know once the motor actually turns.
  • kwinnkwinn Posts: 8,697
    edited 2013-11-27 17:50
    There would be very little if any math to do in PASM. The waveform would be generated by stepping through a table stored in the cog. The spin program could do the calculating and pass the result to the PASM program running in the cog.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-11-27 18:57
    I'm worried that spin can't do the math fast enough for the 1KHz pulse rate. If it could, it would be kind of pointless to use PASM just for pulsing. When I get it running, I'll update you on how it works and if I need help going faster.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-12-02 18:46
    So I ran the motor today, it works, but it's a little jumpy. I found that speeding up the PWM frequency helps, but spin can't pulse fast enough to create a smooth rotation. Any ideas? the PWM objects on the OBEX aren't working for me; I can't pulse from different cogs. Is there a trick in spin to speed it up or do I have to try to do it in PASM?

    This is my current pulse code. one function call = 1 pulse. Can I create a similar function in PASM to call from spin?
    CON
      pwmFreq  = 100
    
    ...
    
      waitCoef := clkfreq/pwmFreq
    
    ...
    
    PRI pulseWithDC(dutyCycle, phase) | t1, t2
    
      t1 := cnt                                                                                                                                                                                                                                                                                                                                                         
      t2 := t1 + waitCoef
    
    
      dutyCycle <#= 100
      dutyCycle #>= 0
    
    
      if dutyCycle == 100
        outa[phase]~~
      elseif dutyCycle == 0
        outa[phase]~
      else
        outa[phase]~~
        waitcnt(t1 + (waitCoef*dutyCycle)/100)
        outa[phase]~
      
      waitcnt(t2)
    
  • kwinnkwinn Posts: 8,697
    edited 2013-12-02 21:50
    I'm pretty sure the problem here is with the speed of spin. Add an instruction to your program to toggle a pin each time through the subroutine to see how long it takes.

    BTW, what RPM are you trying to obtain?
  • kwinnkwinn Posts: 8,697
    edited 2013-12-02 21:59
    n_ermosh wrote: »
    .....................................................................................
    Is there a trick in spin to speed it up or do I have to try to do it in PASM?


    I think you will have to do it in PASM, but it would probably be to have a variable that tells the pasm routine how quickly to step through a table of pulse widths to produce the waveform you want.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-12-03 05:45
    kwinn wrote: »
    I think you will have to do it in PASM, but it would probably be to have a variable that tells the pasm routine how quickly to step through a table of pulse widths to produce the waveform you want.

    Can you give me any specific help to make that happen? I'm not that great with PASM.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-12-03 06:12
    kwinn wrote: »
    I'm pretty sure the problem here is with the speed of spin. Add an instruction to your program to toggle a pin each time through the subroutine to see how long it takes.

    BTW, what RPM are you trying to obtain?

    I'm not sure what RPM I want yet, I haven't picked a stage, but I think my wave frequency will be between 100 mHz to the fastest the motor can handle.
  • kwinnkwinn Posts: 8,697
    edited 2013-12-03 20:56
    n_ermosh wrote: »
    Can you give me any specific help to make that happen? I'm not that great with PASM.
    The PASM part should be relatively simple. A small program would step through a sine table and generate the three output phases at a rate set by the spin program.
    I'm not sure what RPM I want yet, I haven't picked a stage, but I think my wave frequency will be between 100 mHz to the fastest the motor can handle.

    A min of 0.1Hz is no problem. The maximum will depend on how many steps you need in the waveform to get smooth motion at all speeds.
  • n_ermoshn_ermosh Posts: 294
    edited 2013-12-04 06:20
    I'm playing with the signal generator object thats on the OBEX right now. I can start it 3 times on 3 cogs. Start wave 1, then after 1/3 of the wave has passed, start wave 2, then after another 1/3, start wave 3. And repeat. In between I'll have to figure out something to hold the motor at precise positions, but I'll cross that bridge when I get to it. I am making a dedicated driver, so I can use all 8 cogs without any issues.
Sign In or Register to comment.