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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Chip Select Issue

I am using cRIO-9023 and Chassis 9112 with NI-9401 Digital I/O card for the SPI. I want to integrate the SPI GYRO sensor module but unable to make the Chip Select LOW. I am using the SPI_SINGLE_PORT_EXAMPLE have changed the RT controller to my desired controller and added the FPGA modules too. To start the SPI interface it is mandatory to make the CHIP SELECT  ACTIVE LOW so that the SCLK may be generated then a 8 bit data is written and then wait for the READ data, when communication is finished the Chip Select may go HIGH to end communciation.

 

I have read the document at URL: https://decibel.ni.com/content/docs/DOC-7945

 

but unable to make the chip select low, can somebody make me correction where I am making a mistake .

 

Thanks

 

Ather Iqbal

Download All
0 Kudos
Message 1 of 19
(3,649 Views)

Please check the 9104 I/O settings. You have to set the IO's direction either in the project settings (module properties) or in your FPGa code via property nodes.

I suppose your CS IO is set to input. So check that.

 

Hope it helps

Christian

0 Kudos
Message 2 of 19
(3,602 Views)

I have change the IO pin of CS. But unable to read the correct data, how to get the correct data, The device which I am communicating is a GYRO, I am writing data to the GYRO's register in Hex '0F' then 0 nad then makeing the CS high, but getting the same data or FF, which is not the correct form of data

 

Kindly help me out

0 Kudos
Message 3 of 19
(3,544 Views)

Hi Ather,

 

Since you are simply using a digital output module for this SPI communication, you can just invert the digital value that you are sending to the I/O Node in the FPGA code. If you look through the SPI example code that you linked above, there is a part of the FPGA code where they write the Chip Select State to an I/O Node to be outputted. You should just be able to invert the logic there to change from ACTIVE HIGH to ACTIVE LOW.

 

Regards,

 

Ryan

Ryan P.
CLA
0 Kudos
Message 4 of 19
(3,500 Views)

Don't know what the communication scheme of the Gyro is. I suppose you send a command and then you'll get the data. So you will need a communication timing between request and receive. What type of Gyro sensor is it?

0 Kudos
Message 5 of 19
(3,481 Views)

Its Pmod Digilent GYRO L3g4200d 

0 Kudos
Message 6 of 19
(3,462 Views)

I think you'll need level shifter. The Gyro has a 3V (Low voltage-compatible IOs 1.8 V) supply and the NI9104 works at 5V (needs 2V min for a high level signal).

0 Kudos
Message 7 of 19
(3,439 Views)

I've used voltage shifter IC, but I've uploaded the data sheet fot the SPI timing diagram reference

 

0 Kudos
Message 8 of 19
(3,414 Views)

I (and NI) recommend using this SPI driver http://sine.ni.com/nips/cds/view/p/lang/en/nid/210637

Have you connected an oscilloscope to look at the actual state of the lines? Can you get a capture of that data and post it? With the SPI implementation linked above, if I remember correctly you read and write concurrently, so if you need to write to the bus and then read from it while holding the chip select line active, then you need to include empty bytes at the end of data to write, which will then become the data you read.

0 Kudos
Message 9 of 19
(3,404 Views)

... or the Example you have started with fails to set the I/O direction when switching form read to write. If the output is tri-state ...

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 19
(3,398 Views)