A programmable transcutaneous electrical nerve stimulation device based on arduino and remote control using a smartphone

Chronic pain, which includes back pain, headache, and joint pain, affects one out of three people worldwide. The work, social life, and mind of an individual who suffers from this illness can be affected, and the illness severe. A transcutaneous electrical nerve stimulation (TENS) device is typically used to relieve the pain. Existing TENS devices, however, consist of a hard-coded program and are unhandy. Therefore, this work aims to improve such devices by using Arduino to make them programmable and handy. Arduino can be programmed to produce an electrical pulse pattern desired by the user. The circuit is equipped with Bluetooth to make it handy and connect it to a smartphone application. Results indicate that Arduino can generate electrical pulses similar to existing TENS devices and can be easily changed if required. Thus, it provides patients with customized treatment patterns and is portable.


1.Introduction
Uncomfortable sensations, such as pain, often could cause a destructive stimulus. The International Association for the Study of Pain defines pain as an unpleasant sensory and emotional experience associated with actual or potential tissue damage, or described in terms of such damage [1]. Pain is entirely controlled by an overly protective person's brain, regardless of what happens to the tissues in the body [2]. That is, most types of chronic pain can be treated through different tricks and stimulations [3]. However, the human brain is stubborn and hardly believes that pain [4] can be stopped completely. The brain can determine the pain level through various sources of information.
Pain has consistently tortured humankind for centuries. In the age of modernization, various medicines and technologies have been developed to deal with different pain [3]. Most of the pain experienced by humans in this world already has corresponding treatment. The strategies used to treat pain can be divided into pharmacological and non-pharmacological techniques [5].
*Author for correspondence In pharmacological treatment, drugs are usually used; such treatment has various side effects, such as an allergy to a substance in the drugs, or leads to a worse condition that can be fatal [6]. Therefore, nonpharmacological treatment is the best alternative to replace medications and treat pain, regardless of medications and severity [7]. One nonpharmacological technique is using an electrical device [8]. Treating pain by using a device has several advantages over pharmaceutical treatment (taking medicines) because there is no need to digest [9]. Furthermore, treatment by using devices can be cheaper than taking medicines in the long run and may be used in combination with recovery therapies to realize enhanced results [10].
A transcutaneous electrical nerve stimulation (TENS) device is usually used to relieve pain through electrical pulse injections into our nerve system [11]. TENS devices available in the market use wires over long distances and hard-coded electrical pulse programs. Wired TENS devices assist users only in problems requiring limited movement. On the contrary, a programmable electrical pulse generator can help the user customize treatment patterns.
The architecture of current TENS device circuits is mostly complex and uses many components to produce pulse width modulation (PWM) signals for the generation of electrical pulses. Thus, the objectives of this work are 1) to develop a simpler TENS circuit by using a programmable Arduino that can help the user deal with related nerve pain problems and relax muscles and 2) to develop an application for smartphones to make the TENS circuit be controlled remotely.

