Interfacing ADS1115 with raspberry pi in matlab

6 ビュー (過去 30 日間)
Subash chandar
Subash chandar 2014 年 8 月 14 日
編集済み: Andres Ruvalcaba 2020 年 2 月 28 日
I am trying to get a signal sampled by ADC interfaced with raspberry pi via Matlab. The code is as follows,
mypi = raspi i2cadc = i2cdev(mypi,'i2c-1','0x48') act_val=0; for i= 1:1:1000 writeRegister(i2cadc,1,hex2dec('C3E3'),'uint16'); %single shot 860fps (Config register) while (value ~= 50147) % wait until the MSB of conversion register has changed) [value]=readRegister(i2cadc,1,'uint16'); end [value1]=readRegister(i2cadc,0,'int16'); %(conversion register) act_val1(i)=value1; act_val(i)=(value1*4.096)/32767.0; end figure;plot(act_val1); figure;plot(act_val);
My input signal is 50 Hz sine, I have configured the ADS115 at 860fps and i am reading the signal from channel A0. The signal which is read from the conversion register is just some random noise rather than the actual signal. I don't know what is the problem with the code, but hardware wise the connections are intact and correct. Kindly let me know the issue with this code.
  1 件のコメント
Andres Ruvalcaba
Andres Ruvalcaba 2020 年 2 月 28 日
編集済み: Andres Ruvalcaba 2020 年 2 月 28 日
Did you get this reading correlctly?

サインインしてコメントする。

採用された回答

Murat Belge
Murat Belge 2014 年 9 月 8 日
It is rather late but the issue with the original code is this line:
writeRegister(i2cadc,1,hex2dec('C3E3'),'uint16');
Datasheet for the device says that you need to send the high byte first followed by the low byte for the 16-bit register value. The code above does the opposite. The code should have been:
writeRegister(i2cadc,1, swapbytes(uint16(hex2dec('C3E3'))),'uint16');
Likewise, you need to do a similar transformation when reading the raw ADC conversion value from the conversion register. Look at my ads1115 class for details.
I posted a MATLAB class to read ADC conversion results from the ADS1115 here.
  1 件のコメント
neuromechanist
neuromechanist 2019 年 1 月 28 日
Your class for ADS1115 is awesome.
Thanks.

サインインしてコメントする。

その他の回答 (1 件)

Mohamed BOUTOUBA
Mohamed BOUTOUBA 2018 年 11 月 23 日
Hello everyone,
Please I have to read an analog signal using Raspberry so I bought a ADS1115 but unfortunately I do not have any idea how to use it ; Can anyone sent to me the matlab code or a blocunder Simulink to solve it; PLEASE :/
My email is : btba.med@gmail.com

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Raspberry Pi Hardware についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by