LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronous AI, AO and DI - Trying again!

Solved!
Go to solution

Hello LabVIEW community - I back to working on this problem of trying to get LabVIEW to measure three AI channels, output one AO signal and measure the digital inputs on four lines all at the same time and frequency.  I can ge the AI and AO tasks to start from the same trigger and run simulaneously but when I try to also start the DI task off the same trigger it says something like "Specified property is not supported by the device or is not applicable to the task" (error -200452).

 

The equipment I am using consists of: cDAQ 9172 chassis,
  • 9401 DIO module (slot 1) - four DI lines I'm trying to measure
  • 9401 DIO module (slot 5) - line 0 is what I am usign as the start trigger signal
  • 9239 AI module (slot 6) - want to measure 3 channels of signals
  • 9263 AO module (slot 3) - want ot generate one channel of output
  • 9481 Relay module (slot 2).

I have included the guts of what I'm doing in the attached VI.  I specifically purchased the second 9401 module and put it in slot 1 because previously I was trying to read the four lines on the same module in slot 4 which is apparently verboden (can't use the same module for triggering and measuring at the same time).

I have a feeling I don't have the right trigger signal or clock selected for properly triggering the DI task.  Any thoughts on how to get around this or am I trying the impossible here?

Message 1 of 15
(6,937 Views)

Do you have a counter available that you could use as an external clock source for all three tasks?  I haven't worked with the cDAQ hardware much -- I've worked with a lot of PCI-based and USB-based DAQ hardware and have successfully synchronized multiple devices.

 

I presume that you have looked at the multi-device synchronization examples that ship with LabVIEW?  If not, have a look there first.

 

If you have a counter available, you can do the following:

 

1.  In LabVIEW, set up your counter as the clock source.  You will need to check your device's specification to find out what the default output terminal is for your counter.  Look at the "Gen Digital Pulse Train -- Continuous" example that ships with LabVIEW in order to find out how to set up a counter as a pulse train source, if you don't know already. 

2.  Physically connect the counter output terminal to appropriate external clock source pins on your AO, AI, and DIO devices.  (usually one or more of the PFI pins).  You will have to check your devices' specs to determine which PFI pins will be the appropriate ones.

3.  In LabVIEW, specify the clock source for each task as the appropriate PFI pin.  Set "DAQmx Timing" to "Sample Clock" and then set the source to whichever PFI pin is connected to the counter output.  Meaning, if you have the counter output pin connected to PFI10 on, say, your AI board, right-click on the "Source" terminal of "Sample Clock" and choose PFI10 on the AI board.  That will tell your AI task to look there for its clock source.  Do the same thing for your other two devices.

4.  Start your tasks.  Make sure you start your counter task after you have started the other three tasks.  The other three tasks won't start until they see a clock source.  By starting your counter task last, you ensure that all three of your other tasks start simultaneously.

 

Make any sense? 

Let me know if this helps at all,

d

Message Edited by DianeS on 02-22-2010 08:19 PM
Message 2 of 15
(6,926 Views)

Hi MJHanagon and Diane,

 

Actually the cDAQ Chassis will act just like one large DAQ card.  What Diane suggested is definitely one way of how you could do it if you had multiple devices that you had to synchronize.  It would also work in this case, but is a little more complicated and there is an easier way.

 

Since the compact DAQ chassis behaves like one large DAQ card, you can actually just set the DI and AO tasks to use the AI sample clock as their sample clock source.  This will be routed internally and therefore not requir any external wiring. You will configure the AI task and the AI start trigger, but you will actually start the AI task last.  DI and AO will have the DAQmx timing VI configured to have the same rate as AI, and then to use the ai/SampleClock from your AI task.

 

The DI and AO tasks do not need a start trigger, but rather will be armed as soon as the start task VI is run.  After they are armed, on every pulse of the AI sample clock pulse, DI will take a sample, and AO will output a sample.  This is why you have to start the AI task last, to make sure the other tasks have already been started and will be ready to receive sample clock pulses. 

 

