LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what does the clock rate mean in SPI demo?

spi.png

 

hello,

I try to read the accelemeter data through SPI with NI9401 in cRIO. But I don't konw what does the clock rate mean at SPI WRITE/READ.

I want to set the sample rate 500Hz, what should I do?

English is my second language, excuse my poor english writing skills.

Thank you!

0 Kudos
Message 1 of 8
(3,161 Views)

500hZ is rather slow for SPI. read the specifications for the accelerometer to find out what speeds it supports. 

 

SPI has two wires, Clock and Data.  Data is written and read on the Clock rising edge.  The clock rate controls the rate of the clock ( which should be fairly straightforward) and, hence the data transfer rate in bits per second 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 8
(3,156 Views)

Thanks for your reply. I thought the clock rate contorls the rate of the clock before, but when I change the clock rate to 1000000(means 1Mhz),  each read loop costs about 120ms. It is too slow. however, when I change the clock rate to 20(means 20Hz ),  something very strange is happened, each read loop costs about 2ms! So, I doubt the clock rate is not the SPI clock rate.spi.png

 

 

this is my Labivew code. At first, set the SPI confisguration. and then read the data using a while loop. 

Thank you! I'm looking forward to you reply.

0 Kudos
Message 3 of 8
(3,123 Views)

That is hard too read.

 

Could you post the code as a snippet?  Menu edit create snippet.  I'll get to my PC in the morning.

 

Androids are less capable.

 

2017 is the latest I have.   Back save if you please.   

 

Someone else might solve I st in the meantime.


"Should be" isn't "Is" -Jay
Message 4 of 8
(3,110 Views)

Thanks for your reply.spi.png

 

 

This is the snippet. It is 2017 version.

And the accessory is my all code. My goal is to get LSM6DS3 data through SPI bus, the sample rate is about 500Hz (2ms each loop). 

Thank you very much!

Best wishes.

0 Kudos
Message 5 of 8
(3,104 Views)
I uploaded my code already. This problem bothered me long time. Could you give me some advise? I use the SPI and I2C driver API. http://sine.ni.com/nips/cds/view/p/lang/zhs/nid/210637 Thank you very much.
0 Kudos
Message 6 of 8
(3,085 Views)

Posting via phone so I can not open the snippet but, my 8-Ball is highly calibrated. 

 

~~~Is tianci really trying to update that many charts with scalar values every iteration?~~~

 

Answer.  Yes, and that is insane!

 

Time to break the coupling between acquire and  display.  Any producer consumer system will allow the acquisition to go fast and it really is  crazy to update 5 charts at anything faster than the eye can see.... jam the readings in a single queue as an array of integers then defer FP Updates, and flush the queue no faster than 20hz, index the rows (channels) scale and write the charts then in defer updates to the front panel.   It isn't the  communication that is slowing you down.  It's the redrawing of all those chart graphics 1 at a time and sequentially for each scalar value.

 

Get rid of the tab container too.  It makes charts overlap and forces all overlapped charts to redraw for any update

 

I Hate Tabs.  Use a sub panel instead.  For an example search my tags for the tag I Hate Tabs

 

Yes my 8-Ball magic told me, "With that many charts, you can put money on the developer having overlapped indicators and a tab container.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(3,075 Views)

hello, 

Thanks for your reply. I try the producer consumer system, however,  it is useless. I even deleted all those chart graphics, the time delay is also too long. 

Now, I don't know what should I do. I want to get the real-time data from sensor through SPI bus in a high sample rate. This bothered me long time.

And the date read from sensor has much niose. spi.jpg

 

 

 

I try to get data using Arduino through I2C , and the data is right.spi arduino.jpg

 

 

could you give me some advice? 

Thank you very much.

0 Kudos
Message 8 of 8
(3,060 Views)