LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-8451 SPI read

Hello,

I have been trying to develop a program that communicates via SPI. I am not interested in doing anything very complex, I would just like to pass some bytes from file to some shift registers (4 - 8 bit serial-in, parallel-out shift registers). I have so far been able to pass at least one byte at a time to one shift register, and I am now attempting to create a feedback system to check that the proper data is being transfered. I have so far attempted to use the SPI write/read vi which seems to be suitable for writing, but not so much for reading. I keep getting an error message that the SPI write/read vi requires to be connected at the write input line. What would I need to read data from a shift register using the USB-8451 SPI input line. Thanks.

Andre

I have attached the program below. It is functional and writes bytes from a file one at a time.


0 Kudos
Message 1 of 4
(2,898 Views)
Hello again,

Just trying to bump my original post so that someone can hopefully offer some suggestions. Again, I need to figure out a way to read serial data from a shift register using the SPI line on the above noted USB device. Any help would be appreciated. Thanks.

Andre
0 Kudos
Message 2 of 4
(2,867 Views)

Hi Andre,

To use SPI Write Read.vi, you will need to wire the write input line.  I recommend looking at the General SPI Read example in the NI Example Finder, to see how to wire the write input line to perform a read.  You can modify this example to incorporate shift registers.  Under the SPI Advanced palette in LabVIEW, there are DIO Read Port and DIO Read Line functions, if you want to work around wiring the write input.  I hope this helps!

Regards,

Rima

Rima H.
Web Product Manager
0 Kudos
Message 3 of 4
(2,855 Views)
I can't comment on the SPI VIs, but looking at your code I can suggest a couple of code improvements:
  • Your upper loop seems to be parsing the file and converting it into a 2D array. You can replace the Read From Text File and the entire loop with a single call to Read From SpreadSheet File. You might have a Rube Goldberg entry here.
  • Your bottom loops should be replaced with for-loops. This will allow you to auto-index the 2D array, eliminating the indexing that you're doing and the check for when to stop.

0 Kudos
Message 4 of 4
(2,853 Views)