Arduino Programmable 10 Volt DC Signal Tutorial

Use an LM358 Op Amp and an MCP4725

LM358 Non-Inverting Amplifier FeaturedIn a previous article I have shown how you can create a 5 Volt supply using an MCP4725.  In another,  I have shown how to create a 5 volt supply using an LM358 Op Amp.   This one combines the two and shows how to create a programmable 10 Volt DC signal using both.

The MCP4725 is an AD converter that is controlled via I2C.  The link above explains it in more detail.

The LM325 is an Op Amp.  If you’re unfamiliar with Op Amps,  you can read this Op Amp Introduction.

Getting the Parts.

The MCP4725 can be found at any of the sites below:

eBay     Amazon     Bang Good     Deal Extreme

The LM358 is also readily available:

eBay     Amazon     Bang Good     IC Station

Circuit Functional Description

This circuit will use an LM358 Op Amp that is configured as a non-inverting amplifier.   In this configuration,  R1 and R2 for feed back and gain resistors respectively.   The values of these resistors determine the gain of the amplifier.

Simple put,  they form a voltage divide.  When the Op Amp receives and input on pin 3,  it will raise or lower it’s output until the level at pin 2 is matched.

In this circuit, we will use an 8.2K resistor and a 10K potentiometer.  The potentiometer is set so that it matches the value of R2 exactly.  Thus, in order for the Op Amp to establish an output that causes the voltage at pin 2 to to match pin 3,  it will have to create an output that is double the input.

LM358 Non-Inverting Amplifier

Component Pin Outs

Diagram for the LM358

LM358 Pin Outs

Diagram for the MCP4725

Arduino MCP4725 Module Pin Outs

Arduino LM358 MCP4725 Programmable 10Vdc Signal Tutorial

You’ll Need the Adafruit MCP4725 Library

The Adafruit library can be found HERE.

If you don’t know how to install libraries,  I suggest this article from the Arduino folks.

Make The Connections

You’ll want the 12V supply or higher.  You will also need to set the potentiometer so that it matches the actual resistor value of R2.

LM358 Op Amp MCP4725 10V Supply Arduino Tutorial Hook UpCopy Paste and Upload the Sample Sketch

#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;
        
    // About 1V Out from MC4725
    // About 2V Out from LM358    
    dac.setVoltage(819, false);
    delay(3000);
    
    // About 2V Out from MC4725
    // About 4V Out from LM358    
    dac.setVoltage(1638, false);
    delay(3000);
    
    // About 3V Out from MC4725
    // About 6V Out from LM358    
    dac.setVoltage(2457, false);
    delay(3000);
    
    // About 4V Out from MC4725
    // About 8V Out from LM358    
    dac.setVoltage(3276, false);
    delay(3000);
    
    // About 5V Out from MC4725
    // About 10V Out from LM358    
    dac.setVoltage(4095, false);
    delay(3000);
      
    
}