Jump to content
  • 0

SPI Pressure Sensor - need help reading data


fr.bernardo

Question

Hello all,
I come from a mechanical engineering background, and I'm currently doing a PhD on fluid structure interaction. For this reason i have an experimental sloshing tank in which i want to read the pressure on the tank walls. Therefore i have bought a pressure sensor (Honeywell HSCDLNN100MDSA5). Relevant links below:
https://pt.mouser.com/ProductDetail/Honeywell/HSCDLNN100MDSA5?qs=Yk42LiOZU8S6l8LKiyP%2FCw%3D%3D
https://pt.mouser.com/datasheet/2/187/HWSC_S_A0012826924_1-3073319.pdf
https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/ja/products/sensors/pressure-sensors/common/documents/sps-siot-spi-comms-digital-ouptu-pressure-sensors-tn-008202-3-en-ciid-45843.pdf

I have never done anything with digital sensors but i thought it shouldn't be very hard. Also i have at my disposal a brand new Digilent Analog Discovery 2.
Now i cant for the life of me understand how i can read pressure values using the waveforms software, i have read tutorials and guides, and i think i understand the basic principals of SPI interface, but i dont know how to actually read and create files with pressure over time.

I have it connected as such (table is the pins of the sensor, it is the SPI variant):

imagem.thumb.png.5599f639542a1efd69c0919fea1d41a2.png

Sensor -- AD2


pin1 -- GND

pin2 -- V+ (set at 5v on the supplies tab of waveforms)
pin3 -- digital i/o 0

pin4 -- digital i/o 1

pin5 -- digital i/o 2

And in the waveforms protocol section, i think i have it correctly set up as seen below, with DQ1 reading from DIO0, and DQ0 is irrelevant as this sensor doenst have any MOSI connection.

As can be seen in the figure, when i click 'execute' it reads information from the sensor, which i think is a good sign, but i dont know where to go from here. Can anyone indicate where i can learn to code a script to implement in the 'sensor' tab? the examples there dont really help much and ChatGPT hasnt been much of a help either.

imagem.thumb.png.9ba93c10f2722fd69f738a07688805c4.png

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @fr.bernardo

First see the examples in Custom and Help tab.
If this is working with your sensor and you need precise ~10 nanosecond level timing you can turn to Sensor mode.
Otherwise you can use Custom mode or Script tool for ~10 millisecond precision software timing.

image.png

image.png

Link to comment
Share on other sites

  • 0

Hi @attila,
Thanks for your help. i was able to write this script ith the help of chatGPT :
imagem.thumb.png.eb511015d8d09a495f2bbb2ce18b68c6.png

This doenst have errors, but the results being returned are not correct so I know it isn't really doing what i want it to be doing, but i can't really figure out what i need to code here.

Can anyone help me find some tutorials/guides for writing scripts in the waveforms environment? I don't really know how to convert the information coming from the sensor into useful information and how to write it to a file (.csv or .txt. or whatever really).

Link to comment
Share on other sites

  • 0

Hi @fr.bernardo

It should be something like this:

var reg = Read0(8,4); // read 4 bytes from DQ0, SISO,
var ss = reg[0]>>6;
var bd = ((reg[0]&0x3F)<<8) | reg[1];
var tp = (reg[1]<<3) | (reg[2]>>5);
if(ss!=0) return "SS"+ss;
return bd; // or scale it to unit

Link to comment
Share on other sites

  • 0

Hi @attila,
I got the code and sensor working with the following code, returning status bits, raw value and pressure data from 1 sensor.


imagem.thumb.png.8bff3db5f166e85b06bee00c622754eb.png

I now want to move towards applying the sensors to its final place and for that i want to learn 2 things:

  1. As the code is prepared it returns the pressure everytime I click on 'Execute'. I want to be able to press something and it starts recording to a .txt or .csv file for a given amount of time (30s for example).
  2. I want to connect up to 5 sensors at the same time and write information from all into the file mentioned above. From what i understand i can do this by sharing the the GND, Vsupply, MISO and CLK pins, and have a different Slave Select for each sensor, activating 1 at a time.

Can I do this in the 'Protocol Tab' under the 'SPI/Custom' tabs or do i have to use the 'Script' Tab or even some other software? If i can make this in the Waveforms software, where can i find an example of something similar working ?

Thanks in advance!

 

Link to comment
Share on other sites

  • 0

Hi @fr.bernardo

You can change the CS in SPI/Custom, but make sure to have pullup on these keep the unused ones idle, or you can control from Script tool the SPI and StaticIO.
You could also have common CS/CLK and separate MISO, supported only by SPI/Spy. In SPI/Custom separate calls are needed like with different CS, eventually calling ReadQuad for 4 sensors and unpacking the bits.

image.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...