PWM phase sync
bennettdan
Posts: 614
Hello,
I have been looking through Beau Schwabe's PWM_32 code and its has the ability to sync three PWM signals 120 degrees apart it works fine but it has about a 15khz limit and I dont need the other functions of the code just the three phase sync PWM.
I know I can get a much faster PWM switching speed with PASM and I looking for advice on how to use mutiple pins from one counter?
Also is it possiable to launch mulitple counters without using a cog?
Thanks Dan
I have been looking through Beau Schwabe's PWM_32 code and its has the ability to sync three PWM signals 120 degrees apart it works fine but it has about a 15khz limit and I dont need the other functions of the code just the three phase sync PWM.
I know I can get a much faster PWM switching speed with PASM and I looking for advice on how to use mutiple pins from one counter?
Also is it possiable to launch mulitple counters without using a cog?
Thanks Dan
Comments
Counters can only be used when the cog containing them is active. If it's fire-and-forget (counter) usage then the cog itself can run unrelated code.
I have been working with the counter app note and will see what I can come up with but just wanted a point into the right direction as to be able to sync the three pins.
I have not tested this yet though.
I dont really want to use three cogs if their is a way to do sync it in one cog, I will study on this some more thanks for the help.
pwmasm_3Phase.spin
pwmAsm - Archive [Date 2011.03.25 Time 21.49].zip
What is the maximum speed you are looking for?
If it is below, say 50 or possibly 100KHz, then there is a very simple one cog solution if you employ my multi threading scheduler,
If that is of interest to you then let me know and I will send you the scheduler kernel, but only if your application is not of a significant commercial nature. If it is, then a very small per-unit license fee would apply.
Cheers,
Peter (pjv)
Thanks for the help this might turn into a comercial product so right now I plan to work out the details with testing. I am working on a brushless 3 phase AC servo Amp for use on CNC equipment I have here in the shop but if it works out I plan to sell it at a hobbist cost.
I plan to switch my power stage around 15k to 20khz.
I have been looking into some other PWM examples that dont use counters they just sync off the system counter.
Phil (PhiPi) has also made an excellent PWM object that uses the video hardware and up to 8 channels, it operates at high frequency though is a little slow to change the duty.
This issue of the phase shift between the three channels, will this actually need to be done at the level of the PWM generation or will the phase shift be introduced in the modulation of the duty of the channels? i.e. if you wanted to produce a sinusoidal field variation you could modulate the duty in a sinusoidal manner and you would introduce a phase shift between the modulation of each channel while the PWM which could be at a much higher frequency could be synced perfectly. That is certainly the case for brushless DC motors used in model aircraft except they don't even bother with the sinusoid.
Graham
The duty concept directly from the counters works very well for many things that can tolerate fast and frequent switching transitions. Not so with power stages for motor drivers. They don't like the many short durations the counters produce, and causes significant unnecessary heating. A slower speed such as the 20 or so KHz Bennettdan suggests is much better, and that can't be done with the simple use of a counter in "duty" mode..... cog intervention is required.
Cheers,
Peter (pjv)
I am not using the counters in duty mode, this is true PWM (can vary duty 0-100% at a fixed f) and 20khz is no problem. It does use cog intervention but still leaves a lot of time for other code to run. Check my code out.
Graham
@pjv Peter I Don't mind using a one or even two cogs but if their is a way to do it in as little as one cog then that would be ok.
@ kuroneko I dont plan to change the duty cycle very much just set it to around 50% but I will ahve to reverse the Phase Sync to allow the motor to trun backwards.
This will be a true sine wave style 3 phase inverter I have it worked out as fars as how I plan to control the sine wave frequency its just the phase sync is the next step.
Thanks again for the help.
As I mention above I think the phase shifting is at the level of the sin modulation not at the PWM level. Like this:
The duty is varied to create the sine wave. The sine waves need to be out out phase but not the PWM (although the duties given to the PWM routines will be out of phase).
Unless I've missed something
Graham
I plan to output three 120 degree in sync PWM pulses at 10khz to 20khz on three prop pins then also a fourth pin I plan to output a Sine wave of the base 20hz to 200hz then using three Comparators I plan to feed one side the PWM and the other the Sine and when you look at the output of the Comparator it will look like the Picture of the varied duty cycle PWM sine wave.
I believe this will allow me to vary the voltage of the DC buss with PWM and also the speed of the motor with the varied sine wave.
Most AC drives dont filter out the high frequency pulses but I plan to use a Three phase filter which is basically a low pass filter with a cutoff of around 200hz.
I am not home right now so I cant test this code but if you or anyone wants to test this PASM program I wrote to output 3 120 degree in sync pulses of 50% duty cycle at 10Khz I would not mind at all this code is not finished I plan to add the math to allow this to be ran at other frequencys.
3Phase PWM.spin
BUT these are the tricks used before microcontrollers! As the first diagram shows PWM can create any voltage between +/- the bus voltage so you can easily create sine waves of varying amplitude and frequency directly from the propeller. You just need a sine look up table, the faster you move through the table the higher the frequency and the greater the multiplier between the table and the PWM duty the greater the amplitude.
In either case there is no need for the PWM itself to be phase shifted.
Graham