SETTING UP AND TESTING THE MICROCONTROLLER
Now it’s time to use your 1337 (elite) hacking skills to interface your tesla coil with your computer from scratch.
This step, for the first time ever in tesla coiling history, provides a direct and easy way for average hobbyists to build and tinker around with their own music board. Coilers don’t typically go into detail with this step because they assume that if you get up to this point, then you probably don’t need detailed instructions (plus it’s pretty cool, so why just give instructions away for free?). I produced this music board because I did not just want to buy one of those ones floating around online (they were $200 when I was looking!).
The microcontroller we will be using is the MSP430 Texas Instruments microcontroller. Why? It is really easy to use, and, unlike arduinos and the like, is dirt cheap (whereas arduino is more like a general “everything is here” board, the MSP430 is more specific, we just get what we need and won’t have to pay too much; it is around $5).
You will need to install Code Composer studio for your MSP430 in order to load codes to it. Specify a folder that you want to work in, and start a new project called Muzak. Follow the instruction book that comes with your MSP430 to do this. Once you have Code Composer Studio, download these files and/or copy and paste their code (this will require opening the .rar file): http://www.mediafire.com/?oogn9t59vvk4p2b
Put Muzak.h into your project folder. This file contains a table of notes that you will need.
Put Muzak.c into the “private” folder. This file contains code that specifies pulse width, clocking, and frequency information.
Put Main.c into your project folder. This file contains general instructions to the microcontroller.
Put Song.c in a new folder in your project folder called “songs.” This file is a music file that your microcontroller will play.
Put Rest.c in that same folder. This file is a music file that is empty.
What this code does is put a signal through pin P1.0. Once you load the code onto the board, you should see the red LED (light) blinking. This is because the music signal is sent through the LED and thus it blinks along with the song. To hear the song, remove the jumper across pin 1 hook up two wires from a speaker to P1.0 and Ground. You should here the song playing. Do you recognize it?MODIFYING TO FIT YOUR COIL
Look at the signal through an oscilloscope.
The signal for “on” is when the voltage reaches past a threshold voltage (the top part of the square wave). Don’t worry about the threshold voltage yet, because we will be using op-amps to increase the amplitude of the signal. But basically the top part of the square wave is “on” and the long bottom part at near 0 volts is “off.” When the coil is “on” energy flows freely into the primary circuit. A good analogy is an everyday playground swingset; imagine that swinging one way represents energy going into the capacitor and swinging the other way represents energy going into the inductor (primary coil). When you swing, energy goes back and forth, but to go back and forth requires that you begin pushing the swing. When energy flows into the primary circuit (the “on” stage) is analogous to someone pushing.
I know you really want to, but you can’t just simply plug the music board into the tesla coil. You have to adjust the signal’s PULSE WIDTH, FREQUENCY, and DUTY CYCLE. If pulse width is too high, then too much power will go through the IGBTs at once and they will blow. Similarly, if pulses go through the IGBTs one after the other too quickly, they will also blow. Finally, if the IGBTs are on for too high a percentage of the time (duty cycle) then they will overheat and/or blow. The key is to keep pulse width, frequencies, and duty cycle low, then to gradually increase them to see what they can handle or cannot handle. In my coil, I limited (absolute maximum) my pulse width to 200uS (microseconds), the frequency to around 150Hz (200 pulses per second), and around a 2.5% duty cycle (it can be on 2.5% of the time). Don’t expect anything much higher for your coil! Digital oscilloscopes (if you do not have one like me, see if you can use someone elses at a computer lab, college, or at a friendly engineer’s house) have the advantage that they measure all of these for you.
Adjusting the code will allow you to adjust all of these parameters. Open Muzak.c. There are variables near the top labeled specifically for you. Change their values and see what happens to the output waveform. You can also edit Main.c to give your microcontroller general instructions. Currently, the two instructions in the file are:
playSong(); <- this plays the song
delay_ms(0); <- this tells the coil to rest for a certain amount of time before the song repeats
After you have adjusted the code, check the output waveform using the oscilloscope and continue modifying until you get a desired output that you feel good will work well with your coil (start low first!). Years ago the first time I experimented with audio boards my frequency was way too high, and so my tesla coil blew (plus the audio quality wasn’t that great because at the time, my H@x0ring skills weren’t 1337 so I wasn’t coding songs, I was just using electronics circuits to modify audio output from any mp3 player (it was “analog” instead of “digital.”).CODING SONGS
I have included a few song instructions here: http://www.mediafire.com/?t48qa78eoplx760
, but if you would like to code your own, I will explain briefly how. In my High School java class, we programmed a fake robot and gave it a list of instructions. Essentially, coding music works the same way; you are giving your tesla coil a list of instructions on what to play. The code that we are working with is similar to java code in that it is object oriented.
Download Anvil Studio and a .midi file of your choice. Open the .midi file using the program. You will be given a graphical representation of the song of your choice, and you will see which notes play when and for how long (this is a good reference). This is all of the information you need to code a song! In the code there is a table of notes that I have pre-coded in, so all you have to do is specify a list of notes that will play in your song in succession, and for each note, specify the duration it plays and insert rests. After a few attempts and testing, you will find that eventually your coded song will begin to resemble what you would like. You can play around with making your own songs until you are satisfied.
For example, in Song.c the instruction beep(G1H, 120); tells the microcontroller to “beep” with a note G1H for a duration of 120 units of time (determined by the microcontroller’s clock speed). The note “R” is a rest.
You cannot have your song too long because otherwise you will run out of memory. In addition, these tools show you how to make a monophonic tesla coil audio board, and so, in other words, you can only play one note at a time.