Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)

uzzors2k, Thu Oct 22 2009, 08:48PM

Polyphonic Tesla Coil MIDI Interrupter

This is a little something I've been working on for the last month. It's a modular MIDI player, which can be used as a Tesla coil interrupter or synthesizer. For those who aren't familiar with MIDI, it's a music standard used largely by keyboards and drum pads, in which simple commands are sent serially, such as note on and off information, but not actual musical. That job is left to the synthesizer, which is simply told when a note is on or off, and must create the corresponding sounds (frequency, waveform, etc) itself in order to make audible music. So no matter what the original song is supposed to sound like, the MIDI signals simply tell us when a key is on or off (and a lot of other information, but nothing that's interesting for this project). This is perfect for Tesla coil modulation, as every SSTC or DRSSTC can be interrupted, and by interrupting the coil at the same frequency as the note being played, we can create music!

1256237317 95 FT0 Attiny2313 Midi Interrupter

This project has evolved from a monophonic MIDI player using a single ATmega32, to a multi-channel, multi-note (polyphonic) MIDI player using several ATtiny2313s working together. Each ATtiny2313 can play two notes at once, using Timer1 and the two Compare Match modules. The AVRs are organized so they all receive the same input, but only start playing notes once an enable input (PD5) is set high. Once an AVR has used both it's compare match modules to play notes, ie is full, an output pin (PB0) goes high. This way they can cooperate, and in theory play and infinite number of notes at once. The MIDI channel that the AVRs listen on is set using the four most significant bits on PORTB. I've made a small example circuit where three ATtiny2313s are chained together, and can either play 6 notes on one channel, 4 notes on channel 1 and two on channel 3, or two notes on channels 1,2 and 3. Depending on the switch positions. The firmware was made using WinAVR. Firmware, schematic and a command-line program for determining the compare match values here can be found further down.

For anyone else who wishes to tread down the path of MIDI, I recommend you read this article by Paul Maddox. It was a reference I used throughout the entire process, and saved me a lot of headaches. (not to say I still didn't encounter enough of them.) Also, if you wish to mix several notes together you need to keep the duty cycle low (~5%). This is obvious once it's been pointed out (thanks Steve W), because you can only send one bit of data down the line, and mixing two square waves results in areas at V/2 - which would require 2 bits of data to describe. Keeping the duty cycle low reduces the chance of an overlap. And the more square waves you mix the more bits are required. It's easy to see graphically if my explanation is poor.

1256240152 95 FT0 Square Mixing

The firmware itself is interrupt-driven. MIDI bytes are processed as soon as they are received, and once a full MIDI packet has been received a note is either turned on or off. When a note is turned on the correct off-time and on-time values are looked up and stored for quick access, and interrupts are enabled for one of the compare modules. If both compare modules are now busy an output pin is set high to alert any other AVRs in the chain that it's full. Once a compare module generates an interrupt, an output pin is toggled and the time until the next interrupt is determined depending on whether it's in a high or low state (to get an asymmetric waveform). When a note off event occurs the AVR first checks that it's actually playing the note before stopping one of the compare modules. The main program loop is just used to indicate when notes are being played and check what channel to listen on.

So far I've done little more than test this on a quarter watt PC speaker, but it's plays the Maple Leaf Rag perfectly, so I can't wait to try it on a SSTC or DRSSTC. The next steps in this project are designing a PCB, boxing up the interrupter, and finally making a dedicated SSTC. Don't be afraid to test this interrupter before I do, it'll still be some weeks until I can rig up a TC to test it on.

Wed Nov 18 2009

Progress is still snailing along. I made a PCB for the MIDI interrupter but ordered the wrong box size and only received one of the two 12MHz cyrstals I ordered. Still, I had enough to test the full circuit over a toslink connection, which works great with a small speaker. With a temporary 8MHz crystal on the last ATtiny2313 I couldn't get 6-note polyphony though, only 4-note. I hope this is due to the crystal speed, and not something in the code... I'll publish the PCB design and upgraded firmware once I've pinpointed the problem.

1258550221 95 FT78225 Img 1163

I later dusted off an old secondary and half-bridge from another SSTC project and fired it up using several different drivers. In the end Steve Conner's MKI PLL was the only one that worked reliably, thanks again man. wink With a 2250µF filter capacitor power draw is almost exactly 1kW and the discharge is fairly silent, no mains hum at least. Heatsinks stay cool and it appears to be able to run continuously in CW mode.

1258550221 95 FT78225 Img 1179


I figured a musical test was in order, so I hooked everything up for a trial run. Results left a lot to be desired... Low frequency notes gave decent sparks, but higher notes gave smaller streamers until I could only hear them without my earmuffs on. Eventually (within 10 seconds) the output died altogether, even when playing low notes. I turned off the coil at this point and removed the keyboard and set the coil for CW. When I turned it on again, after charging up the filter capacitor, I was blinded by an exploding bridge of IRFP450s. The toslink module was unshielded, and I hadn't disabled the IRFP450's internal diodes. Now before I go buy some expensive diodes, was this the likely cause of failure? This coil's resonant frequency is 625kHz.

Sun Nov 29 2009

I've tested the PCB and final source code now which all work, so it's a go for anyone looking to try this! I put the assembly in an ugly project box, and made a little teaser video. An actual Tesla coil test will have to wait until I get the high speed diodes I ordered from China.

Teaser video. ]mvi_1188.avi[/file]
Project files. ]tc_midi_interrupter.zip[/file]

