11-17-2015 08:49 AM - edited 11-17-2015 08:51 AM
Hi - having a bit of a strange problem. I have some code that watches the signal on AI0 and start-triggers on that; it uses the measured frequency of that signal to record a single period of data on either one or multiple channels. So, if the signal is at 100Hz, I record either AI0 or several AI's for 10ms exactly.
I do this by setting up a start trigger with hysteresis; exporting this to PFI4; and using a low frequency counter to get the period. Then I use the same start trigger to initiate the actual voltage measurement.
With one channel, this works great. With two channels, it was working intermittently and oddly (worked with sine wave but not with square wave, for example) - - until I connected the second channel to the same signal! So, with AI0 set as the start trigger source, unplugging AI1 from the signal makes it sometimes fail, but it's not always triggering from AI1 because disconnecting AI0 makes it always fail! As best I can tell, when I add a second channel to the voltage task, the Start trigger is either occasionally reading off AI1, or it's somehow reading a combination. (AI1 is not shorted, so it reads as a deformed trace of AI0 with a time constant added.)
The trigger initiation looks like this (pseudocode):
DAQmxCfgAnlgEdgeStartTrig(waveformTask, "dev1/ai0", DAQmx_Val_RisingSlope, _trigVal + _deadBand/2.)); DAQmxSetAnlgEdgeStartTrigHyst(waveformTask, _deadBand); DAQmxExportSignal( waveformTask, DAQmx_Val_StartTrigger, "PFI4")); DAQmxStartTask(waveformTask);
And the frequency measurement:
DAQmxCreateCIPeriodChan(ct,"dev1/ctr1", "", minVal, maxVal, DAQmx_Val_Seconds,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000001, 4,"")
CLIFFS NOTES: When trying to trigger a 2-channel voltage task with a start trigger based only on channel 0, the triggering behaves oddly unless both channels in the task are connected to the frequency signal. Any thoughts would be very much appreciated, I'm ready to tear the last of my hair out!
11-18-2015 10:34 AM
Hi there,
What devices and environment are you working with and in?
Are you synchronizing these channels?
Also, you can try to use instead of a hysteresis start trigger, you can use a delay trigger. Explained here:
http://www.ni.com/example/25905/en/
Are you running multiple tasks on single channels? If so, are you remembering to stop and clear the tasks before starting the new ones?
- Bear
11-18-2015 11:37 AM
Hi,
Thanks for the response! This is with a USB-6251, Win7, C++. It's just a straight analog input, continuous sampling, 2 channels (for example), with the first channel also being set as an analog edge start trigger. I think I need the hysteresis (deadband) to deal with noise. It's just one task - it gets stopped to change the trigger value or deadband, then restarted.
BUT - as always - the plot has thickened. I noticed that simply grounding the second channel fixed the issue! After googling, it seems like reading unconnected channels can cause various issues - do you (or anyone else) think that an ungrounded, unconnected channel in the scan could cause a spurious or missing start trigger? I'm thinking that's the issue but I'm going to do some more research.
Thanks again!
11-18-2015 01:13 PM
I definitely think it could. That would effect the read on the channel and it explains the different signals being read because of the ramp up of the signals. I would definitely keep looking into it if you'd like more clarification.
Glad you got that figured out with hopefully all your hair!
-Bear