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
, and freqpin (pin A0). the enable pin (pin
, 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.