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.

Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronisation of input and output using myDAQ

Hello!

 

I am currently using the NI myDAQ and use both analoge output. and both analoge inputs. The sampling rate needs to be as high as 200k Hz. (Also within the while loop I do quite a lot of data manipulation and saving into text files.)  My vi works generally fine, but I still have to problems:

 

1. How can I ensure that the read and write tasks are synchronised? I found out that it is not possible to use other trigger than the sample clock for write and read tasks using the myDAQ. (Is this right?) So as a workaround for me it is not important that the tasks start at the same time, but I want to ensure that the delay between "Start Write Task" and "Start Read Task" always is the same.  Is this possible? And how can I realise it?

 

2. If I want to generate a non periodical signal that is not constant, how do I best generate this? At the moment I use a Sine Waveform.vi with a frequency of 0 and I change the offset input with every loop. I also tried to use the FormulaWaveform.vi but with this my produced waveform seemed to stop after completing the "number of samples in the waveform". But the sampling info must be the same for both AO channels I use, so I cannot simply increase this number.

 

Thanks a lot for any help! Jules

0 Kudos
Message 1 of 4
(7,086 Views)

hi Jules,

 

If you only want to ensure that the delay between "Start Write Task" and "Start Read Task" always is the same, you can realize it with a simple while loop (with Wait Until Next ms Multiple).

But if you want to synchronize for example both analog input, you can see how it works in different examples. Following Path is shows you how to find these examples:

     In LabVIEW -> Help -> Find Examples... Brows(Brows according to Task): Hardware Input and Output -> DAQmx -> Synchronization -> "Analog Input Synchronizantion.vi"

 

To generate a non periodical signal that is not constant, you can change the offset input every loop. If you want to manipulate the offset while running you can also use local variables in the loop.

In this case you could manipulate for example with a slide control.

 

Regards,

grroesis

0 Kudos
Message 2 of 4
(7,057 Views)

Hi grroesis,

 

Thank you for the reply. I had a look at all the examples listed under > Hardware Input and Output -> DAQmx -> Synchronization -> Analog Input Synchronization. However, they don't work for the myDAQ device.

 

If I use the wait until next ms multiple, is it guaranteed, that within one loop all vi's are executed using the same time? I also tried using a stacked sequence, each for read and write task. For every sequence I used a wait until 200ms multiples. So for the two tasks, I expected to get a total loop time of 200ms(read) + 200ms(write)=400ms. But one loop took only 200ms. How can this be?

 

Regards, Jules

0 Kudos
Message 3 of 4
(7,054 Views)

Hi Jules,

 

Don't try it with stacked sequence - use the "flat sequence structure" - right-click on the frame -> add frame after - now put each task in one of these two frames and try it again. Don't forget the "wait until 200ms multiples" 😉

 

relating the while loop:

If you set the "right time" into the wait until next ms multiple, both tasks will be executed in every loop-flow. With the "right time", I mean minimal the time, which the tasks need to work.

 

Regards,

grroesis

 

0 Kudos
Message 4 of 4
(7,047 Views)