From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

can NIDAQmx simulate synchronized analog input from two simulated devices?

Solved!
Go to solution

I would like to test synchronized analog input from two simulated NI6225 multifunction devices.  I have created two simulated NI6225 devices in Measurement & Automation (M&A) and labelled the first NI6225a and the second NI6225b.   In M&A, I created a RTSI cable configuration and added both of the simulated devices to it.  However, when calling NIDAQmx C functions in my test code, I am getting a error condition which suggests that the simulated devices are not synchronized.  Before proceeding any further, I would first like to confirm whether NIDAQmx is designed to

simulate synchronized analog input data from two simulated devices.  If not then this will explain the error condition I have encountered in my test code.

 

Thank you,

 

Ian

 

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

I B,
How are you determining that the two devices are not synchronized?

 

Keep in mind that simulated devices generate a sinusoidal at different phases depending on the channel. If you are noticing that there is an offset, this does not mean that they are not synchronized.

Jared A.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(3,425 Views)

To further elaborate, each channel within a task will return back a sine wave with a phase offset.  However, in your case would have to be running two separate tasks (M Series device don't support multi-device tasks).  Simulated devices do not simulate synchronization at all when you are sharing clocks or timebases between devices.

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 8
(3,420 Views)

Hello Jared,

 

I've worked with multiple synchronized devices in the past.  Each device always returns the same number of samples per channel at any given time.   In contrast, this does not occur when I ran test code on simulated devices.

 

Ian 

0 Kudos
Message 4 of 8
(3,416 Views)

Hello John,

 

I am not concerned about phase differences in simulated signals between devices.  I am only concerned that, at any given point in time, each simulated device returns the same number of samples for each analog input channel. 

 

As mentioned in my reply to Jared,  I have worked with multipled, synchronized, 'real/physical' NI multifunction devices in the past that are linked using a RTSI cable and programmed to share a common clock.  When synchronized, at any point in time, the total number of samples output per channel from each device has always been the same.   Is this what you are also referring to when you state that simulated devices do not simulate synchronization?

 

0 Kudos
Message 5 of 8
(3,412 Views)

I was thinking you meant the returned values.  The timing of when data is returned is going to depend a bit on how you are reading back the data.  Here are a couple examples:

 

1.  When asking for a specific number of samples per loop, even a simulated device will block the loop for the amount of time that it would have taken for your data to be available based off of the specified Rate (ignoring clock source).  The loop time should be approximately equal to (Samples to Read / Rate):

 

Read N Samples.png

 

 

 

2. When reading all available samples (-1), the simulated device is also able to give you the number of samples which is approximately equal to the expected number of samples that would have been acquired since your last read.  Here, the array size returned by the read should be approximately equal to (Loop Time/1000)*Rate (where Loop Time is in ms and Rate is in Hz).  Notice again that the clock source is irrelevant for simulated devices, but the specified rate does affect how much data is returned.

 

Loop time.png

 

 

Simulated devices do an OK job with simulating the timing of data, but they do this based off of your specified rate alone.  The purpose is to give a good idea of what the program might behave like, but simulted devices aren't always a completely accurate representation of real hardware.

 

Simulated devices do not accurately simulate timing when you are synchonizing multiple devices.  As we have seen, they do not use the sample clock input.  They also trigger immediately.  If you have two synchronized tasks, any amount of time between the start (in software) of each task will show up as a discrepancy in when the samples are returned (in case 1 above) or the number of samples returned by the first read call (in case 2 above).  Subsequent read calls (in case 2) should be more closely aligned, but they might not be exactly the same (this is also true for real hardware).

 

 

Since you mentioned that you are not getting the same number of samples between tasks, it sounds like you might be reading -1 samples.  If it is important to you to have the same number of samples, it would probably be better to specify the desired number when you call DAQmx Read.  Some people don't do this since the Read call will block until the desired number of samples have been taken.  There are ways around this as well (you can poll Available Samples per Channel or you can configure a DAQmx Every N Samples event).

 

 

If you have a specific example of what you are seeing and need help explaining it you can feel free to post a snippet which demonstrates how your tasks are configured.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 8
(3,404 Views)

Hello John and Jared,

 

I apologize for not responding sooner.  I will be able to get back and respond to you on Friday of this week. 

 

Ian

0 Kudos
Message 7 of 8
(3,373 Views)
Solution
Accepted by topic author I_B

Hello John and Jared,

 

If I recall correctly used to support synchonized simulated devices.   I've run different tests this week but all fail.  I am going to order/install a RTSI cable and test with physical devices. 

 

Thanks for you help.  I am closing this post.

Ian

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