Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to synchronize start of reading from DI and AI channels?

I am using a simulated NI-6251 device and DAQmx driver version 8.3. I am controlling the device through a C# program (through .NET support from the driver).

 

My objective is to synchronize start of reading from analog and start of reading from digital input channels. The code that I tried is given below:

 

1: Task task1 = new Task();

2: task1.AIChannels.CreateVoltageChannel("Dev3/ai0", "", AITerminalConfiguration.Differential, -10, 10, AIVoltageUnits.Volts);

3: task1.Timing.ConfigureSampleClock(string.Empty, N1, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, N1);

4: reader1 = new AnalogSingleChannelReader(task1.Stream);

5: Task task2 = new Task();

6: task2.DIChannels.CreateChannel("Dev3/port0", "", ChannelLineGrouping.OneChannelForAllLines);

7: task2.Timing.ConfigureSampleClock("ai/SampleClock", N2, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, N2);

8: task2.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("ai/StartTrigger", DigitalEdgeStartTriggerEdge.Rising);

9: reader2 = new DigitalSingleChannelReader(task2.Stream);

 

The code does not work, since line 8 causes an DAQ exception: “Specified property is not supported by the device or is not applicable to the task.” DAQmx help file shows that simulated devices support (non-hardware) timing. One thread on this forum mentions that triggering should be used for synchronization (URL: http://forums.ni.com/ni/board/message?board.id=170&message.id=214314&requireLogin=False). Another thread suggests simply starting reading of digital channels before starting reading of analog ones (URL: http://forums.ni.com/ni/board/message?board.id=250&message.id=8437&requireLogin=False). Since none of these two methods seems to work for me, does anyone have any suggestions how to synchronize (start of) reading of analog and digital channels in C#? Also, is there a way to check whether the readings started simultaneously?

 

Any suggestions will be much appreciated. Thanks!

 

0 Kudos
Message 1 of 2
(2,905 Views)
Hi Bogdan,

Unfortunately the MultifunctionDAQ boards do not have a start/stop or reference trigger for digital tasks.  While I was unable to find a C # example of synchronizing analog and digital input tasks, there is an ANSI C example that ships with the NI-DAQmx driver.  It can be found in the following directory:

\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Synchronization\Multi-Function\ContAI-Read Dig Chan\ContAI-ReadDigChan.c

This should be a good start in getting your application up and running because it will show the proper order of DAQmx function calls for this type of synchronization scheme.

Regards,
Andrew W
National Instruments
0 Kudos
Message 2 of 2
(2,874 Views)