08-16-2021 03:41 PM
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!
08-16-2021 09:37 PM
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,
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?
08-17-2021 04:00 AM - edited 08-17-2021 04:07 AM
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
08-17-2021 02:41 PM
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.
08-18-2021 04:32 AM
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.