MCP4725 Digital to Analogue Converter + MATLAB

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
khemzi
 
Posts: 3
Joined: Fri Aug 19, 2022 9:30 am

MCP4725 Digital to Analogue Converter + MATLAB

Post 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.

User avatar
sj_remington
 
Posts: 500
Joined: Mon Jul 27, 2020 4:51 pm

Re: MCP4725 Digital to Analogue Converter + MATLAB

Post by sj_remington »

What does the Matlab documentation for that function state?

User avatar
khemzi
 
Posts: 3
Joined: Fri Aug 19, 2022 9:30 am

Re: MCP4725 Digital to Analogue Converter + MATLAB

Post 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.

User avatar
khemzi
 
Posts: 3
Joined: Fri Aug 19, 2022 9:30 am

Re: MCP4725 Digital to Analogue Converter + MATLAB

Post by khemzi »

*the

User avatar
sj_remington
 
Posts: 500
Joined: Mon Jul 27, 2020 4:51 pm

Re: MCP4725 Digital to Analogue Converter + MATLAB

Post 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.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”