Skip to content

Repository files navigation

This project is an open-source transcranial-magnetic-stimulator, including some code for VERY SIMPLE controls for pulse-firing system and hopefully charge-controller (coming later), but mainly it's for documentation of the system design, schematics, pictures of circuits, pictures of coil-designs and more.

To be clear, this is NOT a legitimate medical device and should not be seen as an alternative to going to get legitimate TMS treatment. Any treatment with this janky, built-in-my-garage version of TMS isn't gauranteed to work, or do anything as I have no way to verify that it works such as an MRI. This is a dangerous device involving energy levels more than high enough to stop your heart, kill you and do alot of damage.

Update: I'm building a charge-control circuit!!! Starting the the same design seen in the Kicad schematics; the charge control circuit is a safety critical circuit which controls charging the main pulse capacitors. This circuit is an improved version of past control circuits using arduino and an ADC which wasn't able to sample (divided) capacitor voltage consistently. To be more fail-safe than the last version, this version uses a DAC outputting an analog voltage to a comparator which compares the DAC output voltage to the (voltage-divided) capacitor voltage. This way the arduino/teensy microcontroller doesn't need to sample quickly or at consistent times, and if the microcontroller glitches or dies, I'm going to have a weak pull-down on the DAC to be sure the DAC voltage falls to 0 making the charge circuit fail safely. This circuit has been tested though my voltage-divider is picking up quite a bit of noise.... which is everywhere since this is basically a small EMP generator. So I'll try some shielded cable and filtering to reduce this noise while maintaining good measurements. I've confirmed it triggers the comparator output as expected but have not connected the comparator's output to drive a switch to disconnect the charging supply. I'm also trying some ADCs since I'd like the main controller (a teensy 4.1) to be able to know the capacitor's voltage without having to worry about having the teensy doing anything super safety critical.

Components Common to each Pulse Generator: TMS-Coil: I primarily use two types of coils; single coils, and figure-of-eight coils. Both single and fig-8 coils can be either single-layer or multi-layer flat coils with no core (use air as core). I basically just used the same general architecture in these designs from various research papers and what little information released by tms-coil manufacturers. As I've transistioned to higher-speed pulse rates and higher pulse energies I've found it necessary to have active cooling for the coils and have tried a few different methods. One of my favorite designs is similar to the CloudTMS coil using hollow copper tube (sold for air-conditioning systems), insulating the tube with some kind of heat-shrink(I've found PTFE heat-shrink works quite well because it's wall is thin even after shrinking, withstands high-temp, and is doesn't allow coil to move as much compared to other thicker heat-shrink, but requires pretty high temp to fully shrink). For the coils I've made, I buy 4mm OD, 3mm ID copper tube in 5m sections, and buy 4.5mm 4:1 PTFE heat-shrink in bulk. To get any kind of long section of heat-shrink onto such a long tube takes creativity, patience and compressed air to create an air-cushion between the copper tube and heat-shrink to easily push it on. Then I'll use a janky, custom coil-winding jig to wind a coil in either single layer or multi-layer(Note multi-layer is just winding randomly around a bobbin, not stacking multiple single layers... I'm not that fancy yet, but they seem to work well). You'll want to put something close to the ID of the copper tube to keep it from collapsing during the first few windings, and pull it out after winding's done. I find that weedwacker cable works well for this. Hold coils together with some tape while you pot them in some epoxy. Potting these coils in epoxy helps greatly with general stability of coil and noise, it keeps the coils in place when they want to fight eachother. I've tried holding coils together with hot-glue which does work, but those coils are very loud which doesn't inspire much confidence increasing power.. These coils with hollow copper tube are meant to have cooland pumped through them to cool them. For a long time, I used mineral-oil as a coolant which is pretty thin for oil, but much thicker than water. To achieve proper cooling (maintain ~40C) I needed about 150-200psi to push enough through the small ID of the coil. When running higher energy levels, I added a water-chiller and heat-exchanger to further cool the oil before going to the coil. Recently I found that diaphram pumps are electrically insulated (to some extent) through the diaphram from the fluid they're pumping, so I found that using a diaphram pump and distilled water as coolant is much more effective and simple. Though there is a risk of the water/coolant being at high-voltage.

Charging Circuit: I've used the same general janky, open-loop charging circuit for a while; this consists of mains power going into a variable-transformer which goes to a microwave-oven-transformer to step it up to higher voltage, which is then rectified with a full-bridge rectum-fryer. This rectified DC then goes to the large discharhe capacitor which is discharged through the coil by a high-side switch (either latching-SCR or non-latching-IGBT).

Cooling Microwave-Oven-Transformers: When running this system at higher-frequencies and higher energy levels (ie. 10hz pulses at ~2000V for a 100uF cap), I've found the system will draw about 14amps AC at 120v (going into the variable-transformer) At this current, the MOT(Microwave-Oven-Transformer) will get pretty hot, I don't know the max temp they can run at (core or winding), so I prefer to keep the primary-coil below 70c. To do this at high currents, I've built a low-pressure mineral-oil cooling system which circulated oil in a custom-made enclosure (MOT is insulated from walls of enclosure) through a heat-exchanger getting cooled by the same water-chiller. This has kept the MOT at a reasonable ~50c running at the energy levels mentioned above.

