Pages: [1]   Go Down
Author Topic: 3-phase sine wave generator(pwm)---finished design  (Read 2719 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This topic is not a request for help on my project, im simply posting code for my most recent project.

Any one having trouble creating (or are looking for) code to make a muliphase sine wave generators? I know i was, and thanks to the help of tmd3, my design is finally finished. Anyone who needs such code feel free to download it, and once again, THANK YOU tmd3 for all your help! this woud've never been possible without your help! so thanks!

The generator has 3 outputs: out1, out2, out3. It also has 2 inputs: enable (pin smiley-cool, and freqpin (pin A0). the enable pin (pin smiley-cool, enables the generator whenever its value is HIGH. Remember to connect this pin to a resistor connected to gnd, or the board wont be able to tell if the input is HIGH or LOW. The freqpin (pin A0) is connected to the center(second) pin of a pot, which has its first pin connected to 5v and the 3rd to gnd.

anyway, feel free to download the code for your own projects! also, make sure you compile the code before uploading it to your board, as i compiled this code to upload to my arduino leonardo. Uploading to other boards should still work, just make sure you compile it to upload to your board.

READ THIS IF YOU WANT TO MODIFY THE CODE:

-The frequency of the generator is controlled by a pot. The specific code for that is the delay in the loop, which should come up as delay(freqpin). If the pot isnt making the generator operate at a high enough frequency, change delay(freqpin) to delay(freqpin/#) the number of course being an integer. the greater the integer, the higher the frequency. The same thing applies to lowing the frequency, only instead of dividing by #, you muliply, and the greater the number for that, the lower the frequency.

-The resolution of the sine wave is controlled by const float y = pi/30. I RECOMMEND THAT YOU DO NOT TAMPER WITH THIS VALUE. if you want to change the resolution, however, MAKE SURE THE EQUATION IS AS FOLLOWS: const flat y = (#1)*pi/3*(#2). The greater the value of #1 is, or the lower the value of #2 is(NOT COUNTING 0), the lower the sine wave resolution will be. To increase the resolution, increase the value of #2 and decrease the value of #1(NOT COUNTING 0). Make sure that #1 and #2 are POSITIVE WHOLE NUMBERS.

* _3phasesine.ino (0.86 KB - downloaded 291 times.)
« Last Edit: July 14, 2012, 11:15:30 am by ajrenzetti » Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Thanks for sharing! Do you think this code will work for brushless dc motors? In my opinion, it should work the same but, maybe require slower ramp rates depending on the application.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i'm pretty sure it should work on brushless dc motors. in fact, its for this very reason i created this code. i havent tested it out on a dc motor yet, but i have tested it out on led's, which seem to work exactly as they would from a 3 phase pwm sine wave.

just remember to hook up each of the 3 motor inputs with a low pass filter, which should smooth up the operation a little.
« Last Edit: July 14, 2012, 11:29:07 am by ajrenzetti » Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Wonderful to hear! I have some interest of building a ESC for a quadcopter but, it is down the list.

 I think it would be nice to have a single ESC with microprocessor that could run four channels so that the component cost an count would be much smaller.

 I am not sure it would be possible with 16MHz chip but, it should be easy with a faster Arm style chip.

 If you feel like building a board, it would be interesting to see and try to help with that too.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to generator 20hz sinewave with this code and can't seem to change output with potentiometer. Any thoughts?
Logged

Pages: [1]   Go Up
Jump to: