HSC pressure sensors via SPI Arduino
6 次查看(过去 30 天)
显示 更早的评论
Hi! Does anyone know the robust way of connecting Honeywell HSC pressure sensors via SPI and Arduino board?
Suggested here SPI interface supports only Aardvark and NI connections:
The idea is quite simple: to drop CS pin to 'low' and read just four (4) bytes of data from MISO (there's no MOSI at all) and then close connection.
Cheers
0 个评论
采纳的回答
Arun Kumar
2019-6-11
Hi Viacheslav,
What I understood from your question is that you want to read data from a SPI device using arduino.
To do this, you can use MATLAB Support package for Arduino Hardware.
Here is the link to download that:
And here is the link to the documentation of SPI communication on Arduino using MATLAB:
Hope this helps.
Cheers
2 个评论
Arun Kumar
2019-6-12
Hi Viacheslav,
Reading 4 bytes should not be any issue with arduino.
Refer this page for details:
You can read 4 bytes like this:
a = arduino;
dev = device(a,'SPIChipSelectPin','D10');
dataOut = writeRead(dev,zeros(1,4));
更多回答(2 个)
Viacheslav Sedunin
2019-6-14
1 个评论
Arun Kumar
2019-6-14
Hi Viacheslav,
The random values could be because of wrong clock speed. Can you check the SPI clock speed supported by your sensor and the SPI clock configured in matlab.
For decoding values from two bytes, you can use the code below:
msb = bitshift(bitand(byte1,bin2dec('111111')),8); %Extracting only 6 bits and shifting it by 8
lsb = byte2;
out = bitor(msb,lsb);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!