07-30-2023 09:40 AM
Hi Everyone,
I'm trying to receive data from USB 6001 and Arduino via visa at the same time, the loop is 50 hz due to daqmx and means on the data, the visa is upto 100 samples per second so there is a buffer in receiving visa data and there is a delay at presenting the visa data.
So how i can set the visa read rate the same as the loop rate or the same as daqmx sample rate? How to Synchronize the two sources of data visa and daqmx.
Attached VI
Thank you for helping,
Kareem
Solved! Go to Solution.
07-30-2023 03:26 PM
Your USB-6001 runs off a pretty accurate crystal clock, so I "trust" that you are getting 20 samples 50 times a second (given your sampling rate of 1 kHz). Arduino is definitely running on its own clock, and I don't know (and haven't done the research to find out) how accurate or precise it is.
Are you trying to make "control" decisions, or are you in "pure sample mode"? For example, if your DAQmx sample size was 1000 points, you would get points once a second, and could also ask the Arduino for all of its unread data once a second (at the same time you do the DAQmx Read, so you're doing your best to synchronize the data). You'll get 1000 points from DAQmx, and I don't know how many points from VISA, but you'll have a whole second to do whatever you need to do with both of them, and with the longer sampling interval, the possible "mismatch" between DAQmx and Arduino in sampling rate might be less "significant" (a VISA difference of one sample in 1 second is "smaller" than one sample in 20 ms).
The question comes at what point do you need to do things with both sets of data. You haven't described much about what you are hoping to accomplish. It might be that it makes sense with two such different sources to save the data in two distinct streams, combining them after-the-fact (and doing whatever post-acquisition fudging needed to "synchronize' their two clocks).
Bob Schor
07-31-2023 03:32 AM
Thank you Bob,
What I'm trying to do is to control the visa sampling rate same as in the loop rate, the data in live experiment so the two sources should be match in time, is their a way to read visa data in different controlled sampling rate without filling the buffer (just read when i want so i can integrated with the loop
07-31-2023 04:50 AM
Hi kareemab,
kareemab@post.jce.ac.il wrote:
What I'm trying to do is to control the visa sampling rate same as in the loop rate, the data in live experiment so the two sources should be match in time, is their a way to read visa data in different controlled sampling rate without filling the buffer (just read when i want so i can integrated with the loop
You cannot control the "sample rate" of your external device with VISA communication.
But you can place the VISA code into its own loop and put the read values into a notifier to always keep the most recent data.
In your other loop you can read from the notifier whenever you want and you will get the most recent value…
08-02-2023 02:54 PM
I tried the notifier and it works well, thank you for your support.