Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB-8452: Read FIFO Accelerometer

Hi everyone,

 

I have written a small program with which I can read an accelerometer via the FIFO with the help of the NI USB-8452 SPI interface.

That works pretty well so far and I can read out the X, Y and Z axes.

Now I wanted to know wheather I am really reading out all data (continuously) or whether I am losing data. So I put the accelerometer on a shaker (e.g. 60Hz) and lo and behold, I have jumps in the measures signal (sine).

 

I think it is because I close the reference every time in the while loop and create it again. In the "SLAVE CONFIG" subVI, a new script reference is generated at the beginning and the reference is closed in the main view of the block diagram (when determining the number of data in the FIFO and when reading out the FIFO).

 

I have already tried to remove the "SLAVE CONFIG" SubVIs and the "Close Reference" block after the while loop, but without success.

 

Attached are screenshots of the main block diagram and of the "SPI_Slave_Config" subVI.

 

Thanks in advance! I hope you can help me!

 

Download All
0 Kudos
Message 1 of 5
(1,467 Views)

As per my understanding, you're using script mode, in this mode, all commands within a script run are timed and clocked accurately, but between script runs the timing is completely determined by windows.

 

For example, the following could be the absolute time of sample read from accelerometer,

  • iter 0 - 0ms
  • iter 1 - 108ms
  • iter 2 - 160ms
  • iter 3 - 300ms
  • ....

You can observe that the sampling is not equally spaced and hence when you reconstruct the captured data as equally spaced, it will not be a proper signal.

 

If you need proper time domain reconstruction, you would need to use more advanced instrument like DAQmx, HSDIO, Digital Pattern which use precise timing.

 

Please correct me if I misunderstood your code. In addition, could you please share actual VI and the datasheet of the accelerometer?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 5
(1,448 Views)

These MEMS usually have a signal for timestamping/sync, something like a trigger in or a data ready.

However, in addition to the OS timing jitter, the internal MEMS clocking sometimes is not the best... https://doi.org/10.1051/metrology/201922003

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 3 of 5
(1,435 Views)

Yes I use the script mode, but currently not all actions are carried out with one script. I think that could be the mistake..

The error could be that I enable and disable the script several times in the while loop. With the SPI Script disable VÍ, all chip select pins are set to tristate status. Maybe SPI communication will be interrupted and data will be lost?

 

Do you really think it's the timing? The FIFO acts as a buffer. So it doesn't matter if something else happens in between, as long as the fifo isn't running at full capacity.

 

Attached the datasheet of the accelerometer and the LabVIEW project.

Download All
0 Kudos
Message 4 of 5
(1,418 Views)

And on this screenshot you can see the measured data of the axes. The z-axis should be a continuously sine but as you can see there are some jumps in it.

0 Kudos
Message 5 of 5
(1,407 Views)