Page 1 of 1

MCP4725 Digital to Analogue Converter + MATLAB

Posted: Fri Aug 19, 2022 9:53 am
by khemzi
Hi,

Ive connected the MCP4725 DAC to an arduiono uno (I2C interface). I'm controlling the DAC's input voltage through matlab, and the arduino acts as a 5v power supply. Everything works perfectly and I can send 10 bit number to the DAC with the write(dac, [64 127 240], 'uint8') command. The variable 'dac' stores the MCP4725 DAC's I2C address. I found this function from https://uk.mathworks.com/matlabcentral/ ... =srchtitle

However, I dont know the relationship between [64 127 240] and the DAC's voltage output (). Why is this array sent to the DAC?

Any help is appreciated.

Re: MCP4725 Digital to Analogue Converter + MATLAB

Posted: Fri Aug 19, 2022 2:44 pm
by sj_remington
What does the Matlab documentation for that function state?

Re: MCP4725 Digital to Analogue Converter + MATLAB

Posted: Mon Aug 22, 2022 4:56 am
by khemzi
Hi,
This is the link for the write function: https://www.mathworks.com/help/supportp ... write.html. It explains how to use ghe function to write to i2c devices. Again, the connection is successful, I’m just not sure what the three columns in the array are individually responsible for.

Re: MCP4725 Digital to Analogue Converter + MATLAB

Posted: Mon Aug 22, 2022 4:57 am
by khemzi
*the

Re: MCP4725 Digital to Analogue Converter + MATLAB

Posted: Mon Aug 22, 2022 10:46 am
by sj_remington
The Matlab documentation could be better, but in this call:

Code: Select all

write(myi2cdevice,data,dataPrecision)
"data" can evidently be a vector, so the argument "[64 127 240]" should write those three decimal values to the DAC.

An interesting but unanswered question is "how quickly does it write those values?", which you could determine by connecting an oscilloscope probe to the DAC output.