Monday, July 1, 2019

Use a MCP4728 DAC with AVR ATmega


The MCP4728 device is a quad channel, 12bit voltage output DAC. It also has EEPROM embedded.
The DAC is driven using the I2C interface.

This library implements an ATmega driver for this IC.


The selected I2C library is the one proposed by Peter Fleury, you can find it here: http://homepage.hispeed.ch/peterfleury/avr-software.html

This library can drive up to 8 IC, depending on the MCP4728 selected address.

Each individual channel can be powered down, then wake up.
User for setting gain, raw output value and voltage value is provided. Also values can be stored to IC EEPROM.

The reference voltage can be set as internal, that is 2.048V, or external.

The sample provided output a sine wave, or a voltage output test.

The max output voltage depends on the gain and the voltage reference selected, if external voltage is selected as reference the gain is omitted.


The sample schematics contains also an output stage build up using a LM358 opem with a non-inverting configuration.
In non-inverting configuration the Gain is R2/R1 + 1, given R2 the resistor between out and - input, and R1 the resistor beteen - input and GND. The sample gain of 3.2 amplifiy the input signal taken from the DAC by 3.2, of course the output voltage can not exceed the power supply voltage of the opamp. For this reason if you supply the LM358 with a 12V supply, a sample output voltage of 2.4V will became 7.68V output.
The output current is limited to 20mA for a sink load and 40mA for a source load.
By simply adding a power MOSFET you can amply the output current that can be draw.

This project has been developed and tested on an ATmega8 running at 8Mhz.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

No comments:

Post a Comment