Arduino Programmable Constant Current Power Supply

Arduino Controlled Constant Current Source

Arduino Constant Current Supply LogoThis experimental project uses an MCP4725 Digital to Analog Converter, an LM358 Op Amp,  an MAX471 Current Sensor and a logic level N-Channel Mosfet to create a constant current source.

We’re going to use the op amp in a non-inverting application.  If you’re not all that familiar with op amps,  you can read this Op Amp Basics Tutorial.

Where To Get the Components

MCP4725 Sources

eBay     Amazon     Bang Good     Deal Extreme

LM358 Sources

eBay     Amazon     Bang Good     IC Station

MAX471 Sources

eBay     IC Station

 

Component Pin Outs

Click on the images to get a better view.

MCP4725 Pin Outs

Arduino MCP4725 Module Pin OutsLM358 Pin Outs

LM358 Pin OutsMAX471 Pin Outs

Max 471 Volt Current Power Pinouts

IRLB8743 Mosfet Pin Outs

This is the Mosfet I used.  Most logic level N Channel mosfets rated for the current will probably work.

IRLB8743 Pinouts

 

Constant Current Source Function Description

Refer to the picture below:

Arduino Programmable Constant Current Supply

Fundamentally, we will use an LM358 to control the bias on the Mosfet until the current measured by the MAX471 matches what has been called for at pin 3 of the op amp.

The MAX471 has a very convenient output for this application is that it will provide a 1 volt output for 1 Amp of current measured.  Its measurement range is limited to three amps, thus this constant current supply is limited to 3 amps.

It is important to keep this measurement range in mind as providing an input greater than 3 volts into the op amp could be a bit of a problem.

Arduino Programmable Constant Current Power Supply Tutorial

In this tutorial, we’re going to use an MCP4725 Digital to Analog Converter to provide an input to pin three of our op amp.  You could also use an analog output from your Arduino directly as show in  this example for a power supply.

Get the MCP4725 Library

Adafruit has created a library for this device that can be found HERE.

If you don’t know how to install libraries,  you can read THIS ARTICLE.

Build Your MCP4725 Circuit

Your Mosfet is going to get hot.  Put a heat sink on it.

Click on the image to enlarge.

My load was three 1 ohm 5W resistors in parallel.

Arduino CC Power Supply Tutorial Connections

 

Copy Paste and Upload the Code

 

#include <Wire.h>
#include <Adafruit_MCP4725.h>

Adafruit_MCP4725 dac; // constructor

void setup(void) {
    
  dac.begin(0x60); // The I2C Address: Run the I2C Scanner if you're not sure  
  
}

void loop(void) {
  
    uint32_t dac_value;
        
    // Ask for 0.5A
    dac.setVoltage(410, false);
    delay(2000);
    
    // Ask for about 1A
    dac.setVoltage(819, false);
    delay(2000);
    
    // Ask for about 2A
    dac.setVoltage(1638, false);
    delay(2000);
    
    // Ask for about 3A
    dac.setVoltage(2457, false);
    delay(1000);
      
    
}

Test Your Circuit

There’s more than one way to do this.   You can use your voltage meter to measure the voltage across the load or you can use your meter in the ammeter mode.