How can I program module ADS1115 with Arduino in Matlab?

조회 수: 7 (최근 30일)
daniela tovar
daniela tovar 2020년 2월 24일
댓글: Ahsan Sami 2022년 7월 6일
Hello! I am trying to program the module ADS1115 with Arduino in Matlab, I have reviewed these pages however I cannot understand how it works, has anyone managed to program? I have also tried this code and it does not give me an ADC value consistent with what the multimeter shows me.
My code is:
ar=arduino('COM4','Uno','Libraries','I2C');
dev = device(ar,'I2CAddress','0x48');
%dev = i2cdev(ar,'0x48'); % creates i2c device object
writeRegister(dev,1,51075,'uint16');
ADC=readRegister(dev,0,'uint16');
Volt=1.024*(ADC/65536);
disp(Volt)
pause(2)

답변 (2개)

Tom Rockett
Tom Rockett 2020년 3월 5일
Hi Daniela
What is the voltage value that your code is giving you? If it is a factor of two out from the true value of 1.024V then the problem is due to using the wrong measurement mode of the ADS1115. You can try to set up your circuit to do a differential measurement, which will have the full 16-bits of resolution.
Best regards,
Tom
  댓글 수: 3
Tom Rockett
Tom Rockett 2020년 3월 9일
Hi Daniela
If the value is random then that sounds like you are reading noise. I'm not sure what to suggest, other than checking all of the connections in your circuit.
Here is a photo of the circuit that I used, which is similar to what you are trying to achieve (apart from the voltage divider in my case). I hope this helps.
Tom
daniela tovar
daniela tovar 2020년 3월 10일
Hi Tom,
but what was your programming in matlab, I was connected the SCL and SDA to pins 4 and 5 of the arduino, so I see you connect it to the TX and RX. Truth?

댓글을 달려면 로그인하십시오.


Tom Rockett
Tom Rockett 2020년 3월 10일
Hi Daniela
I don't know where you've got TX and RX from, I haven't used them. What model of arduino are you using? The SCL and SDA pins on the ADS1115 are connected to the SCL and SDA pins on the arduino, respectively.
You can try replacing your writeRegister line with:
writeRegister(dev,1,37762,'uint16');
As this should enable the differential measurement (using pins A0 and A3 on the ADS1115). I suggest you follow my original example and read the ADS1115 data sheet (the section on the config register) to understand what difference this will make.
Best of luck,
Tom
  댓글 수: 3
Ahsan Sami
Ahsan Sami 2022년 7월 6일
Tom Rockett can u please help me in understanding how u design "37762" for both pins A0 and A3 and 51075 for only pin A0

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by