LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx AI/DI Synchro and Trigger

Solved!
Go to solution

Hi all,

 

Hardware :

PCI-6224 (Simulated for now in MAX)

 

Inputs :

Up to 12 analog inputs at up to 2 kHz

1 Digital input at up to 2 kHz

1 Digital input for triggering

 

What I want to do :

I want the analog inputs and digital input to be synchronised.

I want both to start on trigger with another digital input.

I log them to TDMS files. This part seems to work fine.

 

For now I’m using a simulated PCI-6224 in MAX.

 

For the attached Vi, I want to be sure my data will really be synchronised with and without the trigger.

I started with ‘Voltage continuous Input’ example and this:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019PBVSA2&l=en-CA

 

-Are my Sample clocks sources right for synchronisation?

-In the Knowledge article, they put the trigger on the ‘slave’ task, I got an error when I tried this so I put it on the ‘master’ task, is it okay?

 

With the simulated DAQ, I seem to get the same amount of data in both files, but I can’t really test the trigger as all input instantly read something it seems.

I will be able to test it for real next week. 

 

Thank you,

0 Kudos
Message 1 of 4
(2,276 Views)
Solution
Accepted by topic author Patrem1

Hi Patrem1,

Your code definitely looks reasonable. What you're doing here is called "correlated DIO", which allows you to couple your digital task with another task.You can find a simple example of what this should like like here. You've capture all the salient features, but this example is still a really good reference.

 

To answer the questions in your block diagram:

1) Your sample clock inputs look fine.

2) Reading out the sample clock rate: the paradigm here is you're requesting a sample clock rate from the driver. The sample clock you use will essentially be a divided down version of some faster master clock. That division means you have discreet values you can actually hit. Any value you set here that isn't an integer multiple of the master clock from which it was derived will cause the rate to be coerced to the closest value that is. The property node lets your read out what the actual, coerced sample clock rate is.

 

And the other question about the knowledgebase article you linked

The knowledgebase has a different trigger set up that what you're looking for (I think). That trigger setup appears to be generating the terminal name for the ai start trigger which is generated when the AI task starts. This isn't an external trigger, it just gives the slave task the queue to start as soon as the AI task does. If you want both to start on some external signal, you should use an external trigger like you are. If you don't need an external trigger but just want them to start at the same time, just configure the digital slave task to trigger on the AI start trigger.

Regards,
Message 2 of 4
(2,252 Views)

Hi Andrew,

 

Thank you for your answer, 

 

I see what you mean concerning the clock rate. I realise I have the same thing happening with a camera frame rate I'm working with. 

 

I did not find this exemple while searching on this, good one.

Only difference is they use 'ai sampleclock' when I put 'Onboard clock'. 

I did a little testing and reading and realised it's the same. 

'For example, the onboard clock for the ai sample clock is the ai Sample Clock Timebase.'

 

I will be trying this soon I'm confident everything should work fine. 

 

0 Kudos
Message 3 of 4
(2,238 Views)

I should add here for anyone else who comes across this thread that for the case in which you don't need an external trigger, you don't need a trigger at all. Since the slave task is started first, it will be sitting idle waiting for its sample clock to be generated. If the master task trigger configuration is set to "none", the master will generate the sample clock as soon as start task is called, which is one reason you would want to start the slave task first and have it waiting on that clock. This will cause the two tasks to be synchronized by virtue of sharing the same clock.

Regards,
Message 4 of 4
(2,220 Views)