HUM: 12-BIT MCP4725 DAC BREAKOUT
You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Dasduino and the basic code. Everything else is left to your imagination.
INTRODUCTION
Microcontrollers, just like any other computer, work with digital signals for easy computing and saving data, and since most of these signals are actually analog, we need a circuit which will convert digital signal to analog. The desired effect will be obtained using this module which contains 12bit MCP4725 digital-analog converter (DAC). We will start by naming some characteristics of this module, and then we will explain how it works and how to connect it and use it with Dasduino.
Characteristics:
Voltage:Â 2.7V – 5.5V
Resolution:Â 12 bita
Communication interface:Â I2C
Dimensions:Â 15 mm x 12 mm
HOW DOES IT WORK?
The module is designed in a way that ensures easy use and compatibility with experimental boards and other modules and controllers in our offer. To this converter, we send a number from the 0-4095 interval, and on the output of the converter we get the voltage between 0V and VCC (power supply voltage). Due to conductor’s high resolution, we can get very nice signals on the output, because the difference between two adjacent values is merely 1.22mV. All digital-analog converters work by the following principle. We send a set of data to DAC, and it gradually turns them into voltage signal in a way that it converts one information into voltage equivalent to its output voltage which it keeps constant until it finds another information. For example, if we send 0->2048->0->2048->… data to the DAC, on the output we would get a rectangular signal between 0V and VCC/2. If we want to achieve a more complex analog signal, like sinusoidal, we must send a multitude of data to the DAC (numbers from the 0-4095 interval) which change by the sinusoidal function. In the image below, we see a sine waveform obtained by this module. If we reduce the time scale, i.e. zoom in on the signal, we will see how it is composed of a number of different values.
HOW TO CONNECT IT?
Connectors:
gnd:Â ground
VCC: voltage 2.7V – 5.5V
SDA:Â serial data I2C
SCL:Â serial clock0
Vout:Â output voltageÂ
In order to use the module with Dasduino, it is necessary to connect it in a way shown in the picture. Module power supply can be obtained by connecting +5V pin on the Dasduino to VCC pin on the module. Gnd connector of the module is connected to one of the two gnd Dasduino pins. Communication is achieved by connecting the SDA pin on the module to A4 pin on the controller, and SCL to A5. Output connectors of the module are connected to an oscilloscope probe to show you the vaweform voltage.
ARDUINO CODE
To make the use of this module easier, we will use the adafruit mcp4725 library which you can find here. The instructions on how to install Arduino libraries can be found in this tutorial. The program code shows how using Dasduino and this DAC we can generate an analog sinusoidal signal whose frequency and amplitude we can change.