Components

cancel
Showing results for 
Search instead for 
Did you mean: 

[Deprecated] SPI Digital Waveform Library

Hello Priyatham,

 

Here is some basic code that will do what you need, if your data is perfect.


Binary Byte Array to Byte Array.png

  1. This simulates a byte array similar to the output from my previous example.
  2. This converts a byte array of 0's and 1's to a binary array.
  3. This is where things get odd, because if your data isn't broken up correctly it will either drop bits at the end or corrupt the last byte. Make sure it is in 8-bit increments.
  4. Pulls out a single 8-bit block.
  5. Reverses the byte array because of the way LabVIEW converts byte arrays to integers.
  6. Convert the byte array to an integer and cast as an U8.

Again if your input array is not a multiple of 8 this will either truncate the last bits or create a corrupted last byte.

Regards,
Dan King

Message 141 of 200
(2,389 Views)

how to use it when my HS-DIO card (6535) should work as a slave on SPI? Then only MISO should be as an output. Should I use SS as an trigger for 'Dig out task'?

CLA
www.espotel.com
0 Kudos
Message 142 of 200
(2,231 Views)

Hello,

Does anyone have an example of a basic SPI Read waveform using SDW toolkit in half duplex?

Thanks!

R

0 Kudos
Message 143 of 200
(2,196 Views)

SPI.png

Hi I need to make the above digital waveforms for SPI communication but all lines are connected to DAQ PFI lines. I am using PXIe 6259 and they are connected to p2.0 to P2.3.

Now I have few questions:

 

1.Can I use PFI lines to read back DOUT?

2. I made the exact waveforms in LV (dt = 0.001 s).but I don't know what I need to do next? Do I need to write these waveforms to DAQ lines and synchronously monitor DOUT to read data? Is there any example to show how can I do this synchronous write/read for SPI comminication?

3. can I use the reference lib?

DIGITAL.png

0 Kudos
Message 144 of 200
(2,023 Views)

Hello Tintin,

 

First of all, you are going to have to change which lines you are connected to; M-Series DAQ cards can only perform hardware-timed DIO operations on Port 0.

 

If you are trying to perform SPI communication on your DAQ card the first thing I would check out is this whitepaper:

 

http://www.ni.com/example/31200/en/

 

It includes information on a reference design that helps you build your waveforms and links to reference applications for HSDIO and DAQ devices. This is going to be your best resource.

Regards,
Dan King

0 Kudos
Message 145 of 200
(2,017 Views)

Hi Dan

 

Thanks for your help. It was very useful. 

Could you pelase let em know if I can use the following sequence for 6259?

My other question is , as you mentieond I shoudl use port0 lines but do I need to output SCLK (clock ) as well or if I use internal clock then I don't need to output SCLK?

 

22.png

 

 

0 Kudos
Message 146 of 200
(2,012 Views)

Hello Tintin,

 

In the whitepaper it is assumed that you are creating the sample clock as part of your waveform, so it is generated along with SDO and !CS.

 

As for clocking, right below where you got that pic is this one:

 

Screen Shot 2014-02-25 at 12.36.18 PM.png

 

which shows the simplest way of using one of your onboard counters as a oversample clock for you SPI generation. So, if you want SPI traffic at 100 kHz you would set up your counter to generate at 200 kHz and then set up your DIO sample clock to be that counter's internal output.

 

So the physical channel of the counter would be something like PXI1Slot2/ctr0 and your clock source would be something like PXI1Slot2/Ctr0InternalOutput (Which you would have to right click on the clock source constant/control and choose I/O Name Filtering>Include Advanced Terminals to find).

Regards,
Dan King

0 Kudos
Message 147 of 200
(2,005 Views)

Dan . unfortuantely I can't use the port0 lines because it needs major changes on the board.Is it possible to manually for loop the data to send it bit by bit and then also read back  DOUT bit by bit.

 

so as you can see first I generate the waveform and then 1 write 1 row of boolean values to SCLK,MOSI and CS and then monitor DOUT. 

 

I also see                          

100 ns min SCLK high pulse width
100 ns min SCLK low pulse width      in the product manual for clock. If I want to send it in this way then is there any way to control timing?

 

w2q.png

 

loop.png

0 Kudos
Message 148 of 200
(2,001 Views)

Hello Tintin,

 

You cannot hardware-time any lines on a M-Series multifunctionDAQ board outside of Port 0. At this point your best bet (outside of a board redesign, which I know would suck) would be to software time the lines or make an inline adapter board.

 

Neither of these is an ideal option.

 

For software timing, the minimum times you mentioned probably wouldn't be too much of an issue. But it's going to depend on your device on how long an output data bit is going to stay high after a clock transistion. It MAY stay high long enough for you to read a static DIO line, but there is no guarunteee. The code difference is that you wouldn't be using any clock or writing multiple samples to the DAQ card, instead you would sequence writes and reads in a loop so that you are executing in the correct pattern.

 

The problem with this is that if you are using windows you can't really expect better than 10 ms of timing accuracy (in my experience), and if you let it run full out you are going to see variable performance based on Windows background processes. With this restriction you would be better off using LabVIEW Real-Time if you have it available.

 

It's definitely something to try, and it's better than the next option.

 

For the translation board, I'm talking about an inline PCB that direct connects most lines, but switches the problem ones over to Port 0. I understand that this takes extra time and money and that the software-timing option is a better bet, but I just wanted to bring it up in case software timing didn't cut it.

Regards,
Dan King

0 Kudos
Message 149 of 200
(1,981 Views)

Hello,

I would like to read a 3-axis digital accelerometer (STMicroelectronics LIS3LV02DL) using the SPI protocol. I'm wondering if it is possible to use the SPI Digital Waveform Library on my NI9403 together with the NI cDAQ-9178. I've read here http://zone.ni.com/reference/en-XX/help/370466V-01/mxdevconsid/digiocseries/ that for this combination of devices <<You can only do hardware timing in one direction at a time on a serial bidirectional module>>. What does it mean? How should I take into consideration this issue on the labview program?

Thank you so much.

Kind Regards.

 

 

 

Giovanni

0 Kudos
Message 150 of 200
(1,779 Views)