Mcp4725 DAC

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
mnfisher
Valued Contributor
Posts: 938
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Mcp4725 DAC

Post by mnfisher »

There is a problem with the mcp4725 DAC component- when I first started using the chip I couldn't get an output. I wound up writing my own code - posted on the v8 forum.
))
The problem occurs if the chip is in power down. It can be woken either by a general call reset on the i2c bus or by using the normal 3 byte command.
Unfortunately the component uses the fast 2 byte form of the command in Initialise, SetOutput and Enable - so if the dac is powered down (and mine was) there is no way to wake it.
dac sine wave.fcfx
(16.9 KiB) Downloaded 118 times
Need to use SetOut3 to bringthe DAC out of it's sleep mode. This could also give the option to set the power down parameters and write the data to eeprom (though not added yet)...

Martin

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: Mcp4725 DAC

Post by BenR »

Thanks for the heads up Martin,

I've added a three byte command to the initialise now to hopefully bring the device out of power down but if you manage to have a go with it to proove it's now correct then that would be much appreciated.

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: Mcp4725 DAC

Post by mnfisher »

Thanks Ben,

It is better - I think the interpretation of the power down mode isn't quite right...

I think the output is either connected to the DAC or to ground via a 1k, 100k or 500K ohm resistor.
When the output is connected to ground via a resistor the DAC goes into a low power sleep mode - woken by i2c general call or 3 byte (normal) command according to the datasheet. Writing the resistance and power levels to the onboard EEPROM allow the DAC to power on (when Vcc applied) either at a set level or in a sleep state.

This is my take on it - it allows the data to be written to the EEPROM to test the power up state too.
DAC MCP4725.fcfx
(18.77 KiB) Downloaded 111 times
It just has 3 macros - Initialise (initialises the i2c - I'm not sure how to test with transaction mode if an ACK is received on 'just' transmitting an address - which can be used as a test for the presence of the DAC)

SetPower - which sets the power output to 0..4095 (note an Enable macro isn't needed either here or in the current component?) (Note - this uses the 3 byte mode if it thinks the DAC is off (first run, or disable has been called)

Disable - Sets power / resistance for disable mode and optionally writes the data to EEPROM. Resistance can be 0 (DAC is on and power set) or 1, 2 or 3 (1, 100, 500K Ohm respectively)

The Main - has a simple test - Initialise, pause for 1s to allow power-on state to be seen on oscilloscope. Brief sine wave then set disable status.

Martin

Post Reply