Sun Jan 10 2010

Holidays are over and it's back to work! I reassembled the Tesla coil and popped some brand new MUR1560 diodes into the full-bridge this time. So far they appear to have solved the problems I had earlier, and the coil can be interrupted without exploding. I have a habit of turning off the logic supply before the main power, which caused some headaches today. So despite constantly forgetting to power the coil down in the right order, thus loosing at least four full-bridges, I managed to get it functioning again.

At first I tried the MIDI interrupter carefully, in non-inverted mode (like a DRSSTC, so ON-times are short) this resulted in absolutely no output from the coil. I suspect the PLL isn't able to lock quickly enough, so that's one problem which needs fixing. So when that failed I switched the interrupter into inverted mode, so it runs CW until interrupted. And it worked!!! I've made a few videos flaunting my coil already.

Super Mario Bros. 2
Maple Leaf Rag

The video doesn't do the sound quality justice with all the background noise, in person the sound is quite clear, easily audible without ear muffs on.

Well, there's the evidence needed for this project! I been in contact with another coiler who has been using this interrupter with a DRSSTC, so it works with them too!

1263144931 95 FT78225 Img 1218
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Mads Barnkob, Thu Oct 22 2009, 09:30PM

This is something I wish I had the time and materials to do right now! So I could try pure notes on my SSTC II.

We have yet to see it work, but as this is the first? published midi modulator, at least in this hobby, it will be a instant classic and worldwide standard :)

Good work, looking forward to more on this
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Wolfram, Thu Oct 22 2009, 11:52PM

Excellent work. I really like the way the microcontrollers are cascaded for more notes, very clever.

I have also used common optoisolators for MIDI, but this has given me a lot of trouble. It seemed to be working well together with some MIDI controllers, but would not work, or only work intermittently with others. The recommended PC900/6N138 are darlington optocouplers, so they have a much higher current transfer ratio than common optocouplers. Common optocouplers will work fine together with stronger midi outputs, but with weaker ones it will work intermittently or not at all. I tried adding an external transistor to the optocoupler, to make it into a darlington, and while this improved the situation, it still only worked with about half of the devices I tested it with.


Anders M.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
plazmatron, Fri Oct 23 2009, 12:40AM

Nice!
I built a similar interrupter based around the ATMega-328, which is coupled to my DRSSTC`s via Toslink fibre optic cable.

Mine is monophonic, because of duty cycle concerns, but the sound is awesome! Very clear and crisp, and is amazing on two or more coils.

Since you have open sourced this, I recommend that anyone wanting to play music on their DRSSTC`s ought to get into µC MIDI control. There are no excuses now and nothing beats it smile

Les




Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
GeordieBoy, Fri Oct 23 2009, 09:14AM

Neat! How did you convert the MIDI note numbers to pitches? Do you use a look-up table in your software?

-Richie,
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
uzzors2k, Fri Oct 23 2009, 01:50PM

Thanks. smile Do you guys want a video of the prototype playing something, or should I save it until I get some sparks?

Anders M. wrote ...

I have also used common optoisolators for MIDI, but this has given me a lot of trouble. It seemed to be working well together with some MIDI controllers, but would not work, or only work intermittently with others. The recommended PC900/6N138 are darlington optocouplers, so they have a much higher current transfer ratio than common optocouplers.

Good to know, I've change the specified type to PC900/6N138 instead. I just used whatever I had in my junkbox.

GeordieBoy wrote ...

