Jump to content
 
  • 0

PStechPaul

Question

  • Member

I have been trying to find a good way to produce three phase PWM sine waves, and I was getting stuck on the concept while looking at the phase-to-phase PWM signals. But then I realized that it just required generating three sine waves on the AH/AL, BH/BL, and CH/CL bridge pairs. Also, the PWM values need to be offset by 1/2 the peak value. So I made a spreadsheet that illustrates the waveforms of the individual bridges to ground, as well as the phase-to-phase voltages A-B, B-C, and C-A. Here is the spreadsheet and graphs:

Three_Phase_Sine_Waves.jpg.0146ec8e258773979a8184ff036f4027.jpg

Three_Phase_Sine_Waves_P-P.jpg.b4e6b3dfe31cea2a651e7da8b44c702d.jpg

I plan to implement this on a PIC and will post source code and other details. Feel free to add suggestions and discussion.

Three_Phase_Sine_Waves.ods

http://enginuitysystems.com/pix/electronics/Three_Phase_Sine_Waves.ods

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • Member

It would be interesting to know what you will be driving with this, and which device you are planning to use. It will also help to know what the frequencies should be, number of etc.

There are some interesting ways to do this, with new devices such as the K42 family it is possible to set up DMA to bang out the signals for you while the processor could even be sleeping!

If you are driving a motor it may also be interesting to look at third harmonic injection, saddle wave PWM's or space vector modulation to get maximum power out of the system.

Have you settled on a device to use or is this still wide open?

This btw. is SVM from an old 2005 Microchip Application note for a dsPIC (AN1017)

image.thumb.png.27441d8ffe9090de782676d07e4818b6.png

Link to comment
Share on other sites

  • Member

I will probably use a PIC18F2331 or 2431, mostly because I already have a few on hand. But I might use a PIC16F18325 or similar device. I want to see, first, how simple I can make a three phase motor controller, even using rectangular "modified sine wave" drive, with basic V/f control. As I gain experience, I may choose something like the dsPIC33FJ16MC101 or dsPIC33FJ32MC102. This will be intended for use on small EVs like tractors.

Link to comment
Share on other sites

  • Member

Creating the sine waves is fairly easy, I usually do that with a sine lookup table and simply having 3 index variables indicating where each phase is, you then simply copy the PWM DC value to the PWM register on a regular interval, like a  timer interrupt.

But as always the devil is in the details. You have to do something different if the motor is sensorless, eg. as measuring the back-emf while driving it becomes a challenge. 

I recently did a 3-phase brushless DC motor project for a friend (we built a grain mill for him to make beer - important stuff! ). The motor was sensored so it was drop off a log easy, had it been sensorless it would have been much more of a challenge. We simply drove the coils with square waves and adjusted the power on each wave by driving it PWM. Since motors have lots of inductance the currents in the coils end up being pretty sinusoidal as it makes a great filter on your square wave signal. We never measured the exact torque, but we added a PID controller and it now runs at 70 RPM (the video shows around 3000 RPM peak) and it is not possible for 2 people working together to stop that motor from spinning it has so much torque!

So if you can give us some more info about the motor, is it BLDC, is it sensored or sensorless, etc. We can be of more help 🙂

Here is a video of the motor spinning with that method (it is a Fisher and Paykel direct drive washing machine motor).

Link to comment
Share on other sites

  • Member

Pretty cool stuff! Around 2004 I rewound a single phase 3/4 HP 120 VAC 4 pole induction motor, to make a 7 VAC, 12 pole,three phase motor. I used a 220V 3 HP VFD and two step-down transformers to run it at 240 Hz which was about 1800 RPM. My idea was to run a three phase motor directly on a 12 VDC battery, or perhaps a 48V battery pack clocked at 4x frequency to get 4x power. I also made a very rough VFD using a PIC16F684, with modified sine (rectangular) waves, and it did run, but after a bit the driver transistors blew out. I know a lot more now about how to properly choose and drive MOSFETs, and that's what I plan to do with this project.Motor_Winding_P7110002.jpg.2bc164a959a284b670458655c340c45f.jpgMotor_Winding_P7110001.jpg.81ff98d06b7272a0eb232864ddfa8fd5.jpg

I added functionality to my spreadsheet that adds a percentage of 3rd harmonic to the synthesized waveform, and I can reproduce the increased output voltage in that way. This is 15% harmonic.

Three_Phase_Sine_Waves_1.jpg.0f57981f9461cd30ad3845308d3579a1.jpgThree_Phase_Sine_Waves_1_P-P.jpg.279787c5ec4e734dd21fdfc104399f57.jpg

I updated my file: http://enginuitysystems.com/pix/electronics/Three_Phase_Sine_Waves.ods

Link to comment
Share on other sites

  • Member

That looks awesome! Must have been quite a job rewiring that! I have heard of a lot of people rewiring the Fisher and Paykel motors to use them as either E-Bike's or for wind turbines, people even shave the poles for decogging the motor so it will not be stalled in low wind conditions. Here is a picture of one guy filing down the poles:

image.png.bfe42d93f1a36cacde08be5b769844e4.png

 

