Category Archives: Ham Radio & Electronics

TDCS Controller Step 5 – Making Electrodes

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.

Stage one of my electrodes for TDCS. The copper coils are 14ga copper from wiring leftover after building a barn out back several years ago.

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

The electrode sponges fit inside the pouches. Red for Anode, black/dark blue for cathode. I was somewhat limited by the range of fabrics in Liz’s scrap pile. Dampened with saline, the sponge/pouch combination lets plenty of current flow.
I sewed velcro onto a few bands of elastic (no comments on my sewing skills… I’m an engineer, not a seamstress). Two for the head, one for the arm.

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.

TDCS Controller Step 4 – Redesign

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 LM334MX is set for either 1mA or 2mA depending on the position of switch S2

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.

R3 is in series with the load resistance (i.e. my head ultimately). The current flows out of the regulator (U1), out through the load resistance, and through R3 to ground. C1 is there to dampen transients at power-up. The LM358 amplifies the voltage by a factor of 10.1 thanks to the feedback resistors (R9 and R10) to produce an output of 1.01V/ma on pin1. R14 and C2 form an additional dampener against transients.

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.

The 5V reference source is derived from a 4.8V zener diode (D3) and a 2.2K resistor (R8)

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.

Pin 5 of U4B is tied to the current sense amplifier. A 1V signal on pin five corresponds to a 1mA current through the load. If the current exceeds 5mA, the output of U4B goes high and triggers the SCR (U2), blowing the fuse and cutting power.

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.

U4A lights up the red half of LED2 when the current sense voltage drops below 0.84V to indicate a continuity problem or a low battery. U3B lights up LED1 when the current sense voltage is above 1.4V to indicate the 2mA output is active.

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.

D1 and D2 prevent current from backflowing if both a battery and power supply happen to be connected. F1 is a 100mA resetable fuse.

So, putting it all together, here’s the end result:

Copyright by Peter Johnson, February 2019 and released under the terms of the Gnu General Public License (GPL). This design comes with no warranty whatsoever, express or implied, for any purpose. It is provided for educational purposes only. Send recommended improvements or polite inquiries to

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.

The almost completed board. There are a few resistors, capacitors, and diodes that are still on order, and I need to connect the switches. The two vias in the center of the board are reserved for connecting an optional panel-mount voltmeter to display the current.

TDCS Controller Step 3 – Testing the Design

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.

After the boards are cut out, I solder on the components. Surface mounts can be hard to deal with if you haven’t done them before. First, solder flux is your friend. It can help stick the components in place, and makes the solder flow well. Second, a dental pick in your non-dominant hand can help pin the part against the board while you tack it down with the soldering iron. Get some solder on the tip of the iron and use that. Drag the solder across the fluxed pins and the solder should flow pretty evenly. If you get too much and short out pins, solder wick is an easy way to clean it up. I’d also keep some chip-quick around for removing components that didn’t go on like you thought they would or that let the smoke genie out.

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.

The yellow trace is the indicated current flow. It turns on like it should, but then shuts off a very short while later. The actual current flow continues. The power supply line and sensing lines are clean and within specs, so I’m at a loss as to what causes this.

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:

  1. 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.
  2. Add filter capacitors to the crowbar signal to suppress transients that erroneously trigger a shutdown.
  3. 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.

TDCS Controller Step 2 – Building The Circuit Board

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:

  1. A circuit board layout
  2. Dry-film photo resist
  3. Double-sided copper-clad circuit board(s)
  4. 300-400 grit sandpaper
  5. Printable transparencies (ink-jet printable in my case)
  6. A good quality printer
  7. A laminator
  8. A laminator pouch that has been through the laminator
  9. Latex gloves
  10. Washing soda (sodium carbonate)
  11. Copper Etchant (I use ferric chloride)
  12. UV curable solder mask
  13. A UV light source (a black-light works well)
  14. A rotary tool (Dremel) and carbide bits
  15. A hacksaw to cut out the finished board
  16. 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.

Printed mask sheet. The top right is the top of the board, bottom left the bottom, and the right side are the respective solder mask patterns for the top and bottom.

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.

Stick tape to each side of the film and pull it apart to start separating the protective plastic from the film. Usually the film on the inside of the curl will pull away. Only pull the plastic off one side of the film at this point.

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.

Tape one edge of the film (film side down) to a piece of card-stock. The card-stock helps pull the board through the laminator, taping the film to the paper makes it easy to put a little tension on the film to avoid bubbles and creases.
Run the cardstock-board-film combo through a laminator set for it’s hottest setting. Put gentle tension on the film as the board is fed through the laminator to prevent bubbles and creases in the film. I usually run it through the laminator 3-4 times in a row. To laminate film on the bottom of the board, flip the board over and repeat.
When the board comes out of the laminator, it’ll be stuck to the paper. Use a utility knife to cut around the edges of the board to release it.

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.

I tape the mask to a section of scrap PCB to keep the separation right and hold them aligned with each other. The photoresist under the black areas will wash away when developed, leaving exposed copper which will be etched away by the etchant solution.
I sandwich the mask and board between two thin sheets of glass I took out of a thrift-store picture frame to keep the mask tight against the board. The rubber bands keep the whole thing together so I can flip it over and expose the back side without changing the alignment.

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 expose the board, I put it about 4-5 inches below a 13W LED black light I bought at Lowes. 5 minutes exposure seems to be just about right with this geometry. After five minutes, I flip the board over and do it again on the back side.
After the exposure is done, you should be able to see the pattern in the photo resist. It may seem a little blurry, but seems to sharpen up when developed.

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.

To develop the photoresist, drop the board into a solution of washing soda and luke-warm water. Agitate it gently, and gently rub it with a soft-bristled toothbrush to work the softened mask loose. Be very gentle or you may damage the finer features.

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.

The developed board should have sharp lines and good contrast. If anything isn’t right, start over. Once you start etching, it’s really hard to fix things that aren’t right.

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.

The exposed copper with start to turn pink, and the etchant will begin darkening as copper is dissolved into it. Swish it back and forth gently. How long it takes to etch will depend on the strength and temperature of the etchant. When you think it’s done, rinse the board with water and look closely to be certain. If there is any copper that still needs to be etched away, put it back in the solution for a while longer.
At this point the etching is done, and the board has been rinsed off. There are two real options for removing the film. The quickest is a brief soak in acetone. The other is to throw it back in the washing soda solution overnight.

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.

The same solution used to develop the photoresist can be sued to take it off if you are patient. If not, hot water speeds up the process, or a quick dip in acetone will do the job.

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).

Make sure the board is really clean and dry, set the board on a piece of card-stock or other disposable surface, then put a small blob of the solder-mask compound on the board. Put a piece of plastic trimmed to a little larger than the board over the paint (I use a laminator pouch that has been through the laminator because old-fashioned transparencies are hard to come by these days).
Use a flat surface (in this case a nylon kitchen scraper) to spread the compound out thinly and evenly. My biggest problems with producing good looking boards come from the paint being too thick and the UV light not making it all the way to the bottom and curing that portion of it. Make sure there aren’t any bubbles, and scrape extra paint out the edges and onto the paper.

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.

Place the board under the black light (with it turned off), align the mask on the board, and place one of the pieces of glass on it to hold it in place. About 5 minutes seems to be about right using the same setup as I did for exposing the dry film photoresist.

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).

You can see the blistered solder mask on the corner of the board on the left. I’m pretty sure it’s a matter of the paint being too thick, or the curing time being too short combined with the fact I used acetone to help wipe off the pads..

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.

After the boards are cut out, I solder on the components. Surface mounts can be hard to deal with if you haven’t done them before. First, solder flux is your friend. It can help stick the components in place, and makes the solder flow well. Second, a dental pick in your non-dominant hand can help pin the part against the board while you tack it down with the soldering iron. Get some solder on the tip of the iron and use that. Drag the solder across the fluxed pins and the solder should flow pretty evenly. If you get too much and short out pins, solder wick is an easy way to clean it up. I’d also keep some chip-quick around for removing components that didn’t go on like you thought they would or that let the smoke genie out.

There you have it. That’s how I build prototype circuit boards. Now it’s time to test it.

TDCS Controller Step 1 – Design

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.

Pin 4 on the LM334 is the input power, and can be from 1 to 40V. The feedback resistance between the four output pins (R1 and R2) sets the output current.

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 LED is actually half of a two-color (red/green) led. When power is applied, the green LED will light up.

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 0.1% Resistor on R3, and a gain of 100 built into the TSC888, the output on pin 1 comes out to a round 1V/mA so a simple panel-mount voltmeter can be used to monitor the current.

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.

U5 and R8 combine to form a constant 5V reference. If the voltage on pin 5 of IC1 exceeds this reference, the output of pin 7 goes to the positive supply rail. The other op-amp in IC1 is used as a threshold detector to turn on the red LED of U3 if the output current is below approximately 0.8mA. The voltage divider of R7 and R6 set the threshold voltage based on the 5V reference.

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.

U2 is a 100mA resetable fuse which is tripped by U4 if the output current of the device goes above the safety threshold. This is a redundant safety feature to ensure that a short in IC2 (the current regulator) won’t expose anyone to dangerous currents.

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:

The completed TDCS controller circuit with a 1mA/2mA current regulated source, a 1V/mA monitoring circuit, power and fault-indicator LEDs, and a safety crowbar to shut things down if something goes wrong. VDD is for powering a panel-mount digital volt meter hooked to TP1 to display the output current (optional), but I didn’t include that in the schematic.

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.

Top board layout. The bottom board is almost all ground-plane with a few jumpers and pads for vias and through-hole components.

Now, on to making the board.

Another Project – TDCS Controller

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.