IGBT switches: My current switch of choice is the Infineon/Eupec FZ1200R33KF2, why? because they're cheap and they can handle alot of power. I've found them on ebay ranging from $100 to $400 each, and I've put 8kA pulse through just one. Just make sure you have enough snubber capacitors/circuitry to keep the voltage accross them less than 3.3kV. With this IGBT, I've used this gate driver from Power Integrations; 2SC0535T2G0-33 (NOTE: Look up gate resistors used with this driver). There's an important balance of setting gate-resistances/current which correlate to turn-off voltage spikes accross the IGBT, with heat generated in the IGBT. By increasing gate turn-off resistance to cause slower turn off, you decrease the turn-off spike accross the IGBT and increase heat in the IGBT, or the other way around. I'm still getting a feel for what's a reasonable balance between the two.... Luckily I haven't fried any of these FZ1200R33KF2 switches yet... since I'd imagine that if it fails short, it would be an epic discharge of the two 1050uF caps and probs explode...

Design #1; SCR type Pulse-Generator. This is the first design of pulse generator I built and it is great for handing rediculous energy levels at consistent frequencies/patterns such as the standard 5 & 10hz protocols used in early depression-treatment protocols. However I ran into limitations when I wanted to try more complex pulse patterns such as "Theta-Burst) which is a short burst of 50hz pulses, repeating at 4-5hz. The SCR (Silicon-Controlled-Rectum-Frier) or thyristor, is a switchable diode which are latching. So for the task of discharging a capacitor through a coil; they completely drain the capacitor, but because of this steady decrease of current, the flyback effect from the TMS coil isn't too bad.

Design #2; Single IGBT type Pulse-Generator. The IGBT based pulse generator allows much more control of energy through the treatment coil. And since IGBT switches aren't latching like the SCR, you can turn them on then back off in short duration pulses, only partially discharging energy storage capacitors. This allows doing pulse patterns such as "Theta-Burst" as mentioned above. However, since you're shutting off the switch as current is flowing through the TMS-coil you're going to have a great deal of flyback to deal with so as not to fry IGBTs with this potentially high reverse voltage spike (This was how I fried many IGBTs). For flyback you'll need one hell of a flyback diode accross the TMS coil, as well as snubber capacitors accross the IGBT(s) to handle the spikes caused by parasitic inductance of wires/cables/bussbars and such. You'll want to get some high-voltage differential oscilliscope probes to measure important voltages, such as voltage accross the IGBT. So that as you're testing and tuning the system, you can stay within the limits of the switch you're using. NOTE: this design used a flyback diode accross the coil, so the coil current waveform has a sharp rising edge, but a slow falling edge as the flyback current is dissipated through the coil+resistance of the wires and the diode. The single IGBT setup seemed to work well and was relatively simple compared to the two-switch flyback, but due to not recycling the flyback energy in the coil, I was limited by drawing too much current from the charging circuit.

Design #3; Two-Switch Flyback IGBT Pulse Generator. Compared to the single IGBT pulse gen, the two switch design recycles more of the pulse energy than the single IGBT. The two-switch setup also has a sharp rising and falling edge of current to the coil, which increases the di-dt which results in a stronger but shorter magnetic field. This setup seems to increase efficiency so my charging circuit current draw decreased significantly. This setup seems to be more effective at stimulating atleast muscles/nerves than the single switch IGBT running at higher peak pulse current. I believe this is because the faster edge rates cause a faster change in magnetic field which (I think) induces greater currents in muscle/tissue.

Design #4; H-Bridge Switch topology IGBT Pulse Generator (Not Built yet) This design should double the coil pulse current compared to the two-switch flyback topology, because of the ability to reverse the current flow. Though this setup feels quite complicated in terms of how to position 4 IGBT switches and needed snubber capacitors so that the added parasitic inductance doesn't decrease the energy capability of the system overall.

Measurement System When running the newer IGBT based Pulse-Generators I monitor the voltages accross each IGBT to make sure I don't exceed Vce (in fact, I try to stay below 2.5kV for my 3.3kV rated IGBTs). To measure this I use a basic oscilliscope and high-voltage differential probes. The HV Diff Probes I use are Micsig DP20003 High Voltage Differential Probe 5600V, 100MHz. I measure voltage of the main capacitor bank using a similar HV Diff Probe, but lower voltage (1300V). I also measure current through the coil, as well as current to the main capacitors. For this I use either a Current-Transformer (TEKTRONIX A621 AC Current Probe 5 Hz To 50kHz 2000A BNC plug) Or a rogowski coil I got from https://powertekuk.com. I had them make a custom rogowski coil because I had trust issues with my other current transformer, and never got reliable readings from any shunt resistor I tried... But now that I've gotten the rogowski, I've confirmed that it agrees with the TEKTRONIX A621.

Useful resources for coil placement and the 10-20 system/beam protocol; https://youtu.be/CKCvAkgdJuY?si=f4i1zZF6m_ImrpPf

TODO: 1. Build a charge-control circuit. I don't trust a uC to do this job. Going to use a comparator, compare to a DAC output from uC, so if uC hangs DAC falls to 0 and turns off charge circuit. 2. Build phase-control recitifier to replace HV charge circuit rectifier, this will also get rid of variac and be tied into charge system. Might need some fancy PID... thingy to control phase/firing angle to let more/less current through to charge caps. Or say fuck it and just bang-bang control it. 3. Process feedback signal from Gate-Drivers (fiber-optic RX) to tell if we're missing pulses. What would we do if we miss pulses? I dunno yet..... shut off another redundant switch to shut off charge circuit?

About

Open-Source Transcranial Magnetic Stimulator. High energy pulse circuitry, simple controllers, and coil design.

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages