Author Topic: Creating a variable frequency and variable amplitude sine wave using pwm  (Read 2229 times)

0 Members and 1 Guest are viewing this topic.

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
Hey everyone this is my first post. Im wondering if anyone herr can help with this. So im building a motor controller from scratch its my first big project. I want to try alternatives to field oriented control. And im having fun doing it. Im currently learning programming micros (rich subject) so this is my question and it may be a silly one . Ok so to produce a sine wave from a lookup array id isr at ech pulse and update the compare register .. however if i try to change the frequency aswell wont this have an effect on the pulse widths? How is this compensated for ? Or am i missing something really stuoid?  Thanks for your input guys and gals ! :-)
The reason for this is i have an idea similar to foc that might be a little bit more efficient so id like to implement it and do some tests. Any reading material on this subject would be greatly appreciated . Many thanks again!
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Unlikely you have invented anything superior to FOC, if you have to ask how to implement a basic PWM modulator outputting a sinewave.

By the way, for a three-phase drive, sinewave is NOT the waveform you need to appear on the output leg of the inverter. That would provide low modulation index.

Search for for example: Third harmonic injection, sixty degree PWM or space vector modulation (SVPWM).

If you want to learn about more efficient modulator, look for DTC (direct torque control), for example the Takahashi algorithm.
 
The following users thanked this post: Jason key

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1545
  • Country: au
Ok so to produce a sine wave from a lookup array id isr at ech pulse and update the compare register .. however if i try to change the frequency as well wont this have an effect on the pulse widths? How is this compensated for ?

Usually, the low frequency motor drive sine waves, are created by modulating the PWM frequency, with 50% giving 0V on all phases.
if you want to vary both the frequency and amplitude the peak modulation depth sets the amplitude, and the rate of modulation sets the frequency.

A question on the design, is what feedback & control do you plan to use ?
For experiments, you could load a large Flash device up with many combinations of Frequency and modulation depth to load into the PWM - basically like a playback system.

If you want to do this more 'live', with feedback, then a more powerful chip with multiplies would make your testing simpler, as it is fast enough to generate live sine modulation

 
The following users thanked this post: Jason key

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
Tha ks yansi for the reading materia. Well im very new to microcontrollers. So yeah very useless at present only been teaching myself in free time for about 6 months so its all very new to me. I can see it in the wave forms what i want to do but its difficult for me to program a microcontroller at this stage to produce results i want. I will read up on this thanks so can you explain to me how a catiable frequency variable duty can be achieved. More so how to keep the duty cycle steady whilst changing the frequency? Thanks :-)
 

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
Hi thanks for your reply. Well so far iv designed a 40kw inverter that can handle inductive loads. That has taken 6 months to complete so as not to destroy the igbts. So thats working. Im not sure weather i definately want to measure currents and iv tried an optical feedback position sensor. And iv recently brought a c2000 piccolo dev board which is like a half dsp half micro does sine on the fly i think.. im half way theu a course . I alreqdy program in c but never pn embedded. So im halfway thru a course learning embedded c and assembly. Very cool im enjoying it loads.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
If you are new to microcontrollers, forget variable frequency drives.  Learn to work with microcontrollers for at least a year or two to gather experience and understanding, then try some advanced stuff like a VFD.

And also forget the damn shitduino, it is not suitable by any means for designing even the most basic of a drive. There way more suitable microcontrollers, even very cheap and small ones, that have the proper perihperals and capabilities to support a design of a VFD.



 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1545
  • Country: au
... More so how to keep the duty cycle steady whilst changing the frequency? ..
That's fairly simple, you look at the ON and OFF times and the ON/(ON+OFF) is the duty and 1/(ON+OFF) is the Frequency.
ie you can scale both on and off times, and keep duty fixed, while varying frequency.

 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Microchip has some great white papers on motor drives using PIC microcontrollers (of course).  Many are for polyphase AC motors.  Maybe spend some time searching over there.

Maybe something like this will give you some ideas:

http://ww1.microchip.com/downloads/cn/AppNotes/cn012129.pdf
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9019
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
There's a rather elaborate open source project for a motor drive based on a STM32.
https://openinverter.org/docs/index.html%3Fen_home,3.html
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
Yes yansi instarted on the arduino. Having no programming experience at the time. I actually found it a very usefull tool in realising the power of microcontrollers in a similar way a child would. So i started there. Then learnt c language. Then started to watch dr paz on you tube he used an arduino on the c level and now learning assembly as i like to know how things work so its nice to see past another layer of abstraction. So once iv finished the assembly part on the arduino. Im going to get theu dr saveks course of c using a ti launchlad as that dev board has a built in debugger and only costs 16 quid so that a bargain. I think itl be usefull to be able to see the registers etc. Im a quick learner picking this all up like a natural but still dont understand how you vary freq
and amplitute simultaneously. I like jumping inot the deep end :-)
 

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
... More so how to keep the duty cycle steady whilst changing the frequency? ..
That's fairly simple, you look at the ON and OFF times and the ON/(ON+OFF) is the duty and 1/(ON+OFF) is the Frequency.
ie you can scale both on and off times, and keep duty fixed, while varying frequency.
Ahh pcb wizz thanks i think youve answered my question so am i correct in saying on a bisc level that if i had frequecy x and a pwm of 50 percent and lowered the count on the timer compare thingy (excuse me im new to micros) that this would increase frquency but also increast the pwm as the toggle on cycles would stay the same but the cielinnof the counter would get less so the off time would decrease. Im reading that back and realise its a shit explanation.  So the timer counts to a max level then resets but the compare match you can set at different levels to get different duty cycles. What i meant was if the timer compare match stays constant and you change the timer count to reset (the cieling as looking at it on the familiar timer graphs with triangles) then you would increase the frequency but also increase the duty cycle .. in fact if the timer reset was lowered to a value below the compare it would just stay on and stop toggling ?  So the simple equation you posted keeps these in the correct ratio? I thought it must have had something to do with that.. in experience on my part.. yansi is right tho i need another 6 months to learn the basics. Thank you so much :-)
 

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
There's a rather elaborate open source project for a motor drive based on a STM32.
https://openinverter.org/docs/index.html%3Fen_home,3.html
 

Offline Jason keyTopic starter

  • Newbie
  • Posts: 8
  • Country: england
There's a rather elaborate open source project for a motor drive based on a STM32.
https://openinverter.org/docs/index.html%3Fen_home,3.html
Yes i wil have to look into this thank you
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf