Measuring Microcurrent over a Transformer with Arduino

Thread Starter

danielantonic

Joined Sep 22, 2019
68
Hello all!

After many digital projects I have started on my first analogue circuit! I am making a Frequency Specific Microcurrent device for myself (set current between 100-600uA and the device outputs an AC waveform to specific frequencies with the set current on multiple channels).

I did some tests on one of these devices and found out the patterns/frequencies etc that are to be used (dozens from 10hz up to 10khz), and I have come up with the following system driven by an Arduino Mega-

Power supply -
A 12V wall wart provides power. A charge pump provides -18V and a DC-DC converter provides +18V, and the 12V feeds the Arduino

Interface -
3x rotary encoders
128x64 LCD screen

Microcurrent Generation -
It has 5 channels, each one controlled by a MCP4725 DAC. The DAC is used to set the microcurrent output by that channel. The DAC voltage is taken by an AD633 analogue multiplier which takes 2.5V from the DAC voltage (to make an AC signal) and multiplies it by the second input (shared on all channels) from a AD9833 function generator/LM359 OP Amp (this outputs a DC waveform 0-18V). The outputs of the AD633s (-4.5V - +4.5v) go into transformers to jump the voltage up to 60V (yet to source the appropriate transformers at this point). This voltage, given human skin resistance of 1k-100k ohms, results in the desired microcurrent.

However, skin resistance can change during the treatment, and I want a constant current.

If I use a fixed, small value shunt resistor to measure the current (such as described here: https://www.instructables.com/DIY-Current-Sensor-for-Arduino/), I can feed this back through the ADC on the Arduino, and the processor can adjust the DACs as needed. However, they only take 0-5V input so I need some way to get the absolute value of the voltage coming back from the current measurement of the AC waveform (plus keep in mind I’m measuring the current on the other side of the transformer, so the current will be greater than the 100-600uA as set by the turns ratio).

I have built/tested everything up to the transformers/current measuring. Does anyone have suggestions for the following:

Transformers to use (13:1?)
Back EMF protection considerations?
OP Amp/shunt resistor sensor – (would that be appropriate in this application? If so, a standard 741 or will any OP Amp do?)

Any other feedback is appreciated! Thank you all in advance!
 

Attachments

schmitt trigger

Joined Jul 12, 2010
899
If you plan to power the opamp from only +5v, you will require a proper rail-to-rail opamp.

Also, sampling the primary current as shown, will have a core magnetization component which will obscure the signal of interest. And which varies with frequency too.
 

Irving

Joined Jan 30, 2016
3,885
Anything mains powered connecting to human body legally needs medical grade isolated power supplies not an off-the-shelf wall wart. Of course if this is for your personal use then feel free to fry yourself :)
What is the purpose of the device? It sounds like some form of TENS device?
 

Irving

Joined Jan 30, 2016
3,885
Also measuring currents that small with a shunt will result in tiny uV levels. A simple opamp is no good here, it's input noise, offset voltage, drift, etc will just swamp the signal, plus you need to be measuring on the secondary side. You need a proper uV-level instrumentation amplifier and a very carefully laid out PCB with appropriate guard areas to get any sort of consistency & accuracy. Watch
for some ideas on this...
 
Last edited:

ronsimpson

Joined Oct 7, 2019
3,037
10hz up to 10khz
A large frequency range for a transformer. Think about a "audio" transformer. They are usually short at low frequencies.
Do you know what voltage it takes to make 600uA on dry skin? Do you need 18 volts?

Also measuring currents that small with a shunt will result in tiny uV levels.
Disagree. You can make the shunt resistor any value you want. Pick a resistor so 600uS makes 1 volt, the 10x that resistor will make 10V or 1/10 that resistance = 0.1V. Because the computer can read 2.5V think about 600uA and a resistor to make 2.5V.
Anything mains powered connecting to human body legally needs medical grade isolated power supplies
Yes Yes agree.
Transformers to use (13:1?)
Are you planning on the 18V from the op-amp being transformed down to 1 volt? How many volts do you need?

Error in schematic, you need a path to ground. See red line.
1625368854505.png
 
Last edited:

Ian0

