03-04-2013 05:29 PM - edited 03-04-2013 05:40 PM
I would like to acquire an analog signal and simultaneously measure the time from the beginning of the task
until the signal crosses some voltage threshold.
My idea was to start an AI and CIPeriod tasks simultaneously and to use an analog threshold
to stop the CIPeriod task (see below) but I am not sure about how to use the analog threshold circuitry
and connect the input signal .
I am using USB 6211 and NIDAQmx C.
Thank you for your help,
Gabriel
// AI Tasks
DAQmxCreateTask("Input Task",&InputTaskHandle)
DAQmxCreateAIVoltageChan(InputTaskHandle,"/Dev1/ai0","",DAQmx_Val_Diff,-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(InputTaskHandle,"",InputSamplingRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,InputLength);
// Timing task
DAQmxCreateTask("Timing Task",&TimingTaskHandle);
DAQmxCreateCIPeriodChan(TimingTaskHandle,"/Dev1/Ctr0","",minVal,maxVal,
DAQmx_Val_Seconds,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000001,4,"");
// Set start trigger of timing task
DAQmxCfgDigEdgeStartTrig( TimingTaskHandle,"/Dev1/ai/StartTrigger, DAQmx_Val_Rising );
// Set Analog Threshold to stop timing task ?????
// Start tasks
DAQmxStartTask(TimingTaskHandle);
DAQmxStartTask(InputTaskHandle);
// Read results
DAQmxReadAnalogF64(InputTaskHandle, InputSamples, Timeout,
DAQmx_Val_GroupByScanNumber, InputData, InputLength, &SamplesRead, NULL);
DAQmxReadCounterScalarF64(TimingTaskHandle,Timeout, &ResponseTime,NULL);
03-04-2013 06:47 PM
I found out that Analog Triggering is not supported by USB 6211.
1) Is it possible to use the properly amplified analog signal as a digital trigger to stop the timing task?
2) How should I proceed to modify the above code)
3) My signal varies from 0-5 V and I would like to stop the timing task when it is about 0.5V .Can somebody suggest a circuit?
Thank you,
Gabriel
03-06-2013 04:07 AM
Hi Gabriel
what about using Schmitt trigger circuit < http://en.wikipedia.org/wiki/Schmitt_trigger > to transform the analog signal into a TTL signal (setting your custom thereshold) and a Semiperiod CI task? With this settings the time measure you need correspond with the low signal time!!!
Unfortunately i use LabVIEW and not C, but the idea behind is exactly the same...what do you think about it?
Best