If I understand you right, you need three signals. 1-40kHz signal that resets the counter to zero; 2-asynchronous trigger that latches the current counter value; 3-some sort of a timebase (20MHz or so). This can be accomplished using position measurement. Using the Measure Buffered Position (NI-TIO).vi which ships with NI-DAQ, you can connect signal 1 (reset to zero) signal to the selected counter's default GATE pin (PFI38 for ctr0). Then using the gate specification (scroll left on the front panel) select another PFI for signal 2 (latch signal). Then you can use another counter to generate a 20MHz signal, which you can wire to the SOURCE pin of the selected counter (PFI39 for ctr0). For the encoder specification, select "two pulse encoder". A two pulse encoder coun
ts up on every A edge and down on every B edge. Since B is not connected to anything, the counter will simply count up. Also make sure to enable Z indexing. This should yield the desired measurements.