I’ve finished the updated design for my TDCS controller, but I’m waiting for a few parts that I didn’t have on-hand and couldn’t strip off of the board that represented my first attempt. Rather than just sit around and wait, I decided to figure out how to make a decent set of electrodes without ordering stuff online.
I used a standard 3.2mm mono-jack to connect the leads, and had intended to build my own cables. However, I don’t have any wire around the house that is suitable for this use. All of it is either way to heavy a gauge, or it’s solid core and stiff. I can either wait for the parts to arrive, or I can improvise. If you know much about me, you know I’m fond of improvising so long as it isn’t unsound. I had a cable from a pair of headphones laying around, and the only difference between a mono jack and stereo headphones is an extra conductor that I can completely ignore.
Headphone wire is well enough for the cable, but breaking out pigtails requires slightly more robust stuff. Again, I didn’t have any wire laying around that was suitable, but I did have an old DC motor I scavenged years ago, and the power leads to it were just right. I clipped those off, soldered and heat-shrinked (is that a word?) them, and soldered on some alligator clips. To make the actual electrodes, I cut two pieces of 14ga solid copper wire (taken from some extra ROMEX wire I had laying around) and coiled it into about a one inch disc.
From what I’ve read, the electrodes can burn you if the current isn’t distributed over a large enough area. Standard practice is to use saline soaked sponges, so I went to the local WalMart to see what was available. All of the sponges I could find in the cleaning isles contained an antimicrobial substance (you can tell because it warns you against use in aquariums). I don’t like the idea of that kind of stuff migrating from the sponge into my head, even though that’s a mostly irrational concern. I kept looking for a sponge that didn’t have that stuff in it. The make-up isle had the answer.
Make-up sponges don’t have antimicrobial stuff on them except for some vitamin E. They are also about the right size. I bought a bag for a dollar and headed home. Using a utility knife, I sliced a pocket inside two of them and inserted the wire coils. After soaking them in salt water, I stacked the two on top of each other and connected them to my first controller design (it generates the right current, it just doesn’t show you it’s working and the safety features won’t work right). The controller reliably produced the correct current through the pads.
To make it easier to distinguish anode from cathode, and to keep the whole thing together, I made small pouches out of red and dark blue material to stick the sponge and electrodes in. While I was rummaging through my wife’s sowing kit, I also grabbed some elastic and velcro to make some bands to hold the pouches in place. Here’s the end result
Now… I just need those parts to arrive and I can test it. If all goes well, the last step will be to design or buy an enclosure. I haven’t decided yet if I’ll have a friend 3-D print one, or just buy one from the electronics hobby type stores.
An unfortunate outcome of many first attempts is the learning that goes along with failure. My initial design for a TDCS controller had some weaknesses (okay… outright failures). At first, I attempted to fix them on-board by cutting traces and soldering wires to re-route power, or by dead-bugging extra components onto it. However, you can only do so much without having to shift gears and start over. This post is all about the redesign.
The driving force behind the re-design was my inability to make the TSC888 current sensing amplifier work like I wanted. However, I can accomplish the same thing with a simple op-amp. In fact, the LM358 that I used as a voltage comparator can work pretty well, and I have a few extras of those around. The trick with using this kind of set-up is to either reference the current sense voltage to ground, or to build up a differential amplifier. The simplest method I could think of was to put the current sense resistor in the circuit after the load and make it the last component the current flows through on its way towards ground.
The basic current regulator is unchanged. It worked so well, I can’t come up with a reason to change it. With R2 at 68ohms, the regulator (U1) is hard-wired to produce 1mA. When S2 connects iwth R1, the effective feedback resistance generated by connecting R1 and R2 in parallel is 34ohms and results in a 2mA current.
The nature of the LM358 calls for another change. It can have an offset voltage between inputs of several milivolts. With a 10ohm sense resistor like I had in the previous design, each milivolt of offset represents a 10% error at 1mA of current. However, increasing the sense resistor to 100ohms increases the sense voltage by a factor of 10, so a 1mV offset would only represent a 1% error. That’s good enough for me. Adding an extra 100ohms of resistance into the circuit shouldn’t really be an issue for my application.
With a 100ohm sense resistor (R3), I need a gain of 10 to produce 1V output per miliamp. Configuring an LM358 (U3A) for a gain very near 10 with a 91K (R10) and 10K (R9) resistors will replace the TSC888, and do so in a package that is easier to solder. I also added a 1uf capacitor (C1) to the output lead to absorb any transients that might inadvertently trigger the crowbar. I also added a 2.2K output resistor (R14) feeding another 1uf capacitor (C2). The resistor capacitor combination gives a 2.2ms time constant, so it will take about 10ms (5 RC time-constants) to react to changes in the output. This will help to further damp out any transients, but do so quick enough that a failure that result in a relatively high current won’t injure anyone.
In order to determine if the output current is above 5mA, I can use an op-amp to compare the output of U3A with a 5V reference. However, that means I need a stable reference voltage. Since the supply voltage can vary from about 9V to 24V, I can’t use it directly. I could use a regulator like an LM7805, but there will be very little current drawn from that source so that would be overkill. Instead, I used a simple 2.2K resistor (R8) and 4.8V zener diode (D3) to derive the reference. The 4.8V zener blocks current until the voltage across it reaches the zener voltage (4.8V), at which point it lets current flow. R8 limits the current that can flow through the diode so it doesn’t melt once it starts conducting. I originally wanted a 5V reference, but the 4.8V zener was substantially cheaper than the 5V option and was close enough to meet my needs.
As before, I used an LM358MX op-amp for the voltage comparator. Each device comes with two op-amps in the package, including the one I used for the current sense amplifier. Ultimately, I need just one more amplifier to sense an over-current condition and trigger the crowbar, but I would also like some status indicators. Since the LM358MX is relatively inexpensive (and I have several extra available) I decided to add another one to the circuit.
The crowbar driver (U4B) is very simple. The inverting input (pin 6) is tied to the 5V reference and the current sense output is tied to the non-inverting input (pin 5). When pin 5 is less than pin six, the output on pin 7 stays low (ground). However, if the output from the current sense circuit exceeds the reference voltage (approximately 4.8mA), the output on pin 7 rises to the supply voltage and triggers the SCR (U2). U2 then latches on and shunts the supply to ground. Once that happens, the fuse (F1) opens up and cuts off power to the whole circuit.
For convenience, I want two indicators: one to show when the 2mA setting has been selected, and one to show when the circuit can’t supply at least 1mA. The circuit for status indicators (LEDs) is similar to the crowbar driver, but I use a voltage divider (two resistors) off of the 5V reference to set the threshold voltage. I could have gotten rid of the indicator LEDs, and used one amplifier to run both the crow-bar and for current sensing, but they are cheap and easy to work with, so I opted to add another chip. The voltage divider on U3B set by R11 and R12 set a 1.4V reference on pin 6. If the output of the current sense circuit is above 1.4V (1.4mA output), pin 7 goes high and LED1 turns on. The divider on pin3 of U4A sets a 0.84V refrence. If the current sense voltage drops below 0.84V because the load resistance is too high (like when it’s disconnected) or because the battery has dropped too low, pin 1 goes high and turns on the red LED in LED2 (not shown). R5 and R13 limit the current through the LEDs to keep them from burning out.
The final change I made from the previous attempt was to add diodes in line with the battery and power jack. If you’re only going to ever run this thing off of one or the other power source, there isn’t a need for the diodes, but if you happen to have a 9V battery plugged in and you connect a 12V power supply, you’ll end up with current flowing from the power supply into the battery. That can result in some nasty stuff. The opposite condition can occur if the battery voltage is higher than the power supply voltage. Two cheap diodes (D1 and D2) are all it takes to prevent that possible outcome.
So, putting it all together, here’s the end result:
With the new design comes a new board layout (slightly larger, but easier to fabricate at home). The mask sheet containing the photomasks for both the photoresist and the solder mask can be downloaded here. The capacitors are Panasonic outline B, diodes are SOD-123 packaged, resistors are 0804 size, LED1 is 0804 and LED2 is a custom two-color LED footprint. The ICs are all SO8 packaged. The process I use for fabricating boards is described here if you want to try making one for yourself. The .brd and .sch files for Eagle Cad can be downloaded here.
I had to order a few extra parts with the redesign, and am waiting for them to arrive. Once they do, I’ll test the resulting circuit and post the results. Until then, if you make improvements or just decide to build your own, I’d love to hear about it. Leave me a comment below.
In previous posts, I described the process I went through to design and fabricate a circuit designed to safely apply 1mA of current to any load (including potentially a human). Up to this point, things had gone well. The TSC888 amplifier intended to measure the actual current flowing turned out to be a little small for hand-soldering, but my practiced and patient hands managed it okay. I wouldn’t recommend it to someone who is just starting out with surface mount components though.
With the board built, I plugged in a 9V wall-wart transformer, connected a 1K resistor to substitute as a human, and switched it on. The LED blinked, then turned off. A little probing revealed that the fuse had been tripped. connecting my oscilloscope to a few test points and cycling the power switch revealed that the crowbar was working beautifully except for the fact that it was tripping due to power on transients. In an effort to continue evaluating the rest of the circuit, I added 1uf capacitors to the output of the TSC888 and to the input pin on the SCR. They are the blue cans visible in the picture below.
With the capacitors in place, the low setting seemed to work well. I measured 10mV across the 10ohm sense resistor, so the current source was working as designed. I switched the board to the 2mA setting, and so far so good. To test the ability of the regulator to handle extreme cases, I shorted the output leads together, and the low-current error light turned on. Weird… With the leads shorted, the current should be the same or higher than if the leads were disconnected. After a little fumbling and scratching my head, I realized what I had done wrong.
Consistent with most of the application notes and examples in the datasheet, I tied the power supply pin of the TSC888 to the output of the current regulator. This works fine when the load resistance (your body resistance) is relatively high, but when the resistance is low, the output voltage from the regulator drops very low to keep the current constant, and the TSC888 starts to behave erratically. It quits working all together if the connection is shorted because there is no power to drive its amplifiers, and that’s exactly when I want it to work the most. I had to pull off the chip, cut a trace, and tie the power supply pin (pin 5) to the input supply voltage (Vcc). A perfect example of why chip-quick is helpful… I know of no other way to reliably remove a surface mount component without destroying it (and often the board traces) in the process.
The output regulator worked perfectly everywhere from short-circuit to 10K ohms. If I didn’t care about monitoring or safety features, I’d be good to go. However, as I turned up the resistance, there came a point where the output of the TSC888 would drop out. Current would still be flowing, but the indication output would be 0V. I again connected my scope and dug in. Apparently the TSC888 is cutting of after a brief period. It’s unexplainable behavior. It could be because I damaged the IC by getting it too hot while soldering-removing-resoldering it, but if that’s the case, I should probably find something less sensitive. Otherwise, there is some “feature” I didn’t account for, and that part isn’t suited for my application in the first place.
So. To summarize… After all that work, I have to go back and redesign. The core building blocks all work, but there are definitely things to change:
Add a diode in line with the battery terminal and power jack to prevent current backflow if someone connects external power while a battery is installed.
Add filter capacitors to the crowbar signal to suppress transients that erroneously trigger a shutdown.
Move the 10ohm current sense resistor to the load low-side and build my own op-amp detector to sense current flow instead of the TSC888. If I use another LM358, I can use the remaining op-amp to drive an indicator for whether 1mA or 2mA is flowing.
More to follow. I’ll redesign the circuit, build another board, and come back when I have something to report.
In the previous post, I described a circuit design for a TDCS controller I’m developing. Because I’m working almost exclusively with surface mount components, I can’t really breadboard the circuit. The best option I have is to build a circuit board and use that for testing. Conceptually, I could send the board out to a fab shop and have them produce one. However, doing a 1-off build, especially when the design hasn’t been proven, is expensive, risky, and takes a while. Because I’m impatient and like to do things myself, I make my own. In this post, I’ll describe the process I use for making my own boards.
If you happen to be interested in trying this yourself, you’ll need a few things:
A circuit board layout
Dry-film photo resist
Double-sided copper-clad circuit board(s)
300-400 grit sandpaper
Printable transparencies (ink-jet printable in my case)
A good quality printer
A laminator pouch that has been through the laminator
Washing soda (sodium carbonate)
Copper Etchant (I use ferric chloride)
UV curable solder mask
A UV light source (a black-light works well)
A rotary tool (Dremel) and carbide bits
A hacksaw to cut out the finished board
Soldering Iron and solder
I make my boards by laminating bare copper clad board with dry film photoresist. I then print the pattern negative onto an inkjet printable transparency to use as a photomask while exposing the photoresist. To make the mask, I use Eagle CAD to build the board layout as part of the circuit design. However, I don’t like the way Eagle exports the graphics. I turn off all the layers but pads, vias, and either top or bottom layers and export the result as a PNG at 1200 dpi. However, the exported graphic isn’t quite ready for exposing a board. First, it isn’t black and white. In order for the photomask to work right, it needs to be either transparent (white) or black. Second, with the latest version of Eagle the signal names are printed on the traces and need to go away. Finally, the drill-holes are almost filled, and it’s much easier to hand-drill if the etched copper acts as a sort of pilot hole to guide the drill.
Using Gimp and a round brush I erase (paint over in black) anything that blocks the drill holes. Then I use the threshold tool to turn it to black and white. Once that is done, I mirror-image the bottom layer and add any graphics (like my logo) and text I want or have room for. In the end, anything black in the image will be areas where the copper is etched away.
To build the mask for curing the solder mask, I turn off all the layers in eagle except either the tStop or bStop layers, change the fill pattern to a solid color, and export it using the same settings as the board layout. Using Gimp, I use the threshold tool to make it black and white, then invert it so that the pad areas are black (black areas won’t cure and can be wiped off when the mask is applied).
Printable transparencies are kind of expensive, so I try to cram as much onto each one as I can. To do this, I use Scribus to lay out a full page that includes all the masks I need. A calculator and the properties dialog box are handy to make sure the relative geometries of tiled masks are the same. Finally, I use Scribus to export the result as a PDF for printing. Generally, I’ll print out a sheet on copy paper and make sure things line up, and that device footprints match the components I have on-hand. Make sure you don’t have “shrink to fit” selected on the printing options, and when you print the actual mask, set the print quality to maximum and resolution to at least 600dpi.
To laminate the dry-film photoresist onto the copper-clad board, I start by using 320-grit sandpaper to sand off oxidation and contamination from the board. I’ve tried using brillo pads and cleanser, but have had issues with the film not adhering strong enough and pulling loose at inopportune times. Once the copper has been sanded bright, I clean it off with acetone to make sure I didn’t leave any oils on it. I also wear cheap latex gloves from Harbor Freight any time I handle the board to make sure I don’t get skin oils on it.
Once the board is clean, I cut a piece of film about 1″ wider and longer than the board I want to laminate. I also cut a piece of card stock about 2″ longer and wider than the board. The dry-film photoresist is protected by a thin sheet of plastic on both the top and bottom, and one of these protective sheets needs to be removed in order for the film to work. To separate it, I sandwich the corner edge of the film between two pieces of scotch tape (sticky-side to sticky-side) and peel the tape apart. One side of the protective film will peel away (usually the inner side based on the way it wants to curve). If it doesn’t, try again, maybe on a different corner.
I then tape the top-edge of the film face-down (protective layer up) on the card stock. I align the board underneath the film and feed the film into a hot laminator taped-end first. The laminator will grab the paper and begin pulling it through. Gently lift up on the film to keep gentle tension on it and avoid bubbles or wrinkles as it feeds into the laminator. Once it’s been through, I usually run it through two or three more times just to make sure it’s good and stuck. At this point, the film around the edge of the board is laminated to the cardstock, so I cut around the board with a utility knife to get the board free. Then, I turn the board over and repeat the process for the bottom.
To align the top and bottom masks I cut them out, leaving about a 1/2″ margin around the pattern, and use a piece of left-over circuit board to act as a spacer between them. I tape one of the masks to the piece of board, then flip it over and tape the other mask down so that it’s aligned. It isn’t exact, but it’s about as good a way as I’ve found for consistency. When I’m ready to expose the board being etched, I slide it between the masks, and sandwich it between two pieces of glass that I took out of a thrift-store picture frame. Rubber bands, binder clips, or clothespins work pretty well to keep it all together (you have to flip it over without messing with the alignment, so it’s important to get at least some tension on it).
I’ve seen lots of folks on the web double-layering their masks to get stronger contrast, but in my experience this is totally unnecessary, and can make it really hard to work with small features. It’s almost impossible to get them exactly aligned, and variances in the printer can make it absolutely impossible. Using a single layer mask I’ve reliably made boards with traces down to about 10mils (1/100th of an inch) that turned out crisp. However, I do prefer to keep all the clearances and trace widths 15 mils or larger just to make it easier on myself.
The photoresist is sensitive to UV light (and to a lesser degree it’s sensitive to the blue-end of visible). Some people have had success using fluorescent lights a few inches above the board, but that didn’t work particularly well for me. Others use sunlight, but I like to be able to work when it’s dark or cloudy outside, and the UV from the sun can vary widely based on time of day and cloud conditions. My solution was a 13W black-light LED bulb I bought at Lowes or Home Depot. I rigged up a fixture that holds it about 4 inches above the board. In this configuration, a 5 minute exposure is about right. Your mileage may vary, and you’ll likely have to experiment with different exposure times to get consistent results. Take good notes and it won’t take long to make beautiful boards.
To develop the photoresist, carefully peel off the protective plastic. Use tape on the corner and lift up if you can’t get it with your fingers. Be very careful and gentle, pulling the plastic outward and upward to avoid tearing the film. This is one point where you find out if your board was totally clean and if the laminator was hot enough. If the photoresist starts to peel off, clean it off with acetone or a long bath in hot water and washing soda and start over. Assuming the plastic comes off cleanly, drop the board in some luke-warm water with washing soda* dissolved in it. It isn’t critical how much. I usually use about a teaspoon or two per cup of water. If the water is too hot, you may end up washing away both the developed and undeveloped portions and have to start over
*you can find washing soda in the laundry isle of most grocery stores, or you can make your own by heating baking soda in the oven at 350F for half an hour or so.
Gently agitate the board, and lightly rub it with a paintbrush or soft toothbrush (I used cheap acid brushes from the plubming section at Harbor Freight). The unexposed areas will soften and gradually wash away. Keep going until all the copper you want to etch away is completely exposed. You can patch up areas that are accidentally exposed by drawing over them with a sharpie after the board has dried off and before etching, but I prefer to just re-do the exposure since it turns out much neater that way. When all the copper you want etched away is exposed, rinse the board in cold water to stop the developer from eating away the film you want to keep. Let the board dry before you try to re-touch any copper that got accidentally exposed.
At this point, the board is ready to etch. At the moment, I’m using Ferric Chloride etchant, but you can find tutorials on the web for making your own etchant from hydrogen peroxide and hydrochloric acid (muriatic acid for cleaning swimming pools) you can buy at WalMart. Pour some etchant into a non-reactive container and swish the board around. The board will etch faster if the etchant is warm. Also be careful with FeCl… it indelibly stains almost everything it touches, especially clothes, skin and counter tops. Definitely use gloves, and lay down some paper towels or cardboard to protect your work surface. Check the board every few seconds. Quit when all the exposed copper has been eaten away and rinse the board with plenty of warm water. Don’t dispose of this stuff down the drain, the copper in it will kill aquatic life. I’m currently looking for a good chemist to show me how to precipitate the copper out of the solution so I can neutralize the remainder and flush it down the drain. Until then, I pour the etchant back in its original container and keep it.
Depending on how impatient you are, and what you have available to you, a short soak in acetone will quickly loosen up the photoresist. I don’t really like working with harsh organic solvents like acetone, so I usually just drop the board into a solution of hot water and washing soda and leave it overnight.
If you are working only with through-hole components, you can stop after the film has come off, drill the holes with a dremmel or drill press, and start building the board. However, I prefer surface mount components, and those are much easier to work with if you apply solder mask. Besides, solder mask makes the board look better (even if you screw it up a little like I tend to). The soldermask I use is a UV curable epoxy paint that is heat resistant enough that it won’t blister when you solder components to the board. It’s available online from places like ebay and Amazon. To make it work, you need a thin layer, so I squeeze a small amount of the paint onto the board, then squeegee it under a sheet of transparent plastic (I use a laminator pouch that has been through the laninator). The biggest problem I’ve had is getting the paint too thick so the UV light doesn’t penetrate far enough to cure the deeper layers. Spread it out THIN. I’ve also found that taping one edge of the transparency to a piece of cardstock will help minimize the sheet or board slipping with respect to each other (not shown in the pictures).
Once you have a thin layer of paint, expose it using the same setup as was used to expose the photoresist. Five minutes seems about right with my setup, but you’ll likely need to experiment on some scrap boards to get it right. Don’t experiment on large areas. There is no way to peel off the stuff once it’s cured. It’s tough as nails. After exposing it, lift the clear plastic and wipe the board with a clean paper towel to expose the component pads and vias. Wipe it thoroughly. I’ve used an acetone dampened paper towel before, but you run the risk of blistering incompletely cured paint. Once the pads are clean and bright copper, put the board back under the light for another ten or so minutes to make sure it’s fully cured.
After wiping off the uncured paint, I put it back under the light for 10 or so minutes to make sure it’s good and cured. Once the paint is dry, I use a dremmel with bits I got on amazon to drill out the vias and through-hole components. Finally, I cut the board out. A hack-saw works okay, and band-saw works better (I don’t have one of those yet). A dremmel with a cut-off wheel will work in a pinch (what I used here).
At this point, the board is ready to build up. Solder on the components according to the schematic and fire it up to test. Soldering surface mount components is an art form of its own, but the short version involves using plenty of flux paste, dental picks to hold things in place, and solder wick to suck up extra solder when you get too much. Be careful not to overheat the components. If things aren’t going as planed, stop and let things cool off.
There you have it. That’s how I build prototype circuit boards. Now it’s time to test it.
NOTE: This was an initial design, that evolved as I built and tested it. For the final design, complete with a description of each major component, see this post.
The fundamental building block for any TDCS controller is a current source capable of supplying between one and two milliamps of current through the human body. This can be a bit of a challenge because the resistance of the body varies with electrode placement, skin resistance (which can vary from one second to the next), body composition, and a bunch of other factors. The trick is to build a regulated current source capable of automatically adjusting the output voltage to get the desired current even with this rapid and unpredictable change in the person being exposed.
Digging through a pile of data sheets, I found a perfect solution already packaged and ready for integration. The LM334 current regulated source can be programmed to provide a constant current ranging from microamps to ten milliamps. All it takes it is a simple resistor to set the current. Two small and cheap parts are all that’s required for the basic circuit.
We’re I comfortable that nothing would ever go wrong, and didn’t want any feedback about what the thing is doing, that would be it. I could build one on a dime, and do it for just a few dollars. However, I’ve spent way too much time fixing electronics and have seen too many cases where the primary failure was a shorted out semiconductor to trust a piece of silicon to not short out. In fact, I made a good living in college taking advantage of that particular failure mode. If the regulator failed, there would be nothing to prevent a comparatively high current from flowing through my brain and doing significant damage. Clearly this thing needs a few more features.
First, I like the idea of being able to select a lower current setting. Most of the research I’ve seen uses either one or two milliamps, and I’d like to be able to use those two settings at least. I could pretty easily build in an adjustable resistor, but they are much more expensive than simple resistors, and I’ve not seen anything showing an advantage to being able to finely tune the output. Instead, I built in a switch and an extra resistor.
Rather than switch R1 and R2 in and out of the circuit completely and deal with the undefined state that happens during the switch transition, I hard wired R2 into the circuit and selected it to produce a 1mA output. When the switch is closed, R1 is added in parallel with R2, cutting the effective resistance in half, and subsequently doubling the output current to 2mA. If the regulator doesn’t fail, the current won’t ever be anything other than 1mA or 2mA. A simple flip of a switch will seamlessly change the output between only these two values.
With that aspect of the design complete, the next step is to provide an indicator that the thing is on. It’s a simple matter of adding a resistor and an LED on the power line. The maximum voltage the regulator can handle is 40V, so I selected a resistor value that would limit the current to about 15mA or less through the LED at that input voltage. Lower voltages will still light the indicator, but it just won’t be as bright. For my purposes, that’s okay.
The last three things I want in the design can be incorporated with a single basic feature. I’d like some indication when current isn’t flowing, be able to monitor exactly how much current is actually flowing, and a safety feature to shut the thing down if the regulator fails for any reason. To do any and all of these things, I need to be able to monitor exactly how much current is actually flowing through the body.
It can be a little difficult to measure low currents without disturbing the system. Initially, I believed the pile of data sheets had a ready made answer. The TSC888CILT is designed to measure the voltage across a shunt resistor and provide a gain factor to make measurements easy. Combined with a 10 ohm precision resistor, the chip puts out a 1V/mA signal.
With a signal to monitor the output current I can do several things. First, and most importantly, I want the device to shut off completely if something goes wrong and current rises above a safety threshold. If the output current exceeds 5mA something has gone wrong, and 5mA is well below the damage threshold for tissue. The simple answer for circuit protection would be to put a fuse in the line. However, mA-range fuses are hard to find, are bulky, and may not react fast enough to satisfy me. On top of that, I’m not particularly keen on replacing fuses if I happen to accidentally short something out while testing. This is where the current sense signal comes in handy.
It’s pretty easy to set up an op-amp as a voltage comparator and use it to trigger a “crowbar” if the output current exceeds a set value. The idea of a crowbar is that it’s like dropping a metal crowbar across two electrical terminals to blow a fuse or trip a circuit breaker. With the 1V/mA sensing gain and a 5mA threshold current, all that is required is a 5V reference voltage on the inverting input and the current sense signal on the non-inverting input. For the reference voltage I used a simple zener diode and resistor. I also used a 4.8V zener because it was cheaper than the 5V ones available at the time, and because 4.8 mA is still high enough that I want to shut things down if the current goes that high.
The output of the comparator then needs to drive the crowbar. I added a resetable fuse just after the power switch. This fuse is guaranteed to hold 100mA (plenty to run everything) and trigger before something like 250mA. The MCR08B Thyristor can handle 800mA, so it will happily load the fuse when triggered. The output of the voltage comparator will trigger U4, which will turn on and stay conducting until power is removed. When the SCR turns on, the resetable fuse opens up and cuts power until power is totally disconnected and the fuse cools. Theoretically, none of this part of the circuit should ever actually function, but I’m happier knowing it’s there. If the current regulator fails, the crowbar will shut things down without putting anyone in danger.
Because the chip I used for the crowbar trigger has two op-amps, I have one to spare that I can use as a fault detector. If the output current falls bellow 1mA, either the electrodes are disconnected, the connections are poor (i.e. they are too dry), the battery is low, or something else is wrong. R6 and R7 form a voltage divider off of the 4.8v reference used for the crowbar, and sets an 840mV reference for the voltage comparator. Any time the output current falls below 0.84mA, the output of the op-amp goes high and turns the red LED on.
The last parts to add are jacks for power and to connect the output leads. I used a simple mono-headphone jack for the output, and a 2.1mm barrel jack for the input power. I also added a connector and a diode to make it so I can plug in a 9V battery instead of a wall-wart transformer. When connected to a human, you should run this thing on a battery all the time to make sure you don’t encounter any ground-loop issues. At a minimum, make sure that the output of your power supply is floating with respect to earth ground (if you don’t know what that means, use a battery). There are good reasons hospitals have outlets with the neutral floating with respect to the ground pin. Finally, I added some mounting holes to the diagram so they show up on the board.
All combined, the circuit looks like this:
I laid the board out in such a way that I can reliably make my own by using 15mil clearances between traces, and 20mil minimum traces. I could have made it much smaller if I were going to farm this board out to a fab house by putting components on both sides of the board, using small vias, and finer traces. However, I like rolling my own boards, so traces are pretty thick, all the components are on the top-side, and vias are large enough I can drill them, stick a wire through it, and solder it to both sides. The final board is just under 2″ on the long side.
CAVEAT: The design described here has fatal flaws. I’ve since re-designed it, and have left this here as a way to document the process and share the realities associated with designing even relatively simple things with whoever might read it. The current design is available here.
I don’t seem to be able to function well without some kind of project. Usually I have several waiting patiently for my attention. However, at the moment all my current ones require either time, money, or energy I just can’t afford to give. I have a coding project to finish the user interface for the antenna analyzer I designed and built. But that’s at a point where the interesting work is done, I’m stuck on something that should be easy, but there’s something I’m missing. I’ve been using the project to get better at C++, and have run into issues that probably stem from my poor understanding of class objects and their use in my implementation. I’m out of ideas, frustrated at my inability to figure it out, and just can’t convince myself to re-attack it. I’ll tackle it again, but not until I’ve quit being frustrated with it.
Many of the other projects require large enough chunks of money to move to the next step that they have to sit and wait for that arbitrary future when I’ll have enough cash to make more progress. Sometimes incremental progress isn’t really viable, so things just sit and collect dust. The rest (like my writing projects) require motivation and energy I just don’t have at the moment. I don’t have a good excuse other than I’m burned out on them. They’ll sit until I change how I feel about them.
I needed a project I could work on that didn’t take much creative energy, would keep my mind active, and that I could reasonably finish with the small budget I get to spend without having to impact the household finances. Thinking about it, I decided I’d try designing and building a Transcranial Direct Current Stimulator (TDCS). I’ve been seeing reports on the technology for years, and have watched agencies from DARPA to the Air Force research lab study it and demonstrate measurable effects. I’ve been curious to try it, but the controllers are either expensive, or I question the safety features in the slip-shod designs of products coming from places like China or fly-by-night hobby shops just trying to make a quick buck.
The basic concept behind the devices is really simple. The circuit applies a voltage just large enough to induce a small current through the head. Done right, the current is way below the threshold for causing any physiological damage. It can tingle or sting some, will probably leave a metallic taste in your mouth, and might cause a perception of a brief flash of light, but that’s about it. The theory behind its effect is that the small current creates a marginal potential in the brain that modulates the much stronger natural electrical signals already there. That modulation is thought to help selectively dampen or enhance those natural signals.
TDCS has shown clinical significance treating some forms of depression, anxiety, and chronic pain. It had been shown to increase user focus and accelerate learning. There are claims all over the place that it does everything sort of washing the dinner dishes for you. Some claims are backed up by robust research, others are anecdotal or even outright crap. I’m mostly interested in trying the more researched claims associated with depression and focus.
In particular, I’m interested in seeing how effective it would be against my particular variety of mood disorder. However, I’m not interested enough to buy a good device and not willing to risk attaching electrodes to my head driven by a device built and sold by Fast Eddy in his garage. I trust myself and the things I build in my garage. Not so much things built in other people’s garages.
So, with that in mind, I’m going to design my own. Over the next few posts, I’ll share the process and details. So without further adieu, on to Part 1 – Design.
Last summer, Liz and I traveled back to the home country to spend time with our extended families. Among the things we did there was take a weekend trip camping in an offshoot of the Rocky Mountains with my brothers and their popup/tent trailers. Liz and I thought it might be fun and affordable enough for us to get one, and started looking around for a used one in our price-range. As luck would have it, not long after we returned home from vacation a friend told us they had one we could take for free.
Free is my favorite price. Unfortunately, free is almost never free. Besides, I don’t like feeling like I’m taking advantage of someone, so I offered to get an old (1947) tractor of theirs back up and running in exchange. I re-wired the electrical to switch it from 6v to 12v, added all the other stuff necessary to create a charging system including fabricating an alternator mount, replaced a rusted-through exhaust manifold, and fixed a leaking radiator. Quite a lot of work, but in the end, it was mostly labor (and kinda fun at that), so I still felt like I had come out ahead.
Fast-forward almost a year, and Liz decides we need to go on a couple of shorter trips this summer. One to the beach for a weekend, and one to somewhere up north about a day’s drive. Both require either paying for hotel rooms, KOA Kabins, or fixing the trailer and taking it with us. Being averse to spending lots of money on lodging when I have a partial solution waiting for me to deal with it, I finally got around to working on the trailer. As a side note, I have a hard deadline about 2 weeks from the time of this writing. When I committed to finishing the trailer, I expected about a day’s work in total.
I knew there was some water damage in the front cargo compartment, and the short door/step was coming apart. I figured on a half-day to repair that along with a half day to clean out the dust, dirt, and wasp-nests that had accumulated over the course of the last couple of years would do it. Because the whole thing smelled of dirt, and to get a better idea for what I was really getting into, I started by attempting to open the canopy and clean the inside. Problem… the crank that raises the roof was missing. The previous owners didn’t know where it was either. Good thing I have a pile of scrap, a grinder, and a cheap welder. Two hours and a failed prototype later and I had fabricated a reasonable replica that functioned perfectly. So much for just a half-day of work.
After opening the canopy, it became clear mice had decided to nest in there over one of the winters it was sitting and chewed several holes in the canopy and window screens. Opening the canopy further revealed stitching on one of the seams that had dry-rotted and come apart. My leather sewing kit would come in handy for that, even though hand-stitching several feet of heavy canvas didn’t sound like fun. Patching and stitching the canopy chewed up a trip to the outdoor megastore and about six hours. On to the door.
The door proved to be a much more difficult repair than I had figured. The manufacturer had opted to forgo screws and bolts in favor of aluminum pop-rivets in an effort to cut both weight and cost. I had to drill out and re-do over 50 of the little buggers just to get the door apart, not to mention the work involved in fixing the latch, straightening out the bent frame, reinforcing a couple areas, and getting it all back together. What was supposed to take an hour took more like ten.
That done, I moved on to the interior. A full day (12+hours) of scrubbing, sweeping, wiping, pressure-washing, canvas patching, and other general cleaning did wonders, but also revealed lots of additional things that needed attention. Every cabinet door and drawer was falling apart, so I pulled out some glue and my trusty brad-nailer. With their help and about three hours I had fixed the cabinetry. There was also some critical bracing that was missing in the benches/beds that a trip to the scrap wood pile in the garage and some rough carpentry took care of. The water pump in the sink was falling out of the hole because the particle board around the screws had disintegrated, but with a deadline looming, and no immediate need for that particular function, I opted to leave it for another time.
Now that all the “easy” stuff was done, it was time to tackle the water damage in the front cargo area. Originally, I thought I’d be able to get away with reinforcing the floor with some cheap OSB and replacing two panels on the sides, but after looking closer and pulling up the linoleum, it became clear I would have to completely disassemble, demolish, and re-build everything forward of where the forward bed pulled out. By the time I was done pulling off the plastic and aluminum body panels and tearing up rotten OSB and particle board, there was nothing left but the frame. The demolition alone took over three hours, another three hours to go to the hardware store and back, and another eight or so hours to re-build the cargo box and get the body panels back in place.
If you’re keeping track, that adds up to 44 hours so far, and I still have to hand-sew patches over about five or six holes in the screens, make sure the tires are road worthy, stitch up a couple holes in the upholstery, make sure the road-lights all work, and get it licensed. When it’s all said and done, I’m probably looking at something like another 8-10 hours for a grand-total of about 52 hours. Considering what I make when I’m being paid for my work, this free trailer is pretty expensive. Good thing I have more time than unallocated money (and I don’t even have much time). Assuming I can spend Monday on it, I should have it done in time for the first outing in a couple of weeks.
One bright-spot… the air conditioner works, and everywhere we have planned to stop has power at the campsites. Yes… I have fallen far from my backwoods days camping with only what you could carry, but this is Texas in July. I’ll accept the ribbing, and enjoy being able to sleep in something slightly cooler than a hot oven.