Neat! How did you convert the MIDI note numbers to pitches? Do you use a look-up table in your software?

Indeed, I made a command line program so I didn't have to do 176 calculations every time something in the configuration changed. Here's what the note generation code looks like for one compare module:

// List of Timer 1 values required to generate various frequencies, encompasses full 88 notes.

static const uint16_t compare_off[88] PROGMEM = {51818, 48910, 46165, 43574, 41128, 38819, 36641, 34584, 32643, 30811, 29082, 27450, 25909, 24455, 23083, 21787, 20564, 19410, 18320, 17292, 16321, 15406, 14541, 13725, 12955, 12228, 11541, 10893, 10282, 9705, 9160, 8646, 8161, 7703, 7271, 6862, 6478, 6114, 5771, 5447, 5141, 4852, 4580, 4323, 4081, 3852, 3635, 3431, 3239, 3057, 2886, 2723, 2570, 2426, 2290, 2162, 2040, 1926, 1818, 1715, 1619, 1528, 1443, 1362, 1285, 1213, 1145, 1081, 1020, 963, 909, 857, 810, 764, 722, 681, 643, 607, 572, 540, 510, 481, 455, 429, 405, 382, 361, 341};

static const uint16_t compare_on[88] PROGMEM = {2727, 2574, 2429, 2293, 2164, 2043, 1928, 1820, 1718, 1621, 1530, 1444, 1363, 1287, 1214, 1146, 1082, 1021, 964, 910, 859, 810, 765, 722, 681, 643, 607, 573, 541, 510, 482, 455, 429, 405, 382, 361, 340, 321, 303, 286, 270, 255, 241, 227, 214, 202, 191, 180, 170, 160, 151, 143, 135, 127, 120, 113, 107, 101, 95, 90, 85, 80, 75, 71, 67, 63, 60, 56, 53, 50, 47, 45, 42, 40, 37, 35, 33, 31, 30, 28, 26, 25, 23, 22, 21, 20, 18, 17};

// Lookup Compare Match B value
void set_compB(uint8_t data)
{

compareB_playing = data;

// Check if key is in range, if not assign value.
if (data > 108)
{
compareB_off = pgm_read_word(&(compare_off[87]));
compareB_on = pgm_read_word(&(compare_on[87]));
}else if (data < 21)
{
compareB_off = pgm_read_word(&(compare_off[0]));
compareB_on = pgm_read_word(&(compare_on[0]));
// In range!
}else
{
compareB_off = pgm_read_word(&(compare_off[data - 21]));
compareB_on = pgm_read_word(&(compare_on[data - 21]));
}

// Compare Match B interrupt enable
modeB = 0;
TIMSK |= (1 << OCIE1B);

}

// Compare Match B interrupt
ISR(TIMER1_COMPB_vect)
{

PORTD ^= 0b0000100;

// add start value to current timer 1 value ensures that compare match occurrs at set number of Timer 1 increments
if (modeB)
{
OCR1B = TCNT1 + compareB_off;
modeB = 0;
}else
{
OCR1B = TCNT1 + compareB_on;
modeB = 1;
}

}
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
uzzors2k, Wed Nov 18 2009, 01:42PM

Progress is still snailing along. I made a PCB for the MIDI interrupter but ordered the wrong box size and only received one of the two 12MHz cyrstals I ordered. Still, I had enough to test the full circuit over a toslink connection, which works great with a small speaker. With a temporary 8MHz crystal on the last ATtiny2313 I couldn't get 6-note polyphony though, only 4-note. I hope this is due to the crystal speed, and not something in the code... I'll publish the PCB design and upgraded firmware once I've pinpointed the problem.

1258550221 95 FT78225 Img 1163

I later dusted off an old secondary and half-bridge from another SSTC project and fired it up using several different drivers. In the end Steve Conner's MKI PLL was the only one that worked reliably, thanks again man. wink With a 2250µF filter capacitor power draw is almost exactly 1kW and the discharge is fairly silent, no mains hum at least. Heatsinks stay cool and it appears to be able to run continuously in CW mode.

1258550221 95 FT78225 Img 1179


I figured a musical test was in order, so I hooked everything up for a trial run. Results left a lot to be desired... Low frequency notes gave decent sparks, but higher notes gave smaller streamers until I could only hear them without my earmuffs on. Eventually (within 10 seconds) the output died altogether, even when playing low notes. I turned off the coil at this point and removed the keyboard and set the coil for CW. When I turned it on again, after charging up the filter capacitor, I was blinded by an exploding bridge of IRFP450s. The toslink module was unshielded, and I hadn't disabled the IRFP450's internal diodes. Now before I go buy some expensive diodes, was this the likely cause of failure? This coil's resonant frequency is 625kHz.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
BSVi, Thu Nov 19 2009, 08:37AM

