Shop OBEX P1 Docs P2 Docs Learn Events
3 Phase Motor Control — Parallax Forums

3 Phase Motor Control

TappermanTapperman Posts: 319
edited 2010-09-16 11:29 in Propeller 1
· I have been trying to build my own 3 phase inverter for some time now ... and finally made some headway in the last 2 days ... success at last!

· I'm hoping·that Beau Schwabe, who wrote the PWM object (in the object exchange) will help with this one, maybe?

· I want to convert the code included in the AN984 to the propeller ASM.· But I'm not very good at assembly on either micro ... and believe the one in the AN984 is a PIC of some sort, below is a link to the doc.

···· http://ww1.microchip.com/downloads/en/AppNotes/AC Induction Motor 00984a.pdf

I wrote a real clunky SPIN version (works ok at slow speed)· using the PWM from the object exchange.· Which I attached below.· Watch Pin 1, 2 or 3 on an o-scope and see what happens.· I happen to be lucky enough to have 3 phase motor out of a UHER reel to reel tape recorder, that operates on 6 volts.

As soon as I figure out how to make my camera take motion pictures, I'll attach a video of the thing running.· Boy is it smooth.

Anyone else want to make an electric car?·· roll.gif
«13

Comments

  • evanhevanh Posts: 16,161
    edited 2010-01-26 23:36
    I gather those 6 volt motors you have are induction motors? A permanent magnet motor might have some adverse reactions to your code.

    Looks like you're having some real fun though. [noparse]:)[/noparse]
  • TappermanTapperman Posts: 319
    edited 2010-01-27 01:05
    Yes, they are induction motors ... and Yes, I am enjoying myself!· smilewinkgrin.gif
  • mikedivmikediv Posts: 825
    edited 2010-01-27 01:08
    An electric car?? Are the motors really that big from a tape drive??
  • TappermanTapperman Posts: 319
    edited 2010-01-27 01:43
    No, I just don't have the IGBT's I ordered from Mouser electronics yet.· When they arrive I will use these on a 7.5 HP 3 phase motor that is wound for either 440 or 220.· I'm going to use it on 220 ... but I'm not going to use the full voltage .. hopefully I will be able to get up to around 900 of its 1800 RPM design speed.

    http://www.mouser.com/ProductDetail/STMicroelectronics/STGE200NB60S/?qs=BJlw7L4Cy7%252bM2r%2fNHVO%252bEA%3d%3d

    The above link should show the IGBT's I plan on using.

    Post Edited (Tapperman) : 1/27/2010 1:49:46 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-01-27 03:58
    Tapperman,

    My brother-in-law is more on the EV scene, but more on the scale of motorized bikes at the moment with dreams of building a car. I haven't visited my PWM code in awhile, but I think it should be doable. That said, I don't know how a 3-Phase motor would react to a square wave, I see plenty of applications that do it that way though. Personally I would want to create a nice sine wave, not too difficult after reverse engineering a couple of Sine wave inverters of my own.

    Tapperman,
    You do know that there is an option with the PWM code that I wrote that allows you to Phase sync multiple pins... looks like you are doing it in a loop when the object already will do it for you.

    ''-------- This Block creates a 3-Phase 60Hz square wave on Pins 1,2, and 3 -----------
        PWM.Duty(1,50,16665)        ''Create a 60Hz 50% duty cycle on Pin1
        PWM.Duty(2,50,16665)        ''Create a 60Hz 50% duty cycle on Pin2
        PWM.Duty(3,50,16665)        ''Create a 60Hz 50% duty cycle on Pin3
        PWM.PhaseSync(1,2,5555)     ''Phase Sync Pin2 to Pin1 with a Phase leading by 120 Deg    
        PWM.PhaseSync(2,3,5555)     ''Phase Sync Pin3 to Pin2 with a Phase leading by 120 Deg
    
    



    ...You should be able to adjust the speed by varying '16665' and '5555' the latter being 1/3rd of the former.


    For Sine Wave:
    My own misconception was that you needed an inductor and capacitor at a resonant frequency of 50 Hz or 60 Hz ... This is a false assumption on my own behalf and doing so would require a HUGE inductor. You do need an inductor and capacitor however but only acting as a low-pass filter towards your PWM frequency. In this case the inductor capacitor combination ends up being MUCH smaller. Typically your PWM frequency is 5kHz and up. Whatever it happens to be, set your low-pass filter to be at least a third of that frequency.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 1/27/2010 4:13:13 AM GMT
  • TappermanTapperman Posts: 319
    edited 2010-01-27 06:11
    Thankyou for responding ... first I should clarify that I have used your PWM as it was written (very nice by the way!) and it does run my 3 phase motor ... but at slow speeds its kind of 'jerky', but steadys out when you increase speed.


    And also, I was unaware that you could control a motor that way either!!! I thought as you do, that you need capictor, inductor network of some sort to smooth out the square wave into a perfect sine wave. Appearantly there are energy losses if you don't have a perfect sine wave. Something the engineers refer to as power factor. I'm learning, but at this point I'm not sure about this last parameter. Here's a concept link:

    http://www.freescale.com/webapp/sps/site/overview.jsp?code=WBT_MOTORPWMTUT_WP

    If you follow the link in my original post, you can view the AN-984 PDF ... and clearly outlines the technique used in this application. As a matter of fact, her is the link to there promo-video:


    http://www.microchip.com/get/PCJT


    Not only do they control 3 phase motors with the unit ... they can also drive a brushless DC motor (and if I remember correctly - it does have a permenant magnet in it).


    Watch the video, then go back and read the application note (source code is at end) ... but, the code can not be directly converted ..as it uses interupts.


    Also, would your PWM object run faster if the ASM portion, only provided control over say 6 pins versus 32?
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2010-01-27 06:59
    Tapperman - I'm not sure if this will help, but there was another thread where Phil did some PWM work and I believe he used the video generator circuit. I don't recall if he was only using one line or if he was able to control multiple outputs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • TappermanTapperman Posts: 319
    edited 2010-01-27 19:04
    What thread? I'm having trouble finding it?
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2010-01-28 00:17
    I am not finding it with the forum search right now either. What happen to search.parallax.com? That use to work and was the best way to search the forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • TappermanTapperman Posts: 319
    edited 2010-01-28 18:14
    Thankyou Timothy Swieter & evanh!!! Haven't read much more than three paragraphs .. but already looks VERY promising!

    OK, just read the source code ... and I can't use it.· All the signals (from 1 to 8) are leading edge aligned.

    Even though, I'm inducing a AC current with a DC voltage, I would like the current draw off of the batteries to be stepped one at a time.· Rather than all at once.

    ... Onward, more research.· tongue.gif

    Post Edited (Tapperman) : 1/28/2010 6:29:41 PM GMT
  • evanhevanh Posts: 16,161
    edited 2010-01-28 22:54
    I wouldn't be at all worried about the instantaneous square-wave voltages being aligned. The currents most certainly are not so aligned. Even without filtering, the inductive nature of the motor means the currents are much more aligned to the rotating sine-wave that you are modulating.
  • TappermanTapperman Posts: 319
    edited 2010-03-03 01:37

    Beau Schwabe (Parallax) said...
    Tapperman,
    You do know that there is an option with the PWM code that I wrote that allows you to Phase sync multiple pins... looks like you are doing it in a loop when the object already will do it for you.



    ''
    ThisBlockcreatesa3-Phase60HzsquarewaveonPins1,2,and3
    PWM.Duty(1,50,16665)''Createa60Hz50%dutycycleonPin1
    PWM.Duty(2,50,16665)''Createa60Hz50%dutycycleonPin2
    PWM.Duty(3,50,16665)''Createa60Hz50%dutycycleonPin3
    PWM.PhaseSync(1,2,5555)''PhaseSyncPin2toPin1withaPhaseleadingby120Deg
    PWM.PhaseSync(2,3,5555)''PhaseSyncPin3toPin2withaPhaseleadingby120Deg
    </CODE>

    ...You should be able to adjust the speed by varying '16665' and '5555' the latter being 1/3rd of the former.
    Just wanted to write a followup on this subject. The driver I have written is done. I've been waiting for a friend of mine to come through with a video camera. And today he did! So here is a link to the motor running on your suggested object from above snippet:

    http://www.youtube.com/watch?v=gzfRf3hQEBg

    and here is the video of my driver loaded seconds later and run on the same motor:

    http://www.youtube.com/watch?v=VWzE7rD_KdU
  • kf4ixmkf4ixm Posts: 529
    edited 2010-03-03 02:53
    that is cool tapperman, do you plan to release your driver?
  • TappermanTapperman Posts: 319
    edited 2010-03-03 03:01
    I'm still working on it ... But YES! I am hoping to fabricate a PC board just for the occasion.· Oops, I guess there is sound in it ... I thought there wasn't, then discovered my volume was off on my speakers.
  • BRBR Posts: 92
    edited 2010-03-03 03:15
    Paul Rowntree did a nice brushless DC motor controller object a while back:
    http://obex.parallax.com/objects/414/

    ...it may be of some use.
  • ManAtWorkManAtWork Posts: 2,178
    edited 2010-03-03 08:36
    Hello Tapperman,

    why not use the sine table of the propeller and generate true sine waves? For an electric vehicle, I think, you don't need very precise control of the motor, so a simple V/f control should do. You can also drive the motor in the weakened field area, I mean, if your motor is rated for 220 volts at 1800rpm and you only have 110 you can still drive it to 1800rpm but with only half the torque. Ramp up the voltage until 900rpm (30Hz) and then apply constant voltage up to 1800rpm (60Hz). Torque will drop inversely proportional to speed above 900rpm, then. But that doesn't matter much. You need the highest torque at low speeds anyway for acceleration and climbing.

    BTW. I'm currently building a three phase sine wave motor controller for permanent magnet motors. I do it "state of the art" with current vector control, clarke transformation and so on. But this is much too complicated for your application. Just a preview: http://benezan-electronics.de/forum/videos/BeneHack22.avi

    There's only one "problem". You surely want the throttle to control the torque and not the speed of the motor. So you need some feedback of the actual motor current or motor speed or both. Otherwise the motor will stall if you drive it with too high frequency while it's still spinning at low rpm.

    Cheers
  • TappermanTapperman Posts: 319
    edited 2010-03-03 19:24
    ManAtWork said...

    Hello Tapperman,

    why not use the sine table of the propeller and generate true sine waves?

    That's what I'm doing now.· I'm also using an old hard drive to detect motor movement at the output shaft.· It acts as a 2-bit grey code device.· Detects forward and reverse movement.
  • TappermanTapperman Posts: 319
    edited 2010-03-03 19:30
    ManAtWork said...

    Hello Tapperman,

    BTW. I'm currently building a three phase sine wave motor controller for permanent magnet motors. I do it "state of the art" with current vector control, clarke transformation and so on. But this is much too complicated for your application. Just a preview: http://benezan-electronics.de/forum/videos/BeneHack22.avi
    I clicked on your link ... but I didn't get any response (might be my windows?).· But I enjoyed your comments, and I would like to hear more about your controller (might have to move it to another forum though).· Of course, I'd like to look at toyota's software too!· I guess I shouldn't expect too much?

    Thanx
  • ManAtWorkManAtWork Posts: 2,178
    edited 2010-03-03 20:56
    Hello Tapperman,

    I checked the link, it should work. But you need a media player capable of displaying divx format. Google for divx or take VLC media player.

    If you have an encoder (grey code sensor) on your shaft then it's easy. Torque control can also be done sensorless but that's very complicated.

    An induction motor (squirrel cage motor) produces torque proportional to slip. If your motor is rated, for example, 60Hz 1740rpm then it has 2 pole pairs and 2Hz slip at rated torque. It would spin at 1800rpm with no load. 1740rpm = 29rps. 29/s * 2 = 58Hz. 60Hz - 58Hz = 2Hz. So you can simply add 2Hz to the sensed speed and drive the electric field a little faster than the shaft spins. Below the rated speed the voltage should be nearly proportional to speed with an offset to compensate for the resistive losses. Typically, 5 to 10V at 0Hz ramped up linearly to rated voltage at rated speed will do.

    You could vary the slip proportionally to the desired torque (throttle pedal angle). However, that results in a poor efficiency at partial load. The motor would have an idle current of 50 to 60% of the rated current at full torque. So you can also decrease the voltage linearly·from say 30% to 100% for 0 to 100% torque. This has the disadvantage that it takes some time to reach the full current due to the large inductance and delay between stator current and rotor current. But we don't need a high dynamic servo system here. You want to low-pass filter the throttle singal anyway to avoid jerks.

    My own motor controller is still in the experimental stage. I'll release more infos when it does something useful.

    Cheers
  • TappermanTapperman Posts: 319
    edited 2010-03-04 01:30
    @ManAtWork, see my post in the Sandbox:

    ······· http://forums.parallax.com/showthread.php?p=886880
  • PhilldapillPhilldapill Posts: 1,283
    edited 2010-03-04 04:40
    This is too cool! Tapperman, if you need any help making the PCB for this, send over the circuit schematic, and I'll make a Prototype PCB and send it to you - free of course. I've been wanting to make one of these as well. Very cool!
  • TappermanTapperman Posts: 319
    edited 2010-03-04 16:33
    Philldapill said...
    This is too cool! Tapperman, if you need any help making the PCB for this, send over the circuit schematic, and I'll make a Prototype PCB and send it to you - free of course. I've been wanting to make one of these as well. Very cool!
    Your on!· It's been a while since I've done any PCB work.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2010-03-04 17:04
    May I recommend "Power Electronics: Converters, Applications, and Design" by Ned Mohan.

    I'm no expert on power electronics but this is what I was pointed to by the power electronics guys at Nottingham Uni when I was interested in making a switched supply. It does cover quite a bit of drive stuff.

    Graham
  • TappermanTapperman Posts: 319
    edited 2010-03-04 19:43
    Graham Stabler said...
    May I recommend "Power Electronics: Converters, Applications, and Design" by Ned Mohan.

    I'm no expert on power electronics but this is what I was pointed to by the power electronics guys at Nottingham Uni when I was interested in making a switched supply. It does cover quite a bit of drive stuff.

    Graham
    @Graham -·Thankyou, I just ordered it from Amazon.com ... That's a BIG book (800 pages), and $125.02 takes a bite out of my DIY EV budget.· But from the looks of the table of contents, the guys at Nottingham Uni steared you in the right direction.

    Thanx again.
  • LawsonLawson Posts: 870
    edited 2010-03-04 22:35
    Regarding three-phase PWM, I'd suggest using the two counters and running one in software. First the counters would be put in duty mode and FRQx would be set to 1. To generate a specific length pulse PHSx would the be set to -length. Repeat this at a known rate and single cycle accurate PWM can be done. Adding the third software PWM is similarly simple using WAITCNT. Combining a software PWM using WAITCNT and some other useful calculations gets more interesting as calculation delays need to be hidden.

    My own need to drive a hard-drive platter motor was satisfied long before I got to the sophisticated driver I sketched out for myself. Spin code + a 40v current limited lab psu + 3/2 H-bridge = 20,000rpm hard disk [noparse]:D[/noparse] This worked so well I didn't even bother implementing back emf block commutation, let alone 3-phase sine wave PWM with current and power factor feedback, or a full flux vector drive.

    Look forward to what you produce,
    Lawson

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2010-03-05 00:41
    For anyone else interested you might want to check out the likes of abebooks for second hand copies, if you don't mind not having the newest edition you can get it quite cheaply.

    Graham
  • TappermanTapperman Posts: 319
    edited 2010-03-07 00:28
    Lawson said...
    Regarding three-phase PWM, I'd suggest using the two counters and running one in software. First the counters would be put in duty mode and FRQx would be set to 1. To generate a specific length pulse PHSx would the be set to -length. Repeat this at a known rate and single cycle accurate PWM can be done. Adding the third software PWM is similarly simple using WAITCNT. Combining a software PWM using WAITCNT and some other useful calculations gets more interesting as calculation delays need to be hidden.
    You have some example snippets?· I tried using the two internal counters·.. but I couldn't control the freq in duty mode.· From what I recall, someone told me that approach wouldn't work (somewhere in this forum, I can never find anything with the built in search).

    For my application, I can not exceed 5KHz.· My IGBT's wont take it.· So I downloaded Mr. Schwabe's driver in the OBJECT exchange, and modified it for my own purposes.· His object let's me set the phase between pulses, which is handy to keep the draw from the Bat's staggered.· I can set the carrier freq, and then change the duty cycle on the fly.

    I do have a mystery though, according to what I have read .. the sum of all three currents should be zero at any instant in time.· But I get the signal shown in the BMP attachment from the stator, and it seems to center around 2v (I'm driving the motor w/6V)

    Post Edited (Tapperman) : 3/7/2010 12:37:56 AM GMT
  • yarisboyyarisboy Posts: 245
    edited 2010-03-07 03:21
    I bought all the parts I'd need to build a small drive for my wood lathe. My old IGBTs can switch up to 20 KHz. I've got six hall effect sensors to monitor current flow from each of the IGBTs. Most VFDs use very few current sensors because the processors are so limited compared to the prop. If each IGBT is controlled by its own cog the resolution of control can far exceed all the old work you'll be tempted to read up on. The PIC crowd points to the body of work in their ANs and feel that their solution is perfect and the wheel does not need to be reinvented. I disagree. Algorithms are possible with the Propeller that had to be ruled out with earlier processors. For these applications the total harmonic distortion that can be driven to unprecedented low levels with a modern multi-core processor. Current samples can be compared to what is desired for the motor with the sine table being used to get the set point values based on speed, frequency, slip and torque level input from your pot box under your right foot. Instead of being an open loop PWM one can monitor current magnitude and THD on the fly and switch the IGBTs in a totally deterministically way never before possible with affordable processors. With two cogs left over the prop can also switch a modern electronic transmission reducing traction motor weight even more.
    I usually bat these ideas around on DIYelectriccar.com more than I do here. I'm glad to see the lights coming on here too. At work we have antique inverters driving 200 hp and 400 hp motors that pump water. The are so noisy you need ear plugs to be around them. Based on their age I wouldn't be surprised to find SCRs in them if I opened them up. The noise/THD problem produces unneeded heat and requires the motors to be "inverter duty". The square waves cause eddy currents in the rotor shaft that will knock out bearings if one of them isn't properly insulated electrically. Reducing THD will cut the cost of traction motors from mine trucks to light rail cars. Prop-on.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    MOORE'S LAW: The capabilities of electronics shall double every 18 months.
    cloyd's corollary: Hardware is easy, software is hard.

    Post Edited (yarisboy) : 3/7/2010 3:36:04 AM GMT
  • TappermanTapperman Posts: 319
    edited 2010-03-10 02:15
    yarisboy said...

    I usually bat these ideas around on DIYelectriccar.com more than I do here. I'm glad to see the lights coming on here too. At work we have antique inverters driving 200 hp and 400 hp motors that pump water. The are so noisy you need ear plugs to be around them. Based on their age I wouldn't be surprised to find SCRs in them if I opened them up. The noise/THD problem produces unneeded heat and requires the motors to be "inverter duty". The square waves cause eddy currents in the rotor shaft that will knock out bearings if one of them isn't properly insulated electrically. Reducing THD will cut the cost of traction motors from mine trucks to light rail cars. Prop-on.

    Thanks, a wealth of information has come flooding my way since my recent post's here.· I'm selecting hardware at this point and am currious if you (or anyone) has used or heard of:

    ··· http://www.mouser.com/catalog/specsheets/L01ZXXXS05.pdf

    This sensor?
Sign In or Register to comment.