Joined Aug 7, 2020
9,814
1. If it is isolated from the mains (to a proper medical standard) then why the transformer coupled output? Wouldn't a balanced output do just as well?
2. If your shunt is on the primary side of the transformer, you are not measuring the output current, you are measuring the sum of the output current and the transformer magnetisation current. At low frequencies the transformer magnetisation current might be the larger of the two.
3. Why measure the current and feed it back to the MCU? That feedback loop won't be easy to do digitally. Why not make a constant current output?
4. If the current is so small, can't you run it of four PP3s? That would save the cost of a medical grade isolated transformer.
5. The op-amp won't like 100nF load. If you are feeding it to an A/D, you will need a signal between 0V and 5V, not an AC signal centred on 0V.
 

Thread Starter

danielantonic

Joined Sep 22, 2019
68
Thank you all for your replies so far!

If you plan to power the opamp from only +5v, you will require a proper rail-to-rail opamp.

Also, sampling the primary current as shown, will have a core magnetization component which will obscure the signal of interest. And which varies with frequency too.
I didn't know about that - I just assumed that the conservation of energy would mean voltage goes up, current goes down.



Anything mains powered connecting to human body legally needs medical grade isolated power supplies not an off-the-shelf wall wart. Of course if this is for your personal use then feel free to fry yourself :)

What is the purpose of the device? It sounds like some form of TENS device?
I didn't know about that either - I just assumed the local circuit breaker would kick in if extra voltage came down the mains. It is similar to a TENS device, but works in uA currents. I personally thought it was simply a placebo affect, but after my wife used it she did have some releif from her pain, and worst case scenario I got to reverse engineer something :)
I tried playing the video you posted but it didnt work - do you have a direct link?

A large frequency range for a transformer. Think about a "audio" transformer. They are usually short at low frequencies.

Do you know what voltage it takes to make 600uA on dry skin? Do you need 18 volts?

Disagree. You can make the shunt resistor any value you want. Pick a resistor so 600uS makes 1 volt, the 10x that resistor will make 10V or 1/10 that resistance = 0.1V. Because the computer can read 2.5V think about 600uA and a resistor to make 2.5V.

Are you planning on the 18V from the op-amp being transformed down to 1 volt? How many volts do you need?

Error in schematic, you need a path to ground. See red line.
I was thinking audio transformer - thanks for clarifying :)
Human skin resistance goes from 1k-100k ohms (verified on many pages and I tested myself on my multimeter), so to get a microcurrent in the 100-600 uA range, voltage needs to be between 0.1V - 60V
I may have written the transformer ratio wrong - it needs to boost 4.5V up to 60V so 1:13, not 13:1...? Not sure which is primary/secondary (I did a unit on power supplies in college in 2004)
Thanks for picking that error up in the schematic - it was supposed to be grounded there and I forgot to join it :-S



1. If it is isolated from the mains (to a proper medical standard) then why the transformer coupled output? Wouldn't a balanced output do just as well?

2. If your shunt is on the primary side of the transformer, you are not measuring the output current, you are measuring the sum of the output current and the transformer magnetisation current. At low frequencies the transformer magnetisation current might be the larger of the two.

3. Why measure the current and feed it back to the MCU? That feedback loop won't be easy to do digitally. Why not make a constant current output?

4. If the current is so small, can't you run it of four PP3s? That would save the cost of a medical grade isolated transformer.

5. The op-amp won't like 100nF load. If you are feeding it to an A/D, you will need a signal between 0V and 5V, not an AC signal centred on 0V.


1. The transformer is simply to boost the voltage up and current down

2. Thanks for that I never thought of that!

3. I am trying to make it a constant current output - I set the Arduino to output a specific voltage via the DAC that corresponds to 100-600 uA over a resistance of 1k - 100k ohms. The feedback is so the Arduino can adjust the DAC output to control the current flow and keep it constant.

4. The original device that I did my tests on used a 12V 1A wall wart - I don't like using batteries if I can avoid it, but it would be safer (kind of a good thing!). Maybe use a rechargeable battery pack...?

5. Exactly - I thought of including an "absolute value" circuit using some OP Amps as I have heaps of LM747 OP Amps to use
 

DickCappels

Joined Aug 21, 2008
10,171
Anything mains powered connecting to human body legally needs medical grade isolated power supplies not an off-the-shelf wall wart. Of course if this is for your personal use then feel free to fry yourself :)
What is the purpose of the device? It sounds like some form of TENS device?
Not true, though it is required for many certifications. Isolation is a very good idea, but for something like this batteries would be even better.

Why use a transformer?

From memory TENS devices don't need much voltage and can make contact through brine-soaked pads.
 

Irving

