How to Use a Digital to Analog Converter

How to Use a Digital to Analog Converter © CC BY

Sometimes you need to generate a analog signal from a digital source a DAC or a digital to analog converter helps you do this.

  • 10 views
  • 0 comments
  • 0 respects

Components and supplies

Apps and online services

About this project

When you need to convert an analog voltage to a digital value you could use a analog to digital converter. But what do you do when you need to convert a digital value into an analog voltage? In this tutorial, I will be guiding you through exactly that.

Digital to Analog Converter

For this I will be using Aptinex DA1C010BI module. This module uses the popular MCP4725 DAC IC with integrated EEPROM. It interfaces to your micro-controller with I2C communication bus up-to 3.4Mbps. It has a both input I/O and power range of 3.3V-5V and out put range is 0-10V.Additionally output have been buffered and offset corrected so you can achieve true 0V level at the output.It has a integrated voltage boost stage so you can power it off of 3.3V-5V yet can output 10V. Now we shall look at how to connect everything together.

Hookup Guide

The module features a dual row header. This is useful if you want to daisy chain more modules or use the I2C bus for other devices. You can use either 3.3V or 5V to power the module.The I/O voltage is also compatible with both 3.3V and 5V. Following is how you could hook up to a Arduino Uno.

Software Needed

I will be using Arduino IDE with Aptinex MCP4725 Arduino library. To test the module, you can simply use the given example below.

#include <Wire.h>
#include “Aptinex_MCP4725.h“
Aptinex_MCP4725 dac;
void setup(void) {
Serial.begin(115200);
Serial.println(“***APTINEX MCP4725A DAC MODULE TEST CODE***“);
// For Aptinex MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
// For MCP4725A0 the address is 0x60 or 0x61
// For MCP4725A2 the address is 0x64 or 0x65
dac.begin(0x62);
Serial.println(“First, Enter H and adjust pot for the maximum value (10v) “); // measure DAC output voltage with multimeter
Serial.println(“Enter H for maximum value“); // DAC output will be set to the maximum value
Serial.println(“Enter M for medium value“); // DAC output will be set to the medium value
Serial.println(“Enter L for lowest value“); // DAC output will be set to the lowest value
}
void loop(void) {
uint32_t counter;
char incomingByte;
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
if (incomingByte == ‘H‘) {
counter = 0xFFF;
dac.setVoltage(counter, false);
Serial.println(counter);
delay(100);
}
else if (incomingByte == ‘M‘) {
counter = 0x800;
dac.setVoltage(counter, false);
Serial.println(counter);
delay(100);
}
else if (incomingByte == ‘L‘) {
counter = 0x000;
dac.setVoltage(counter, false);
Serial.println(counter);
delay(100);
}
}
}

Code

Aptinex_MCP4725_Library.zipC/C++
Aptinex MCP4725 Arduino Library
No preview (download only).

Comments

Similar projects you might like

Send Analog Pulse Using DAC — AD5669 with Arduino

Project tutorial by Varul Jain

  • 1,817 views
  • 1 comment
  • 10 respects

Arduino Toolboxes : Analog Level Visualizer

Project showcase by Arduino World

  • 12,276 views
  • 15 comments
  • 34 respects

Digital Clock

Project in progress by Team SharKode

  • 7,027 views
  • 4 comments
  • 26 respects

Arduino Digital Clock Version 2

Project showcase by Arduino World

  • 6,407 views
  • 0 comments
  • 22 respects

Arduino Digital Clock Version 1

Project showcase by Arduino World

  • 3,890 views
  • 2 comments
  • 17 respects

Arduino Digital Clock Version 1.1 Serially Synced

Project showcase by Arduino World

  • 2,274 views
  • 0 comments
  • 6 respects
Add projectSign up / Login