# What's the best way to control DC current in a circuit from 1mA-20mA at 15-30V input with a microcontroller?

I’m trying to create a circuit for iontophoresis that I can control the current of with a raspberry pi or eventually a microcontroller. What would be the best way to control the current?

Iontophoresis is a treatment for sweaty hands or feet where the hands or feet are placed on two separate electrodes and a current of between 4-20mA is driven through the body. I would like to be able to take an input voltage of 15-30 V and produce a 4-20mA current depending on what value I specified ahead of time. I also want to increase the current over a few seconds rather than go straight from 0 to max.

I did a session yesterday and found that the current from 2 9V batteries wired in series started at about 18 mA and then slowly dropped down to 8mA or so. I was using tap water with salt and baking soda in it with aluminum foil sheets as electrodes and paper towels to separate my hands from the electrodes.

For the polarity switching I plan to use an H-bridge circuit. And I have an INA219 sensor to measure current and voltage with, but I’m not sure what exactly I should use to control the current. Digital potentiometers seem to often be only able to handle voltages of around 5V. I found this one that can handle up to 30V but it also claims that max current is only 5mA at 30V and Rwb < 6k ohms and A open. Which I’m not sure if that’s a problem or not?

Another option seems to be variable voltage regulators. I found the LM317-N and a video talking about how to set it up as an adjustable constant current source. My only concern with that is the minimum load current is listed as TYP: 3.5mA and MAX: 10mA. Does that mean I’d have issues running it at less than 3.5mA through the hands during the startup and shutdown? Constant Current Circuit Design

Any advice on the best course of action here? Is one of those a good solution or is there a better way of doing this?

• Pretty much any common op-amp like an LM324 can source or sink 20mA, however I'm not sure what you are doing is safe. May 14, 2020 at 1:01
• Long-term exposure to DC current definitely is not safe: DC current causes chemical changes in the tissues that it flows through, and any exposure to current (DC or AC) that passes from one limb to another carries a risk of messing up your heart rhythm. May 14, 2020 at 1:31
• P.S., "4-20mA?" For real? Now, where have I heard those numbers before?... Sounds like maybe whoever invented this bogus snake-oil idea maybe found some components in the Grainger catalog that they thought would make it sound and look "scientific." May 14, 2020 at 1:33
• @SolomonSlow Not saying there aren't potential issues but it's actually a very widely accepted treatment for hyperhidrosis with multiple devices approved by the FDA for use. Some more info on it: ncbi.nlm.nih.gov/pmc/articles/PMC5705354 sweathelp.org/hyperhidrosis-treatments/iontophoresis.html May 14, 2020 at 23:21
• Found the web site of the company that makes the machine described in that paper. I can't read Korean, so I don't know what it claims, but just based on the pictures, I'd say it's pretty sketchy. May 15, 2020 at 1:04