I would like to create a TENS machine but use the arduino to control the output. Instead of using integrated circuit to control the frequency and pulse width, I want to use an arduino. Rather than having a constantly pulsing output, I want to be able to program patterns on the fly. For example, a constant current for 1 second, then a 2 second pause, then a constant 2 second current, then a 10hz pulse with 100 microsecond pulse width for 5 seconds.....etc

From reading the schematic, the voltage can be stepped up using this schematic (although it was not used for the final implementation)

Would it be feasible to create this step up converter and control it using the arduino?

Current is constant. It is voltage that is controlled in a TENS unit. Technically, the current will vary by frequency (the higher the frequency, the lower the resistance of the skin = more current.)

In a TENS unit there are 4 controllable parameters. They are the frequency, the pulse width, voltage, and duration. Of course, you could also experiment with different waveforms, but normally a TENS unit just uses square waves.

Using the Arduino to control this you would use PWM for the frequency and pulse width portions. Since the body is essentially a low pass filter, different PWMs will effectively deliver different voltages.

A TENS unit usually has a step-up converter as you noted which normally operates in the 40-80V range. Some are adjustable down to 10V. But you really shouldn't need to directly change the voltage. For safety reasons, the current is limited at the output so it cannot go high enough to cause injury or death.

At the point of output, you apply your stepped up voltage to a push-pull FET driver and apply your modulated control waveform to the gate of the FETS. This will pulse the 40V to 80Vs into the body.

Now, many people call the whole field of these TENS units, but there are actually several different types of electro-stimulation devices. Each has specific purposes (a TENS unit will not cause muscular contractions, for example) which require different waveforms, different voltages, etc...

A TENS unit is designed for pain control. That is all it is good for. What is your goal?

In summary, the step-up convert is not what you want to control with the Arduino. You want your Arduino to take the place of the Switching Oscillator and the intermittent control of that circuit you linked to.

I am a medical doctor and I also have a chronic pain issue. I have been using a TENS machine for a few years. I have found that I get a good response from low intensity(voltage), small pulse width output.

It may sound strange, but my pain is not constant and I can get waves of dull pain. The various machines I have used all have patterns of various different types (crescendo decrescendo, slowly increasing etc...)

I want to program my own patterns.

Thank you for your help. If I have understood you correctly, I will need to build a step up converter and then use the arduino to control it via the current at the base of the transistor Q1 in the diagram that I included.

Would you happen to have any links to help me out regarding the step up converter?

I modified the schematic to show you all the parts that would remain. Your Arduino would connect to the Q1 and Q2 inputs. Turning on Q1 will allow the 80V to pass to the electrodes and turning on Q2 would short the electrodes to ground. Never turn them both on at the same time! This is a totem-pole configuration. Turning them both on at the same time would short the 80V directly to ground, and blow things up.

So you would apply your PWM signal output from the Arduino to the Q1 input, and the inverse of your PWM to Q2. This will modulate and shape your 80V waveform.

Everything else is controlled by your code by altering the frequency, pulse-width, and turning the PWM on and off for your patterns and durations.

You could also build a step-up converter from modern and more efficient components (recommended). Check out the SwitcherPro tool at https://focus.ti.com/docs/toolsw/folders/print/switcherpro.html?DCMP=hpa_tools&HQS=Tools+OT+switcherpro

Maxim has a similar tool to design a switching power supply.

I am hesitant to design and post a schematic and code because of liability. But there are enough hints there to get you going.

This is something I have looked at off and on over the years as a one-day project. I don't suffer from chronic pain, so there hasn't been an immediate need to build one. Just an interest in experimenting (more with muscle building, range-of-motion, and CES applications.)

I investigated Arduino-controlled TENS last year. After some internet research I determined that it needs short (less than 1ms) pulses of constant current, up to about 30mA @ up to about 100V. The pulses are supposed to be alternating polarity to prevent electrolysis. In a multi-channel TENS unit, all the channels should be isolated from each other, since you don't want current flowing between different pairs of electrodes.

I came to the conclusion that the easiest solution was to use a transformer for each pair of electrodes (thereby providing both isolation and voltage step-up), and to feed the primary of the transformer with a constant-current pulse (alternating the polarity) from an H-bridge. It so happens that constant-current H-bridge chips are produced for controlling the shutters of digital cameras, and these chips can switch up to 500mA. If the H-bridge is powered from a 9V battery (which is what almost all the commercial TENS units recommended by the UK NHS appear to use as the power source), up to about 7V can be put across the transformer primary. A transformer with a turns ratio of about 12:1 will then allow the required voltage and current to be generated.

I knocked up a prototype, using 5 mosfets to switch in different current setting resistors (giving 31 intensity levels). For the transformer, I tried using small mains transformers in reverse (which turned out to have too much resistance), designed a home-wound ferrite-cored transformer (which I never got round to winding), and ended up using an audio transformer that did the job well (although it was heavier than ideal for a wearable unit).

If you are interested, drop me a PM and I'll search for the schematic.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.