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.
MCP4725 Digital to Analogue Converter + MATLAB
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- sj_remington
- Posts: 675
- Joined: Mon Jul 27, 2020 4:51 pm
Re: MCP4725 Digital to Analogue Converter + MATLAB
What does the Matlab documentation for that function state?
- khemzi
- Posts: 3
- Joined: Fri Aug 19, 2022 9:30 am
Re: MCP4725 Digital to Analogue Converter + MATLAB
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.
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.
- khemzi
- Posts: 3
- Joined: Fri Aug 19, 2022 9:30 am
- sj_remington
- Posts: 675
- Joined: Mon Jul 27, 2020 4:51 pm
Re: MCP4725 Digital to Analogue Converter + MATLAB
The Matlab documentation could be better, but in this call:
"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.
Code: Select all
write(myi2cdevice,data,dataPrecision)
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.
Please be positive and constructive with your questions and comments.