Awesome interrupter.

I tryed to play several notes at time on single SSTC using DDS. But intermodulation distortion turned sound to someting awful. That is why I abandoned idea to play polyphony on SSTC. SSTC is monophonic by its nature - its sound contains lots of harmonics.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
uzzors2k, Sat Nov 28 2009, 11:34PM

Thanks. I've tested the PCB and final source code now which all work, so it's a go for anyone looking to try this! I put the assembly in an ugly project box, and made a little teaser video. An actual Tesla coil test will have to wait until I get the high speed diodes I ordered from China.

Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Proud Mary, Sun Nov 29 2009, 04:00AM

Is there some clear reason - other than by mental habit - why linear AM would not be suitable in this application?

Which would have the lowest component count, the least power draw, to justify its existence?

Stella
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
uzzors2k, Sun Nov 29 2009, 12:37PM

I've given it some thought, but I find programming microcontrollers much easier than designing analog circuits properly. SSTCs can be AM modulated by moving the drive frequency slightly off resonance, like in Steve Conner's PLL. This works great with analog signals, so you can just plug an mp3 player directly into the coil. In my opinion the sound quality isn't great until you have a coil running in the many MHz range though. Direct AM of the power to the SSTC is also a possibilty, and Reaching did it for a 4MHz class E SSTC. Link2 The sound quality is crystal clear, but the streamers aren't all too large. If I wanted to directly AM modulate my coil using class A, I'd need a 320V amplifier capable of dissipating 3kW, to get the 1kW output my coil has.

Much off the reason I settled on a MIDI controller is so I could get regular sized streamers AND crystal clear music. Also MIDI players like mine have the benefit of being drop in replacements for an interrupter, which all SSTC and DRSSTCs have, so no changes are needed to be made to the Tesla coil itself. Just plug in the MIDI interrupter instead of the 555 and you've got music!
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Steve Conner, Sun Nov 29 2009, 04:59PM

Yes, the gist of it is that DRSSTCs can't be linear AM modulated. The best you can do is trigger a train of bursts at the frequency of the note you want to play.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Goodchild, Wed Dec 23 2009, 01:30AM

Is your desighn PW limited for DRSSTCs?
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Mads Barnkob, Wed Dec 23 2009, 06:13AM

Goodchild wrote ...

Is your desighn PW limited for DRSSTCs?

if you run his program for making the tones, you can set a maximum duty cycle.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Goodchild, Wed Dec 23 2009, 04:42PM

ok thanks I may just use this with my new DRSSTC.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
uzzors2k, Wed Dec 23 2009, 05:21PM

Aye. You might want to use a fixed on-time though. You'll have to experiment and see just how hot the IGBTs get.
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
uzzors2k, Sun Jan 10 2010, 05:41PM

Holidays are over and it's back to work! I reassembled the Tesla coil and popped some brand new MUR1560 diodes into the full-bridge this time. So far they appear to have solved the problems I had earlier, and the coil can be interrupted without exploding. I have a habit of turning off the logic supply before the main power, which caused some headaches today. So despite constantly forgetting to power the coil down in the right order, thus loosing at least four full-bridges, I managed to get it functioning again.

At first I tried the MIDI interrupter carefully, in non-inverted mode (like a DRSSTC, so ON-times are short) this resulted in absolutely no output from the coil. I suspect the PLL isn't able to lock quickly enough, so that's one problem which needs fixing. So when that failed I switched the interrupter into inverted mode, so it runs CW until interrupted. And it worked!!! I've made a few videos flaunting my coil already.

Super Mario Bros. 2
Maple Leaf Rag

The video doesn't do the sound quality justice with all the background noise, in person the sound is quite clear, easily audible without ear muffs on.

Well, there's the evidence needed for this project! I been in contact with another coiler who has been using this interrupter with a DRSSTC, so it works with them too!

1263144931 95 FT78225 Img 1218
Re: Polyphonic Tesla Coil MIDI Interrupter (and SSTC side project)
Mads Barnkob, Thu Oct 14 2010, 01:14PM

Bummer :(

The PCB I made was after the schematics you have here in this thread, but then I noticed you have an updated one on your website where there are some changes to the pin layout of the uCs.