2.Development of wireless TENS device
Arduino Uno is one of the various Arduino microcontroller boards. This board comes with six inputs of analog, 14 digital input or output (I/O) pins (they can be utilized for PWM generation), a 16 MHz ceramic resonator, a USB connector, a force jack, an in-circuit serial programming header, and a reset button [12]. It contains all that is expected to help the microcontroller; essentially, it is interfaced with a USB connection to a PC or started using an AC-to-DC connector or battery. The Arduino Uno is based on an Atmel 8-bit AVR microcontroller that was created in Trondheim, Norway in 1996. Most Arduino architectures are considered reducedinstruction-set computing and consume minimal computational time. An Arduino board has mixed fragments to support programming, and it can be segmented into various circuits, as shown in Figure  1. The board typically uses ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560 chip arrangements. That is, numerous shields can be adjusted separately by allowing them to be stacked and used equally. Arduino compatibles utilize other processors. Most boards are equipped with a 5 V linear controller and a 16 MHz crystal oscillator, but they run at a low speed and deliver with a local voltage controller due to explicit structural limitations. The microcontroller is also pre-modified with a boot loader that unravels the movement of undertakings to the on-chip streak memory and various contraptions that require a programming engineer from outside. It makes the use of an Arduino increasingly transparent by enabling the use of a traditional PC designer. The current Arduino sheets are adjusted using USB connection [13]. For example, the FTDI FT232 Successive Arduino sheets contain a level switching circuit to switch among RS-232-level TTL signs.
The Arduino board reveals most I/O pins for use via different microcontrollers [14]. The Duemilanove, Diecimila, and current Uno deliver 14 I/O pins propelled, with 6 straightforward wellsprings of data and 6 that can make beat width directed signs. The Arduino Nano, Arduino-good No frills Board, and Boarduno sheets can provide male header pins to connect to solderless breadboards at the board's underside. They produce PWM signals that replace the integrated circuits of the 555 and 7555 timers used in standard TENS devices. Arduino encoding can be performed through Arduino software to generate PWM signals. Arduino software is used to connect among TENS devices, and the PWM generator circuit is a common technique used to change the pulse width of signals. PWM has many applications, such as servo and speed control, limiting motor and LED power effectively. It is a square wave with different high and low times.
The Arduino Uno is used to replace the PWM generator circuit in this work, and the PWM output is obtained from Pin 3. Digital control is utilized in the PWM generation to make a square wave and a signal shared between on and off. The on-off example can recreate voltages in the full middle on (5 V) and off (0 V) by changing the amount of time the sign invests in versus the energy it spends off. The pulse width is known as the "on-time" length. It can be regulated to obtain analog qualities that fluctuate. When the onoff pattern is repeated rapidly, it will produce a steady-voltage output signal.
An overall flowchart for developing a wireless TENS device is shown in Figure 2. It consists of two parts: 1) development of a TENS circuit and 2) development of a smartphone application. A detailed explanation on the key elements of each part will be presented in the following subsections. The modified circuit is discussed in the development of TENS circuit. Coding blocks of the application to execute the desired control scheme will be presented in the development of the smartphone application.

2.1TENS circuit
The TENS circuit in this work is simpler than the existing circuit suggested in [15] because some components have been replaced with the Arduino Uno to produce the PWM signal. The frequency and width of the pulse can be adjusted and controlled in accordance with the desired pattern. The circuit is supplied using a 9 V battery, as depicted in Figure 3. All essential devices in the TENS circuit are discussed in the following subsections.

2.1.1Interface switch
A switch is required to interface between the lowvoltage circuit from the Arduino Uno and the highvoltage TENS circuit. The most widely recognized type of switch is an electromechanical device that is physically worked with various electrical contacts associated with outer circuits. System activating the progress between two states can be either a "toggle" (flip switch for nonstop "on" or "off") or "momentary" (push-for "on" or push-for "off") type. An electronic switch is a device that switches an electrical circuit, intruding on the current or transmitting it from one conductor to another. The IRF9640 metal oxide semiconductor field effect transistor (MOSFET) that produces low power output is recommended over ordinary transistors. MOSFET is a transistor utilized for switching and intensifying electronic signs. Although MOSFET is a fourterminal device with gate, source, drain, and body terminals, its body is frequently linked to the source terminal, making it a three-terminal device similar to any other field-impact device transistors. Two terminals are typically connected to each other (shortcircuited) inside, given three terminals that turn out in electrical diagrams.
MOSFET can be considered the most successive transistor in digital and analog circuits [16]. In the enhancement mode, the MOSFET voltage drop over the oxide convinces a conducting channel between the source and channel reaching the field. The expression "enhancement mode" alludes to the increase in conductivity with the increment in the oxide field that inputs carriers to the channel alluded to as the inversion layer. The channel comprises bearers in a surface impurity layer of the inverse type to the substrate, and conductivity is diminished using a field of channel bearers from this surface layer.

2.1.2Voltage regulator
This circuit consists of a capacitor to regulate voltage from the supplied 9 V battery. The capacitor comprises of two aloof electrical terminals used to charge energy in an electrical field electrostatically. Aluminium thin films may be used as conductors. Capacitors are widely used in standard electronic devices. A non-conductive dielectric acts to increase the charge limit of the condenser. A condenser does not disseminate energy; instead, it stores energy among its plates as an electrostatic field. A capacitor provides a sifting activity by parting with a path from the load for the harmonic current.
The capacitor is also used to shorten overshoot and swell voltage present at the step-down converter output. With the lack of capacity and a high equivalent series resistance (ESR) at the output capacitor, enormous overshoot grounds caused by the lack of output capacitance and substantial voltage swell occur [17]. The wave content for a step-down converter circuit can be regulated by incorporating a capacitor with adequate capacitance and low ESR.

