Whelp, AC stimulation is working. Mostly. In the spirit of "Release early, release often", I'm putting out an experimental* AC-capable version of OpenStim.

More specifically, I'm reasonable confident that the latest version will basically do what you tell it to do in terms of generating waveforms. Specifically, it implements the custom waveform settings described on the wiki page. This allows you to specify a waveform shape and frequency in the input file, and the the OpenStim will output that waveform. This is a very flexible system, because it allows you to implement a whole bunch of different protocols that rely on having the ability to do AC or custom DC waveforms(tRNS, single frequency AC, etc.). Right now, the absolute maximum frequency that the system can generate is 100 hz, though I'm working on increasing that.)

In order to use the latest build, you'll also have to make a few(very simple) changes to your hardware. Specifically, you'll have to:

Connect the "ground" electrode to the Arduino's GPIO 8(This lets the software toggle which electrode is the anode and which is the cathode)

Connect the AD5206 side of the current sense resistor to analog input 5, and the Arduino side of the current sense resistor to analog input 4. This allows the OpenStim to detect current going both directions.

If you're confused, there's a wiring diagram

A few caveats:This version has some pretty major changes to the control logic(it's been switched to a system based on timer interrupts), so some features may not work correctly with the new system. In particular, right now I know: