Hi!
I need to generate an N number of pulses based when I receive a storbe from my rate table. As I had my code before I was only generating 1 pulse and it was working fine, but now i tried to change it to be a variable number of pulses and now it gives me a Run-time error (-50103) saying that the specified resource is reseved when I try to start task gCTR5taskHandle which measures the time between rate table pulses (period counter). Could someone tell me how to fix it???
Anyw help would be much appreciated. ..Here's a snippet of the relevant code.
// Setup CTR-0 as DATA REQUEST CLOCK. Free Running Clock.
DAQmxErrChk(DAQmxCreateTask("",&gCTR0taskHandle)); // I create my task
/*I want to create the data request based on the rate table strobe. So, I create a channel which will generate a pulse on counter 0 with the _test_data_req (1024Hz) frequency. Instead of the _test_data_req variable the parameter Value used to be 1e6, now is 1024Hz set via the configuration file.*/
DAQmxErrChk(DAQmxCreateCOPulseChanFreq(gCTR0taskHandle, "/Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low, DELAY,_test_data_req ,DUTY));
DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(gCTR0taskHandle, "/Dev1/PFI19",DAQmx_Val_Falling )); //I want to trigger the generation of the pulses by the falling edge of the rate table strobe (available in PFI19)
DAQmxErrChk(DAQmxSetTrigAttribute(gCTR0taskHandle,DAQmx_StartTrig_Retriggerable,1)); //It’s retriggerable based on if the task is running and if the strobe is obtained
/*The number of pulses I want to generate each time the strobe is obtained used to be 1, but now we need to generate 32 pulses (32 data requests) per each RT strobe(now defined through the configuration file)*/
DAQmxErrChk(DAQmxCfgImplicitTiming(gCTR0taskHandle, DAQmx_Val_FiniteSamps, _test_int_num));
…
// Setup CTR-5 as TIMESTAMP STROBE timer
DAQmxErrChk (DAQmxCreateTask("",&gCTR5taskHandle));
DAQmxErrChk (DAQmxCreateCIPeriodChan(gCTR5taskHandle,"/Dev1/ctr1","",0.000001,25,DAQmx_Val_Seconds,DAQmx_Val_Falling,DAQmx_Val_LowFreq1Ctr,0.000001,4,"")); //This task I want to measure the period of the RT strobe ( the time between falling edges of the strobes)
DAQmxErrChk(DAQmxSetChanAttribute(gCTR5taskHandle, "", DAQmx_CI_Period_Term, "/Dev1/PFI19", 1)); //My strobe for axis 1 comes in on PFI19
DAQmxErrChk(DAQmxSetChanAttribute(gCTR5taskHandle, "", DAQmx_CI_CtrTimebaseSrc, "/Dev1/PFI0", 1));//My 10MHz clock comes in at PFI0
DAQmxErrChk(DAQmxSetChanAttribute(gCTR5taskHandle, "", DAQmx_CI_CtrTimebaseRate, 1e7, 1));//My clock if 10MHz
DAQmxErrChk(DAQmxSetChanAttribute(gCTR5taskHandle, "", DAQmx_CI_DupCountPrevent, TRUE));//This is set in the event where no clock ticks are measured between the RT strobe pulses, to use the internal 80MHz to measure the time (0) instead of having it give me a timeout(receiving an exception that no click pulses were detected between RT strobes