Joined Jan 30, 2016
3,885
Disagree. You can make the shunt resistor any value you want. Pick a resistor so...
Yes, you're correct, though it's common practice to make the burden voltage <1% of the expected supply voltage. Because the TS here has control of the supply voltage he is not bound by that constraint.

However, the overall design is flawed. The TS will never get the current regulation he expects with an Arduino in the loop. Sample rate, dynamic range and MCU speed are all against him.

@Ian0 is right, use the DAC to define a voltage which represents the required current, generate a fixed compliance voltage of ~70v and use direct analog feedback to set the constant current. Then we can chose the dynamic range so 600uA is a count of 3600 from the DAC, and 100uA is 600, and so the LSB is (600-100)/(3600-600) = 0.167uA. So 600uA = 4.39v and 100uA = 0.73v from the DAC (assuming 4096 = 5v).

The TS needs a fixed shunt across 3 decades of skin resistance. So 60v across 100k is 600uA, a burden voltage of 1.2v gives Rs = 2k, and we'll assume TS can generate 62 v. Now reduce skin resistance to 1k and TS wants to select 100uA, so burden voltage now 0.2v and PD over skin is 1k * 100uA = 0.1v, system needs to control output to 0.3v.

So sense amplifier needs to amplify and then rectify AC sample (using ideal diode peak detector) to give 4.39v from 1.2vrms, a gain of 4.39/(1.2 * √2) = 2.59 (and to check, 2.59 * 0.2 * √2 = 0.73v).

The linear current regulation element, whether BJT or MOSFET will dissipate, worst case, 600uA @ 62v = <40mW so no concerns there. Only issue is how to do CC AC.
 

Irving

Joined Jan 30, 2016
3,885
Having said all of the above, TENS units don't actually generate AC as such. They generate a biphasic DC pulse of typically 10 to 200uS at repetition rates of 10Hz to 10kHz. Its not the current that's important, it's the charge transferred (combination of current and pulse width) and there are strict guidelines on the safe amounts. the electrode dimensions are also important to control the charge field (Amps per unit area).

The biphasic pulse can be symettrical (i.e same current and width in each direction), or asymettrical, as long as the current * width balances out as unbalanced charges have detrimental effects on the cells.

We use a range of different products at the research lab attached to the spinal injury centre for research into both pain relief and muscle stimulation for restoration of function. We've also designed and built our own 16 channel unit which can output upto 100v and 80mA for deep muscle stimulation.
 

Irving

Joined Jan 30, 2016
3,885
There are several instrumentation amps with Common mode capability >120v, but it's not really needed here as the sense amplifier is referenced to one side of the output so can be considered to be on the 'low-side' - one electrode is taken as the reference and the pulse polarity is relative to that. Typically it's a half bridge arrangement rather than a full bridge.

The really cheap units use a pulse transformer to generate the output with some basic waveform shaping on the primary and little regulation. The really good units, like my £800 8-channel HasoMed stimulator use direct drive from a current-limited 200v source.

If I get a chance later when I'm back on my PC I'll post an example output circuit from a 'good' unit.
 

DickCappels

Joined Aug 21, 2008
10,171
The transformer is a problem. I suggest that you seriously consider @Ian0 's suggestion of an analog current source, as he explains in post #11. If you need help with the discreet opamp or the current pump, we are here to help.
 

ronsimpson

Joined Oct 7, 2019
3,037
discreet opamp
HV op amp There are some high voltage amplifiers that you can not afford but could get a prototype going.
Another option is to make a "push pull" kind of a circuit using 45 volt amplifiers. (cost is much better) There will be two amplifiers, while one pushed up the other will push down to make twice the output voltage swing. In audio they call it a bridged amplifier.
1625404495432.png
---------
edite
-------
In the hospital they use a liquid or jell to make the skin conductive. This would greatly reduce the need for "high voltage".
 

Irving

Joined Jan 30, 2016
3,885
In the hospital they use a liquid or jell to make the skin conductive. This would greatly reduce the need for "high voltage".
Proper electrodes don't require extra gel, they don't use it all at the spinal unit, nor do I at home. Surface skin resistance is not a major factor, hydration levels are; gel on the surface has very little benefit. The spacing and location of the electrodes has a huge impact on effectiveness, depending on what you're trying to do. Small currents travel horizontally in the outer layer of the epidermis, but as you increase the stimulation the field goes deeper till it starts impacting on the neural interface to the muscles and then you get muscle stimulation.
 

