05-19-2019 09:28 PM
Hello,
I'm trying optical measurement using avalanche photodiode (APD).
I created counting task on MAX and confirmed the task counted the pulse edge from APD correctly (i.e. if the signal is 1 MHz, the count value increased 1,000,000 /s).
However, when the task loaded to my CVI program, the task does not return the expected count value.
My program is like this:
qw=0.; GetCtrlVal (pnl_panelHandle, PNL_GATEFREQ, &gatetime); //gate time is read from the UI panel in ms. timeout = gatetime/1000 ; //convert gatetime from ms to s. DAQmxLoadTask ("CI0_TaskHandle", &CI0_TaskHandle); //load the MAX task. DAQmxStartTask (CI0_TaskHandle); //start the task. DAQmxReadCounterScalarF64 (CI0_TaskHandle,timeout, &qw, NULL); //read count value and pass it to qw. Delay(timeout*1.2); DAQmxStopTask (CI0_TaskHandle); //stop the task. return qw;
in the program, this counting is repeated.
This program returns very low qw value. For example, even if gate time is 1000 ms (thus timeout is 1 s), most of qw is 0 or 1.
When the bright light is irradiated to APD, qw value increases to ~30. So the program is working, but the maximum value is too low.
Is there any problem in my program? I'm not sure about it...
Solved! Go to Solution.
05-19-2019 10:44 PM
You are reading the count immediately after starting the task. I think you should put the delay before the read. Timeout value in the read function is not a gate. It is the maximum duration the function is going to wait for reading. It does not guarantee a waiting duration of 1.2 sec.
Is the task working as expected when you run it from MAX?
05-20-2019 06:11 AM
The program worked when putting delay function before the read function. I misunderstood about the read timing.
Thank you very much!
05-20-2019 06:23 AM
Nice, glad it worked. Please don't forget to mark my post as acceptable solution. Some other person might also benefit. Cheers..