Hardware (shield) ================= - female header SV1 . pins 1-3 are to be connected to a 10k potentiometer which scales the output from opamp IC1A and feeds it into opamp IC1B. Alternatively pins 1 and 2 can be connected so that IC1B receives the full output of IC1A. . pin 6 should either be connected to an external 10-12V power source or to pin 5 which is connected to the Arduino's Vin. In the latter case, the Arduino should be powered from its power jack, not from USB. . pins 7-8 have the output signal coming from transformer TR1. - transformer TR1 . salvaged from an old MBO TENS unit. . primary winding's resistance about 0,7 ohm, secundary 90 ohm. . winding ratio is unknown. - 300 µF electrolytic capacitor . or 3 x 100 µF in parallel. . should be low-ESR (equivalent series resistance) Software (sketch) ================= The working of the sketch is internally documented. Almost everything of the operation is done in interrupt handlers. - TIMER1 interrupts: . determine pulse frequency. . drive the digital potentiometer to charge the capacitors to the required voltage. . set parameters for the TIMER2 interrupts. . initialize pulse by switching driver mosfet on. . start TIMER2. - TIMER2 interrupts: . determine pulse duration. . after pulse duration switch driver mosfet off. . if necessary, switch capacitor discharge mosfet on. . after discharge duration switch capacitor discharge mosfet off. - ADC interrupts: . take care of continuously reading out the 10-bit A/D converters and conditionally storing the result in an element of the array analog[]. The condition is that the corresponding element of the array anamask[] is not zero. Element analog[0] is special. Its value is used to determine which function is used to determine the pulse parameters. Currently there are 10 pulse parameter generating functions which are all described in the accompanying document function_table.pdf. These functions use one or more values from the array analog[]. These values can come from e.g. voltage dividers (potentiometers) connected to the Arduino's analog pins. The value from analog pin 1 is used to select one of the pulse parameter generating functions. Here also a potentiometer can be used, but e.g. an 11-position rotary switch populated with 10 1k resistors will be more user-friendly. The Arduino IDE's function loop() is not currently used. It can (and will) be used for varying the output on longer timescales. E.g., for ramp-up and -down features, frequency modulation, etc. To make this possible, elements of the array analog[] can be detached from the ADC by setting the corresponding elements of the anamask[] array to zero. Those parameters can then be modified by the code in the loop() function. --- 31-05-2016 update: 12-10-2016