I'm trying to write code in Visual Basic 6.0 using NIDAQmx 8.0 that will trigger two tasks simultaneously. The two tasks are a Digital Output to ports 0-1 and a Digital Input to ports 2-3. I am able to perform the Digital Output and Digital Input tasks fine without using a trigger so I know that code works, but I can't figure out how to trigger the two tasks to start simultaneously. I always seemed to run into the error that the route can't be satisfied because the hardware doesn't support it or else I would just timeout.
In order to try code for triggering tasks, I wrote a separate program to just perform a Digital Output task to ports 0-1. In this program I try to use PFI2 as the trigger terminal for the Digital Output task. I physically wired PFI2 to PFI7 on the breakout box and then setup a separate task to drive PFI7 (port 5 line 3) high, which should have triggered my other Digital Output write to ports 0-1, but it always times out. I then removed the trigger task to drive PFI7, started my program and manually connected PFI2 to +5V. This triggered the Digital Output task. What am I missing? Why does it trigger when connecting PFI2 to +5V manually and not when PFI2 is driven to +5V by PFI7? Is there a problem with writing Digital Output for separate tasks consecutively? A sample of my code for this is below.
I have submitted a support request to NI a couple of days ago, but have not received much help yet.
' Create the DAQmx task for the trigger
DAQmxErrChk DAQmxCreateTask("TRIG", taskHandle_TRIG)
' Add channels to the trigger task
DAQmxErrChk DAQmxCreateDOChan(taskHandle_TRIG, "Dev1/Port5/Line3", "", DAQmx_Val_ChanForAllLines)
' Create the DAQmx task for Digital Output
DAQmxErrChk DAQmxCreateTask("DIG_OUT", taskHandle)
' Add a digital output channel to the task.
DAQmxErrChk DAQmxCreateDOChan(taskHandle, "Dev1/Port0", "", DAQmx_Val_ChanForAllLines)
DAQmxErrChk DAQmxCreateDOChan(taskHandle, "Dev1/Port1", "", DAQmx_Val_ChanForAllLines)
' Configure Sample Clock for digital output
DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "/Dev1/Dig0/SampleClockTimebase", 0.75, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_FiniteSamps, 4)
' Setup start trigger for digital output
DAQmxErrChk DAQmxCfgDigEdgeStartTrig(taskHandle, "/Dev1/PFI2", DAQmx_Val_Edge1_Rising)
' Setup the task for digital output
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle, 4, False, 10#, DAQmx_Val_GroupByChannel, writeArray(0), sampsPerChanWritten, ByVal 0&)
' Start the Digital Write
DAQmxErrChk DAQmxStartTask(taskHandle)
' Start the Trigger
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle_TRIG, 3, True, 10, DAQmx_Val_GroupByChannel, triggerBuffer(0), sampsPerChanWritten2, ByVal 0&)
' Wait until tasks are finished
DAQmxErrChk DAQmxWaitUntilTaskDone(taskHandle_TRIG, 10)
DAQmxErrChk DAQmxWaitUntilTaskDone(taskHandle, 10)