04-18-2006 05:57 PM - edited 04-18-2006 05:57 PM
Message Edited by cfgauss on 04-18-2006 06:05 PM
04-19-2006
04:10 PM
- last edited on
11-05-2025
03:38 PM
by
Content Cleaner
Hello cfgauss,
Have you considered using a counter input task rather than a digital input task for this operation? All digital I/O operations on the DAQCard-AI-16E-1 are software timed, meaning that you are basically taking a snapshot of the state of a digital line with each call to the DIG_In_Line function. The rate at which you can take these snapshots is completely dependant on your operating system and how fast it is executing the code. With a counter input task, you can perform a period measurement, which will compare the signals on a counter input line to a 20MHz reference clock onboard the device, resulting in a much higher accuracy measurement. Take a look at the following tutorial about period measurements with counters:
Developer Zone Tutorial: Period Measurement with a Counter
There are also text-based example programs showing how to program counter input applications installed in the C:\Program Files\National Instruments\NI-DAQ\Examples\Visual C\Ctr folder. Take a look at the program titled STCSinglePeriodMeasure.c.
I hope this helps.
Regards,
Travis G.
Applications Engineering
National Instruments
04-19-2006 08:33 PM
04-24-2006 10:29 PM
04-25-2006
06:05 PM
- last edited on
11-05-2025
03:39 PM
by
Content Cleaner
Hello cfgauss,
The code with the do-while loop in the example program is monitoring the counter to check if it is armed. When the counter is armed, within each iteration of the do-while loop, the NIDAQYield function is called in order to allow the program to process any system events. When the counter gets two rising edges, it performs its period measurement and the counter proceeds to disarm, which causes the do-while loop to stop executing.
As for your application, if I understand you correctly it sounds like you are generating the first rising edge from your DAQ device using the DIG_Out_Line function, and you are getting your second rising edge from an external source. You should have both these signals passing into the gate of your counter. For a period measurement, the internal timebase is used as the source of the counter, set using the function call:
Status = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_SOURCE,
ND_INTERNAL_100_KHZ);
and the two signals used for the period measurement should be passed into the gate of counter, set with this function:
iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_GATE,
ND_DEFAULT_PFI_LINE);
The terminal for the gate can be set to any PFI line, but in this case is set ot the default PFI line for the counter gate, which is device specific and can be found in the E-Series Help Manual (PFI9 for your counter 0 on your device). It sounds like from your post that you are connecting these signals to the source, rather than the gate, which could be your problem.
By the way, besides the example programs installed by the NI-DAQ driver, the best resource for programming with Traditional NI-DAQ in text based languages is the Traditional NI-DAQ (Legacy) C Function Reference Help, which you can find under Start > All Programs > National Instruments > NI-DAQ. I hope this helps!
Regards,
Travis G.
04-26-2006 06:42 PM