Fork me on GitHub

Project Notes

#569 Multi-voltage GPIO

A PWM charge-pump approach for driving low-current 0V, 5V, 12V output levels from an Arduino GPIO pin.

Build

Here’s a quick demo..

clip

Notes

For some microcontroller projects, especially those involving chip programming for older devices, it is necessary to apply higher-than-normal voltages on specific pins (for an EEPROM erase, for example). Usually only very low current/power is required.

How to do that with a nominally 5V microcontroller? This project outlines one approach, I’m sure there may be improvements or alternatives. It involves:

  • a PWM-controlled Dickson Charge Pump to generate a higher voltage (12V in this case) than the microcontroller power rail (5V)
  • high-side p-channel MOSFET switching of the high voltage to the intended output
  • BJT switching to enabled a “normal” high voltage of 5V, or a hard pull-down to 0V.

The net result is a 3-level output voltage (0V, 5V, 12V), using 4 GPIO from an Arduino.

  • 2 pins are actually used to drive the PWM charge pump - pins D3, D11 using Timer2 for PSM generation. These would not be required if a separate 12V supply or boost converter was used.
  • 1 pin (D4 in the example sketch) acts as the “high voltage” enable/disable
  • 1 pin (D5 in the example sketch) acts as the output high/low selector

Construction

I tested the circuit on a breadboard:

Breadboard

Schematic

I’ve added a voltage display unit to measure the actual output voltage (to within a few 10’s of mV):

Breadboard Build

Test

The test script MultiVoltageGPIO.ino exercises the circuit: it switches from 0V to 5V to 12V output on a loop, with each output change every 1 second.

To capture a scope trace of the output (below), I switched to a 100ms transition delay, and plotted the output with a -5V offset:

scope

Credits and References

About LEAP#569 ArduinoPower

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics projects - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader