Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

sharing an analog trigger between tasks

Hello,

I have an oscilloscope-like application (ANSI C, E series boards) in which i wish to set a hardware analog trigger in an ai task using the "aichannel" option, not "PFI0", and then use that trigger to start a finite pulse generation on a counter. That counter's output is used as the the sample clock for the ai task. I set the counter as retriggerable, so that subsequent ai triggers generate another volley of pulses, and more data is aquired.

There are several questions that i hope you kind folks can help with.

1) can ai triggers occur after a convert has happened? once you start acquisition, is the trigger circuitry gone?

2)I think i know that ai trigger appears on the PFI0 pin. what i don't know is how to used that signal as the start trigger on retriggerable counter. Shouldn't the following work? I'm getting signal rounting errors.
DAQmxCfgDigEdgeStartTrig (counterTask, "/Dev1/PFI0", DAQmx_Val_Rising );
DAQmxSetTrigAttribute (counterTask, DAQmx_StartTrig_Retriggerable, TRUE);

3)like question #1, suppose i wanted to acquire from ADC0 and set an ai trigger on that same channel, so that when the data rose over a certain value, a counter could count it, while acquisition was occuring. Is that possible? Or do i have to use PFI0?

Thanks everyone, I very much appreciate you help.

Brady
0 Kudos
Message 1 of 4
(3,814 Views)
I thought that if i include some code and the error message, that might help.

Brady

code:

/*********************************************/
/*/ DAQmx Configure Code
/*********************************************/
DAQmxCreateTask ("analogInTask", &analogTask); /* Create a task for analog input */
DAQmxCreateTask ("couterOutTask", &counterTask); /* Create a task for analog input */

/* create an analog input channel named aiChannel */
DAQmxCreateAIVoltageChan (analogTask, ChanString.c_str(), "aiChannel", DAQmx_Val_RSE, -10.0, 10.0,
DAQmx_Val_Volts,"");

/* create the clock for my analog input task*/
DAQmxCfgSampClkTiming (analogTask, counterSource, rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, numSamplesPerTrace);

/*Configure analog input buffer*/
DAQmxSetBufferAttribute (analogTask, DAQmx_Buf_Input_BufSize, 5*numSamplesPerTrace);

/*Configure Hardware Analog Trigger*/
DAQmxErrChk (DAQmxCfgAnlgEdgeStartTrig(analogTask,"aiChannel",TriggerSlope,TriggerVal));
DAQmxErrChk (DAQmxSetAnlgEdgeStartTrigHyst(analogTask, .05));

/* create a counter output channel named coChannel */
DAQmxCreateCOPulseChanFreq (counterTask, counterChannel, "coChannel", DAQmx_Val_Hz,
DAQmx_Val_Low, 0, rate, 0.5);

/* create the clock for my counter output task*/
DAQmxCfgImplicitTiming (counterTask, DAQmx_Val_FiniteSamps, numpoints);

/*Route analog trigger on PFI0 to RTSI1 for use below*/
// DAQmxErrChk (DAQmxConnectTerms ("/Dev1/PFI0", "/Dev1/RTSI5", DAQmx_Val_DoNotInvertPolarity ));

/*Configure counter output Trigger*/
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (counterTask, "/Dev1/PFI0", DAQmx_Val_Rising ));
DAQmxSetTrigAttribute (counterTask, DAQmx_StartTrig_Retriggerable, TRUE);

/*********************************************/
/*/ DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(counterTask));
DAQmxErrChk (DAQmxStartTask(analogTask));
}

/*********************************************/
/*/ DAQmx Read Code
/*********************************************/
while( !Terminated )
{
DAQmxErrChk (DAQmxReadBinaryI16 (analogTask, Parent->NumPointsPerBuffer, timeout,
DAQmx_Val_GroupByChannel , readArray, arraySize,
&sampsPerChanRead, NULL));
0 Kudos
Message 2 of 4
(3,807 Views)
Analog (AI) Triggers do in fact 'keep happening' once converts start. The analog trigger circuit is a dedicated circuit. Once configured for use in a task, it continues to operate until the task is cleared.

To use an AI trigger repeatedly in a second task (your counter task), configure a Digital Edge Start Trigger for that task and set the Source to the /Dev1/AnalogComparisonEvent terminal (instead of "/Dev1/PFI0"). You have to right click on the Terminal I/O control and select I/O Name Filtering to Include the Advanced Terminals to see this terminal. The AnalogComparisonEvent signal is the output of the analog comparison (trigger) circuit. It is a digital signal.

To count the number of triggers that occur, create an edge counting channel and set the Counter Input:Count Edges:Input Terminal property to /Dev1/AnalogComparisonEvent.
Message 3 of 4
(3,801 Views)
Dear thyles -- Many Thanks to you, and what a speedy reply. I got it working with your help.

All the best,
Brady
0 Kudos
Message 4 of 4
(3,794 Views)