Now that you have that spreadsheet I think the easiest way is to select your switching frequency, scale the values to match your PWM duty cycle range and then simply set up a timer interrupt on which you read out the values and transfer them into the PWM duty cycle register. That will give you a sine wave generator. The next challenge is to control the frequency, this is a bit harder. 

If you had a micro with a HLT it would adjust the frequency for you automatically and you are done, but without it you need to adjust the time base, which means the range of the PWM changes as the speed changes, and generally this means you have to do math at every interrupt, which will limit how fast you can go. At that point since the 8-bit does not have a hardware multiplier it becomes necessary to move to something like the dsPIC which can handle the heavy lifting of the scaling.

I like the HLT solution though, and you could also build what the HLT is doing in software, it really is just a period divider using counters...

Now all of that will give you beautiful signals and maximum torque and all that Jazz, but I would just drive it with square waves myself, much simpler and you get pretty close to the performance you will need. Like I said on the mill we did that and got way more torque than we needed, so we never went all the way to SVC.

EDIT: Sorry guys, I meant to say Angular Timer there when I said HLT 😞

Link to comment
Share on other sites

  • Member

I plan to use a look-up table for the PWM values, which may include the third harmonic. Then I will multiply those values based on speed. I have 60 points per cycle, which can be implemented with a 15 point table. One problem I see is that in order to have a full PWM cycle for each sample, the carrier frequency would need to be adjusted for various speeds. There may not be a problem if the PWM frequency is high enough that at least perhaps 10 PWM periods are used at maximum speed, which would mean that, for 60 points per cycle, the frequency for 60 Hz would be 60 * 60 * 10 = 36 kHz. There would still be up to a 10% or so error depending on the frequency. Otherwise, I could generate an interrupt on each PWM period to change the duty cycle, but that would mean a variable PWM frequency depending on speed.

Perhaps the rectangular (modified sine) wave would be sufficient. In that case, the pulse width would remain constant, but the time between pulses would vary according to speed. There will be a maximum pulse width based on the inductance and saturation characteristics of the motor.

I'm still trying to wrap my brain around these concepts, and maybe I'm over-thinking it.

[edit] I had to look up HLT:

http://ww1.microchip.com/downloads/en/AppNotes/90003122A.pdf

Link to comment
Share on other sites

  • Member

It is too bad the angular timer only exists on the PIC16F161x family.  It can automatically give you events on any phase angle and synchronize these phase events to pulses on an I/O pin (or comparator).  It sure does save a lot of math.

But the PIC16F161x only has 20 pins so debugging BLDC systems gets challenging.  Also, it has 2 CCP's and 2 PWM peripherals for a total of 4 PWM's but they are of different types.  To drive a 3phase motor we played lots of games with the PPS to steer the PWM's to the needed MOSFET pairs.  It worked, but some of the savings from the angular timer went into PPS games.  It may have been easier to use 2 PWM's and 1 CCP.

Here's hoping we get a high pin-count, high PWM device with an angular timer.

Link to comment
Share on other sites

  • Member
3 hours ago, N9WXU said:

It is too bad the angular timer only exists on the PIC16F161x family.  It can automatically give you events on any phase angle and synchronize these phase events to pulses on an I/O pin (or comparator).  It sure does save a lot of math.

But the PIC16F161x only has 20 pins so debugging BLDC systems gets challenging.  Also, it has 2 CCP's and 2 PWM peripherals for a total of 4 PWM's but they are of different types.  To drive a 3phase motor we played lots of games with the PPS to steer the PWM's to the needed MOSFET pairs.  It worked, but some of the savings from the angular timer went into PPS games.  It may have been easier to use 2 PWM's and 1 CCP.

Here's hoping we get a high pin-count, high PWM device with an angular timer.

 

Oh yes sorry Paul! I had my wires crossed there, I meant to say Angular Timer and sent you off looking at the HLT instead, sorry, my bad. That was a silly mistake!

 

Link to comment
Share on other sites

  • Member

I found an app note on the angular timer. I don't think it will be particularly useful for control of a 3 phase induction motor, especially if it does not implement a rotary shaft encoder. It seems to me that the PIC18F2331 series is the best legacy part to use, and otherwise the dsPIC33FJ32MCxx. The latter part may be preferable because it has support from the MCC or Harmony, but for now I want to keep it simple.

http://ww1.microchip.com/downloads/en/AppNotes/90003143A.pdf

Link to comment
Share on other sites

  • Member
1 hour ago, PStechPaul said:

I don't think it will be particularly useful for control of a 3 phase induction motor, especially if it does not implement a rotary shaft encoder.

I would like to understand this statement of yours a little better? The idea with the Angular Timer is that you can use something like a timer to trigger the time base, and it will give you (in your case) 60 regularly spaced timing pulses for every time base pulse you provide. This would allow you to control the frequency quite easily and simply read out the state for each PWM at every one of your 60 points, and you can extend this to as many phases as you need as this only does the time base?

I agree that the 1619 is not a great device for 3-phase as it has only 2xPWM channels, but the Angular Timer should really simplify the time base for you, as you would be able to do it all without any divides or multiplies. Of course if you want to scale the output amplitude you would need to multiply, unless you generated a DC rail which you could move (e.g. if you used a switch mode regulator to produce the rail for you).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

 


×
×
  • Create New...