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

  • readybrek: Anyone got a any recommendations for a budget-priced hot air station?
  • William: lol I'm happy to waste 3c for each program/debug cycle... but probably not the time spent soldering a new device down to a proto board!...
  • Joe Desbonnet: Ya, I can recommend the low melting point solder. I used brand 'ChipQuik' and it's amazingly easy to use.
  • Jerome: I need a new BusPirate for the Fablab ;) Many thanks!
  • Max: Seems like an unexpectedly violent way to remove the chip indeed. A hot air station should of course do the job just fine, but in...