See the attached VI, which was made by combining two examples from the NI Example finder.  Those examples were Multi-Function-Synch AI-AO.vi  and Multi-Function-Synch AI-Read Dig Chan.vi.

 

The attached VI synchronizes AI, AO, and DI.  You can definitely modify this for your application and put in your own channels, but the concept is the same. 

 

Good luck and post back if you have any questions,

Eric S.
AE Specialist | Global Support
National Instruments
Message 3 of 15
(6,895 Views)
Solution
Accepted by MJHanagan

I just found something wrong in my code (unfortunately simulated devices don't simulate things entirely accurately).

 

The DAQmx Timing Property node that I used to extract the Sample Clock Source will not work, because it returns the sample clock timebase, rather than the actual AI Sample Clock pulse train.

 

Therefore you have to either use a drop-down and manually select the AI Sample Clock of the Chassis, or use the Get Terminal Name with Device Prefix.vi.

 

Replacing that property node with Get Terminal Name with Device Prefix.vi is the only thing has changed in this code, 

Eric S.
AE Specialist | Global Support
National Instruments
Message 4 of 15
(6,883 Views)

Hi Eric and Diane - I tried your recommendation about sharing the AI sampling clock with the AO and DI tasks and it worked!!  I armed the AO and DI tasks first then start the AI task off a trigger signal and all three tasks are now singing in perfect sync!  It is rather fun watching all three function work perfectly together.

 

I went back to the 9172 user manual and reread the section on multifunction synchronization.  It now makes a lot more sense – it’s always much easier to read and understand these things after you have tried it!

 

Thank you very much for solving my little problem!

 

0 Kudos
Message 5 of 15
(6,852 Views)

Hi Eric,

 

I have a similar application I'm using

 

M series PCI 6251

 

4 AI lines 

2 DI lines that I want to monitor to get the time at which they turn high.

 

I tried your program, I'm confused about what trigger source should be used for my application? 

I tried onboard clock, Dev2/PFI0 both din't work.. Any suggestions will be very helpful..

thanks

 

 

0 Kudos
Message 6 of 15
(6,746 Views)

Hi palkin,

 

Are you trying to acquire on the 4 AI lines when a DI line goes high? Or are you trying to get the timestamp of when the DI lines go high?

 

What is making this different than your post here 

 

If you want to learn how to use change detection, check the knowledgebase article Using Digital Change Detection In DAQmx.

 

 

You're start trigger is going to be whatever digital signal you want to use to notify the start of your acquisition and start all tasks at the same time.

Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 7 of 15
(6,713 Views)

Hello,

 

 

I have a problem with the data aquisition. I have AI and DI that i have to read at the same time but i only have 1 clock and the cdaq doesnt support it. is there anyway to use a trigger or counter to make them adquire that at same time and btw i dont want to use any external clocks. Is it possible?

0 Kudos
Message 8 of 15
(5,784 Views)

Hi there,

 

Im developing a program that must adquire analogic and digital inputs at the same time( mA and freq). I have made an aquisition code without using the express function DAQ and it adquires sample by request. i adquire 1 sample and only after through error in it adquires the other signal. i want to use 2 express DAQ function to adquire my signals but i want them to adquire at the same time. The problem is that i only have one clock and i wonder if there is a way to syncronize both aquisitions. I dont want to use external clock's. 

 

I'm sending in anex my code.

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 9 of 15
(5,757 Views)

Hi asnaev,

 

What hardware are you working with? What version of LabVIEW are you working with?

 

There are some problems with your the way you have your data acquisition VI set up. I would suggest looking through some of the examples available to you in LabVIEW. From within LabVIEW, click Help->Find Examples from the top bar. There are some good examples for both analog input and counter input.

 

As for the synchronization between the two inputs, I suggest reading through Timing and Synchronization Features of NI-DAQmx.

 

Also, you posted in a thread that is a few years old. I suggest creating a new thread or finding a more recent thread next time you encounter an issue so that you put yourself at the best chance of being answered by both other customers and engineers at National Instruments.

 

David B.
Applications Engineer
National Instruments
0 Kudos
Message 10 of 15
(5,716 Views)