Cannot control MCP4725 on matlab (through the arduino)
Show older comments
I am having trouble controlling a MCP4725 DAC with Matlab (which is controlling the arduino hardware)
I have firstly made sure that the DAC does work by testing the triangle wave example from adafruit and reading the data off the analog pin.
However, when I use Matlab I find that sending a command to the DAC does not result in the desired output read on the analog pin. If I send command 64(*) then 4095, the output voltage remains at 0V. I am not sure how I am meant to send the commands to the DAC to result in the output I require. I have attached some of the outputs I received (I did try to adjust the size of the integer being sent to possibly improve it) Does anyone have advice on how the DAC control is meant to occur?
(I first cleared the arduino by sending it an empty sketch)
>>a = arduino('COM12','Mega2560','Libraries',{'rotaryEncoder','I2C'});
>> addrs = scanI2CBus(a)
addrs =
cell
'0x60'
>>dac=i2cdev(a,'0x60');
>> readVoltage(a,'A3')
ans =
0.0244
>> write(dac,64,'uint16'); %command = 64 for write command for DAC input
>> write(dac,4095,'uint16');
>> readVoltage(a,'A3')
ans =
0
>> write(dac,64,'uint8');
>> write(dac,0,'uint8');
>> readVoltage(a,'A3')
ans =
0.0098
>> write(dac,64,'uint8');
>> write(dac,255,'uint8');
>> readVoltage(a,'A3')
ans =
0.0098
>> write(dac,64,'uint8');
>> write(dac,4095,'uint16');
>> readVoltage(a,'A3')
ans =
0.0098
(*) I got 64 from the binary '01000000' (bin2dec('01000000') = 64) which would be the command required (figure 6.2 from the data sheet below) https://cdn-shop.adafruit.com/datasheets/mcp4725.pdf
1 Comment
mcan06
on 11 Dec 2018
Can u solve this problem? Actually when u write different integer values, u read different voltage values from Analog Input.
Accepted Answer
More Answers (1)
Zoey Bigelow
on 11 May 2022
0 votes
"I have firstly made sure that the DAC does work by testing the triangle wave example from adafruit and reading the data off the analog pin."
This is exactly what I am trying to do! Does anyone know where I can find that example??
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!