From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Read Only SPI Using the USB-8451

Solved!
Go to solution

Quick Breakdown: from left to right

 

Section 1: Task Configuration VIs - set up pressure sensor SPI control bits for two sensors.  CSI control bits.  MISO bits,  Shared SCLK line.

 

Section 2:  Master Repetitive Loop - enable CS Lines for both sensors

 

Section 3:  SPI Reader Loop.  Task is to read 32 bits, so we must generate 32 cycles of SCLK.  Cycle SCLK low.  Cycle SCLK high.  This cycle should push one bit out of the SPI MISO lines of the sensors, so perform two reads (one for each sensors).  Relay the read bits to the parsing structure.

 

Section 4A (Upper):  Disable the CS lines so sensors know to generate the next reading word.

 

Section 4B (Lower):  According to Honeywell documentation, parse 32 bit word into Status (2 bits), Pressure Data (12 bits), Temperature Data (6 bits), and Don't Care bits (5 bits).  Perform math to convert Pressure count to actual pressure reading (this varies by sensor, depending upon measurement span).  Display all of the above.

 

Section 5:  Write the data and computations to file.

 

     and finally, after leaving the master loop

 

Section 6:  Terminate the VIs.

0 Kudos
Message 11 of 13
(3,321 Views)

Hey thanks this code has been helpful, but I am a little confused on how you set up your task configuration VI's.  Did you create those using MAX?

0 Kudos
Message 12 of 13
(3,292 Views)

 >> I am a little confused on how you set up your task configuration VI's.  Did you create those using MAX?

 

It has been a while since I set that up, so I'm a little fuzzy on exactly how I came to put it togther.  However, I'm pretty sure I did not use MAX; I think I just used tiles from the Functions > Measurement I/O > NI-DAQmx > Data Acquisition pane of the tool pallet.  If I'm remembering correctly, I spent a lot of time trying to use the wizard to set this process up, but was never able to get it to work properly, so I was forced to do it entirely manually using the tiles as shown.

 

Doug G.

0 Kudos
Message 13 of 13
(3,286 Views)