Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i shorten the delay between trigger and analog output?

I have an application in which i am using DAQmxCfgDigEdgeStartTrig to pause my analog output until a trigger is received.  That works well, but i have a delay on average of about 300 ms or thereabouts and i was wondering if anyone could recommend things i could do to reduce the delay.   I remember reading another post that mentioned Windows might be the cause of the delay, which might be fixed by setting the application task priority to "Real Time".  I did try this and it didn't seem to have an effect on the problem. 
 
Here is a bit of code from my project.
 
DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "", SampleRate, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_FiniteSamps, UBound(WaveData))
DAQmxErrChk DAQmxSetBufOutputBufSize(taskHandle, UBound(WaveData))
DAQmxErrChk DAQmxSetWriteRegenMode(taskHandle, DAQmx_Val_RegenerationMode1_DoNotAllowRegen)
If (SetupFile.Trigger = False) Then
            DAQmxErrChk DAQmxWriteAnalogF64(taskHandle, UBound(WaveData) / (ChanNum), True, 10#, DAQmx_Val_GroupByScanNumber, WaveData(0),    sampsPerChanWritten, ByVal 0&)
Else
            DAQmxErrChk DAQmxWriteAnalogF64(taskHandle, UBound(WaveData) / (ChanNum), False, 10#, DAQmx_Val_GroupByScanNumber, WaveData(0), sampsPerChanWritten, ByVal 0&)
            DAQmxErrChk DAQmxCfgDigEdgeStartTrig(taskHandle, "/Dev2/PFI0", DAQmx_Val_Edge1_Rising)
            DAQmxErrChk DAQmxStartTask(taskHandle)
End If
 
Regards,
Gerry
0 Kudos
Message 1 of 4
(7,437 Views)

Hello Gerry,

If I am understanding the question correctly, you are seeing a 300ms delay between your digital trigger signal and the beginning of your analog output.  This does seem quite long (unless you specify it),  I would expect to see an extremely small delay (if any at all).  The triggering and timing is taken care of in hardware once you configure your task and start it, so it would surprise me greatly if Windows had anything to do with your delay.

I also cannot see anything that sticks out in your code.  Usually we configure the triggering after the timing and before writing to the buffer, but I tried this out on my computer and it still worked fine the way you have it. There also was no delay between my trigger and generating samples.  I did program in LabVIEW, but the calls to the driver were the same. I have a couple questions that may lead us in the right direction of the cause of the problem:

What hardware are you using?
How are you measuring the delay?
How much does the delay length change?
What is sending the trigger and how?
How long after you start the task is the trigger sent?
What are you trying to output?
Do you have any other tasks running at the same time?

Hopefully these answers will give me a better idea of what your program is doing and possible problems that could be occurring.

Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 2 of 4
(7,425 Views)
Neal -
 
I am using a PCI-6711 card, and i was measuring the delay with an oscilloscope based on when the trigger line reached a certain value.  Naturally, there would be some human error introduced with that method. 
 
The trigger is being manually sent by me operating a DC power supply.
 
As for the output, i am just output an analog voltage.
 
- Gerry
0 Kudos
Message 3 of 4
(7,402 Views)

Hello Gerry,

The way the trigger works with the DAQmxCfgDigEdgeStartTrig function is that it looks for the edge in order to detect the trigger.  This edge needs to fall within TTL specifications for level and rise time.  Because the required rise time is <50nS,  your DC power supply may not be providing a signal that is recognized by the trigger line. The change in logic level without the correct rise time could cause the delay you are seeing.

Many of our cards have an analog triggering configuration that may work better for your application.  This uses an actual voltage level and sends an internal trigger when that voltage is reached.  The 6711 does not have this functionality, but if you have access to a card that does, the function for this would be DAQmxSetAnlgEdgeStartTrigSlope.  There is a great explanation on this in the NI-DAQmx C Reference Help (Start»Programs»National Instruments»NI-DAQ). If you search for Analog Level Triggering it should be the article with the same name.  The functions should be the same in C as in VB6.

I would recommend using a specific digital signal (perhaps from your 6711 directly) to send the trigger just to be sure.  You can use a test panel in Measurement and Automation Explorer (MAX) to control the digital line and feed that output back into the trigger line.  You can open a test panel by right clicking your device:



I have a feeling this may be the source of the issue, if it is not, please post back and we can look at other possibilities.



Message Edited by Neal M on 12-19-2007 11:29 AM
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 4 of 4
(7,384 Views)