Ian0

Joined Aug 7, 2020
9,814
HV op amp There are some high voltage amplifiers that you can not afford but could get a prototype going.
Another option is to make a "push pull" kind of a circuit using 45 volt amplifiers. (cost is much better) There will be two amplifiers, while one pushed up the other will push down to make twice the output voltage swing. In audio they call it a bridged amplifier.
View attachment 242702
---------
edite
-------
In the hospital they use a liquid or jell to make the skin conductive. This would greatly reduce the need for "high voltage".
Bridged mode would get double the output voltage quite nicely, but the job of making it "current output" rather than "voltage output" becomes rather more difficult. As we only need 600uA, an audio amp capable of 4A is a bit overkill! A discrete op-amp only needs a BC857/BC847 output stage.
 

ronsimpson

Joined Oct 7, 2019
3,037
LT1637, MC 34071
Randomly grabbed some low cost 40V opamps in the 40mA size.
It would take a good diff amp to see the current.

On the other hand a good CMOS op-amp, you can measure the supply current and almost see the load current.
------edited------
Just remembered that a 40V opamp can only output +20 to -20.
 
Last edited:

Thread Starter

danielantonic

Joined Sep 22, 2019
68
Having said all of the above, TENS units don't actually generate AC as such. They generate a biphasic DC pulse of typically 10 to 200uS at repetition rates of 10Hz to 10kHz. Its not the current that's important, it's the charge transferred (combination of current and pulse width) and there are strict guidelines on the safe amounts. the electrode dimensions are also important to control the charge field (Amps per unit area).


The biphasic pulse can be symettrical (i.e same current and width in each direction), or asymettrical, as long as the current * width balances out as unbalanced charges have detrimental effects on the cells.


We use a range of different products at the research lab attached to the spinal injury centre for research into both pain relief and muscle stimulation for restoration of function. We've also designed and built our own 16 channel unit which can output upto 100v and 80mA for deep muscle stimulation.

Thats a much better description of the waveform I am trying to make - symmetrical biphasic DC pulse. I have uploaded the videos I made using my DCScope (not the best resolution/quality, but it gives me an idea of what the machine is doing - if anyone is interested the links are:
http://www.dcnsolutions.net/FSM/20191114_105749.mp4
http://www.dcnsolutions.net/FSM/20191114_105827.mp4
http://www.dcnsolutions.net/FSM/20191114_105905.mp4


There are several instrumentation amps with Common mode capability >120v, but it's not really needed here as the sense amplifier is referenced to one side of the output so can be considered to be on the 'low-side' - one electrode is taken as the reference and the pulse polarity is relative to that. Typically it's a half bridge arrangement rather than a full bridge.


The really cheap units use a pulse transformer to generate the output with some basic waveform shaping on the primary and little regulation. The really good units, like my £800 8-channel HasoMed stimulator use direct drive from a current-limited 200v source.


If I get a chance later when I'm back on my PC I'll post an example output circuit from a 'good' unit.

I'd love to see that! Thanks in advance!


Step up to ±60V (anything above that is considered "live" so would probably be illegal), make an op-amp out of discrete transistors which will withstand 120V, and connect it as a Howland current pump?


TI has an interesting paper of Howland current pumps

https://www.ti.com/lit/an/sboa437/s...7&ref_url=https://www.google.com/#:~:text=The Improved Howland current pump,wide range of load resistances.

This is new to me - I'll look up some info on the Howland Current pump.


The transformer is a problem. I suggest that you seriously consider @Ian0 's suggestion of an analog current source, as he explains in post #11. If you need help with the discreet opamp or the current pump, we are here to help.
Thank you very much! This is a BIG learning curve for me! If I do away with the transformers, I'll need to boost the voltage up to +/-60V and get appropriate OP Amps that work in that range (something I am not too familiar with). The details of the device did say that each channel was "Galvinically isolated" (http://www.dcnsolutions.net/FSM/20191008_153038.jpg) - I assumed they meant by a transformer.

I have had a thought though - could I put in a "test" pulse of a set DC voltage every few seconds to check the skin resistance? I'm using an Arduino Mega so I have a few spare pins to control a buffer of some sort so that I can periodically override the signal being sent with a flat DC of +5V and activate a link to test the resistance against a known shunt of say 1k...? That way I am testing the skin resistance to set the current using +5V which can feed back into the Arduino with no risk of going over voltage...?
 
Top