2.1.3Current limiter
A potentiometer is used to control the output current that will be injected through the human skin. The resistance of the human skin depends on age and gender [18]. A potentiometer is a physical threeterminal variable resistor. One terminal interface moves over the resistive part with a sliding touch called a wiper, and the other ends of a resistive component are connected by two terminals. The resistive component can be regarded as a series of two resistors (potentiometer resistance), in which the position of the wiper determines the resistance ratio of the primary resistor to the subsequent resistor. The potentiometer output voltage can be determined using the wiper. The potentiometer essentially works as a voltage divider to vary the voltage at terminals. As a result, the current flow through the human body can be controlled to prevent inconvenience. The potentiometer is known as a "potmeter" or "pot". The most popular type of potentiometer is the single-turn rotation. Sound volume control is usually utilized by this sort of potentiometer, similar to different applications. It is generally made of cermet, metal film, wire wound, carbon composition, and conductive plastic.

2.1.4Step-up transformer
A transformer is used to boost the voltage from the supplied 9 V battery to a higher voltage at skin terminals. Large windings are connected to probes and earth through a resistor. In this case, the output voltage can reach a maximum of ±60 V electrical pulses by using a transformer with 1:10 ratio.

2.2Smartphone application
MIT App Inventor is used to build an application to control a TENS device remotely through a smartphone. The MIT App Inventor is visual programming that lets everyone build smartphone and tablet applications that are fully functional [19]. The block-based tools facilitate the complex systems that are produced in a much shorter time than conventional programs. The coding for this application is performed using an online platform. The first screen is coded using the available blocks, as shown in Figure 4, to display the TENS logo as a start button before it goes to the second screen. The second screen is where users provide input in accordance with their needs. Figure 5 shows coding blocks that are used in the second screen.

3.Result and discussion
The proposed TENS circuit is tested on the Tinkercad platform [20], as shown in Figure 6. The proposed TENS circuit based on the Arduino Uno board can produce output specifications based on the standard circuit, as shown in Table 1. A monophasic pulse waveform is generated because the PWM signal is used in the proposed circuit. The pulse amplitude can be adjusted by using a digital potentiometer in the circuit. Therefore, a pulse current amplitude similar to the standard [21] is produced. The pulse frequency can be obtained from the time period of the output PWM signal. The time period is measured at 0.008 s or equivalent to 125 Hz. From the signal, the pulse duration is provided by the "on" time. It is measured at 100 µs. This finding clearly shows that the proposed TENS produces the output waveform in accordance with the standard. Figure 7 Illustrates the process of using the developed application to control the output electrical pulse from the TENS circuit remotely. The application provides an option for users to select body parts to be treated and electric pulse durations (μs). Users can choose the required intensity in accordance with their comfort; thus, the pulse is neither excessively strong nor weak during the treatment. Start, stop, and pause buttons are also available to allow users to stop or continue at any time during the treatment.
The combination of the proposed TENS circuit and a smartphone application enables users to control their treatment wirelessly. The communication between them is established using a Bluetooth module. In this case, the TENS device can be placed at any part of the user's body without the hassle of wires. The TENS circuit is then activated, and the treatment can be adjusted remotely using a smartphone. The treatment's electrical pulses can be easily customized because the proposed TENS is based on Arduino.  Process for wireless TENS control by using a user interface application

3.1Approach limitations
This work successfully demonstrates that the TENS circuit can be developed using Arduino board and controlled remotely using a smartphone. For safety precaution, the entire system is carried out within a simulation environment. Hence, the physical effects on its operation are not considered. The actual dimension and weight of the TENS device also cannot be determined. Nevertheless, the capability of TENS device for a real-time application can be investigated using Tinkercad.

4.Conclusion and future works
Pain can be treated through high-frequency TENS that should be used as an adjunct to pharmacologic methods to replace pills. This paper presents a TENS circuit based on a programmable Arduino. Nearly half of the components in the original TENS circuit can be replaced with the Arduino Uno. The proposed TENS circuit is developed and tested within the Arduino Tinkercad simulator. Then, an application is developed using the MIT App Inventor platform to control the electrical pulses from the TENS circuit remotely during treatment by using a smartphone.
The results show that the proposed TENS circuit is able to produce similar electrical pulses to those by using the standard TENS device. The smartphone application enables remotely controlling the TENS device. In future works, the proposed TENS device can be developed using hardware, and the optimal dimension of the device can be obtained. As a result, the conventional TENS device can be improved to avoid the hassle of wires and become highly flexible in terms of treatment patterns.