Arduino MCP4725 DAC
18/06/2020 | Views: 2017 | Arduino | by: ELECTRONOOBS      


To give more power to Arduino board DAC (Digital to Analog Converter) interfaced through breakout board and detailed Arduino DAC Tutorial given in this article for the best understanding. Here DAC IC MCP4725 based breakout board is used because it is 12-Bit Digital-to-Analog Converter with EEPROM Memory, this IC utilize low power and gives high accuracy output. This IC comes in sot package hence better to go with breakout board in this tutorial we used Sparkfun I2C Breakout MCP4725 board. By using this board we can obtain Analog voltage from Arduino board depends on the digital input and it accepts input in I2C format.

MCP4725 Arduino tutorial


MCP4725 DAC IC


Features and Applications of MCP4725. This IC provides 12 bit resolution and on board Board Non-Volatile Memory (EEPROM). It can be addressed by external A0 address pin, and operates in Normal or Power-Down Mode. It takes wide range of input supply voltage as 2.7V to 5.5V from single supply source. This IC provides eight address through I2C and have Extended Temperature Range: -40°C to +125°C.

Applications

Sensor Calibration
PC Peripherals
Data Acquisition Systems
Low Power Portable Instrumentation

MCP4725 Arduino connections



MCP4725 Arduino connection


Construction & Working. Connect 5V pin and GND pin of Arduino board to Breakout board VCC and GND pin then connect A4 (SDA), A5 (SCL) pins with corresponding I2C pin of MCP 4725 brakout board. If you using other Arduino board then refer and use the corresponding I2C pins. Output pin of MCP4725 is connected with Analog pin A0 by the way we can measure and display the Analog voltage obtained from MCP4725 in serial monitor, you can also measure by using digital voltmeter or multimeter.

MCP4725 Arduino connections



Arduino MCP4725 Code


Here is an example code for the MCP4725 with the Arduino. You will need to install the Adafruit_MCP4725.h library so downlaod it from below. It will be a.zip file. In Arduino IDE, go to include library as .zip file and select the downlaoded file. Now the library shoudl work. Compile, make the connections and uplaod the code.




#include <Wire.h>             //wire library
#include <Adafruit_MCP4725.h> // MCP4725 library from adafruit
#define analogVin A0          // Analog voltage input to A0

Adafruit_MCP4725 MCP4725; 

void setup(void) {
  Serial.begin(9600);
  MCP4725.begin(0x60); // Default I2C Address of MCP4725 breakout board (sparkfun)   If not try 0x61 or 0x62
  
}

void loop(void) {
  
    uint32_t MCP4725_value;
    int adcValueRead = 0;
    float voltageRead = 0;
    
    float MCP4725_expected_output;
    
   
    for (MCP4725_value = 0; MCP4725_value < 4096; MCP4725_value = MCP4725_value + 15)
    {
      MCP4725_expected_output = (5.0/4096.0) * MCP4725_value;
      MCP4725.setVoltage(MCP4725_value, false);
      delay(250);
      adcValueRead = analogRead(analogVin);
      voltageRead = (adcValueRead * 5.0 )/ 1024.0;
      
      Serial.print("MCP4725 Value: ");
      Serial.print(MCP4725_value);
      
      Serial.print("\tExpected Voltage: ");
      Serial.print(MCP4725_expected_output,3);
      
      Serial.print("\tArduino ADC Value: ");
      Serial.print(adcValueRead);
      
      Serial.print("\tArduino Voltage: ");      
      Serial.println(voltageRead,3);      
    }    
}





18/06/2020 | Views: 2017 | Arduino | by: ELECTRONOOBS      












Last tutorials

Arduino Port Register Control
433MHz Relay Control
ARDUINO E-BIKE ESC
Digital Electronic LOAD



PCBWAY PCB service

PCBWAY PCB service

PCBONLINE PCB service