Microcontroller action potential generator

Posted on Monday, August 21st, 2017 in AVR, how-to by DP


Scott Harden writes:

Here I demonstrate how to use a single microcontroller pin to generate action-potential-like waveforms. The output is similar my fully analog action potential generator circuit, but the waveform here is created in an entirely different way. A microcontroller is at the core of this project and determines when to fire action potentials. Taking advantage of the pseudo-random number generator (rand() in AVR-GCC’s stdlib.h), I am able to easily produce unevenly-spaced action potentials which more accurately reflect those observed in nature. This circuit has a potentiometer to adjust the action potential frequency (probability) and another to adjust the amount of overshoot (afterhyperpolarization, AHP). I created this project because I wanted to practice designing various types of action potential measurement circuits, so creating an action potential generating circuit was an obvious perquisite.

See the full post at

Check out the video after the break.

This entry was posted on Monday, August 21st, 2017 at 3:21 pm and is filed under AVR, how-to. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

One Response to “Microcontroller action potential generator”

  1. Drone says:

    First of all, let me post a reference about what Action Potential is in terms of Physiology (since DP isn’t adding much value these days – other than essentially dragging an dropping links here)…

    OK, that’s done.

    Now, A-P stimulus typically runs into the 100’s of Hertz repetitive based on stimulus time profiles (i.e., look-up time domain delays). Given the relatively low repetition rate and some need for waveform shaping, I think this application lends itself to a micro-controller running as a DDS arbitrary waveform generator (ARB). This would go far towards eliminating much of analog interface parts in this design, as well as adding enormous flexibility. Use a simple R2R 8-bit DAC for the output. Monolithic thin-film SIP passive DAC parts are readily available and cheap. Don’t forget to add a smattering of LPF to the DAC output to suppress unwanted spurious above (roughly) the Nyquiist rate. There are plenty of examples of AVR DDS implementations out there on the Web, especially for Arduino – pick one as a starting point. I think something like the use of an 8-bit AVR part for this sort of application because there are Tons of Arduino baseline examples to start with. But when you get down to a final design, you’ll want to clock a typical AVR (e.g., ATMega328) at 20MHz and program key parts in your DDS in assembler to take advantage of the excellent clock-per-cycle efficiency (and reduced complexity) of the RISC AVR parts. This is where I suggest you depart from an IDE like a raw GCC tool-chain or (gawd forbid) the Arduino IDE and move to the free (but not open source) ATMEL Studio IDE (or whatever it’s called today) from ATMEL/Microchip. (One only wonders how long the likes of free unencumbered ATMEL IDE survives before the Greed-Heads at Microchip kill it off).

    There are also a bunch of dirt cheap “Function Generators” available from China on ebay etc. that have arbitrary waveform generation capability that should (theoretically) be a drop-in for this application. But as with anything from China these days – YMMV.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Drone: The LM7171 used in this very simple design can be simulated in LTspice with reasonable results at 10MHz using the non-encrypted PSPICE model from TI...
  • Jon Jackson: I would be interested in 1 or 2 of your circuit boards. Jon
  • Max: An actual Saturday "detector" built with the same hardware would use the precisely timed slightly varying length of the day (and some built-in astronomy data)...
  • KH: In the old days, these things remained on paper forever as whimsical scrawls. Today, they are brandished about on blogs for the entire world to...
  • KH: So he doesn't really know what he's doing. Yawn. It's sensor-controlled. It's not an oscillator. A leaf covers the window, you're toast. TLV3702? Overkill. The...