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 Peter@diligent5.org.

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.



