Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Software trigger Digital In and Digital Out simultaneously

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)
0 Kudos
Message 1 of 4
(4,323 Views)

Hi toddber-

It looks like you're setting everything up correctly.  I'm assuming your writing values for your taskHandle_TRIG task as "0b0000, 0b1000, 0b0000" .  Is this correct?  Have you been able to monitor the states of P5.3 with an OSC to see if the signal is actually going high?  Because the operation of port 5 is software-timed, you should probably actually call the DAQmxWriteDigitalLines three separate times as there is no way to buffer output data and the pulse may complete too quickly to be recognized as a trigger.

Please try calling the write function three separate times with the binary values I suggested and see if you're able to get better results.  If not, please post your entire VBP so that I can take a look at how you're setting up the write buffers, etc.

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 2 of 4
(4,302 Views)
I tried a different method and I was finally able to get the solution to work.  The basic idea is that I exported the SampleClock from the digital output task to PFI6, physically wired PFI6 to PFI3 on the connector, and then used PFI3 as the signal for the StartTrigger for the digital input task.  So, when the digital output task is started, the SampleClock for that task triggers the digital input task across the PFI6/PFI3 lines.  I'll try your suggestion to use 3 consecutive digital writes just out of curiosity.  Thanks.
0 Kudos
Message 3 of 4
(4,300 Views)

Hi toddber-

Glad to hear you got it figured out anyway- let me know if you run into any other problems.  Thanks a lot-

Tom W
National Instruments
0 Kudos
Message 4 of 4
(4,299 Views)