Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

USB 6501 counter

Is the USB 6501's falling edge counter only capable of counting up?

If so, is there any way around this in software? 

Ideally, I would like the counter to count up when a specified digital input is hi and to count down when it is low (essentially the 'externally controlled' counter mode). Aside from purchasing a different DAQ, do you have any suggestions for how to do this?

0 Kudos
Message 1 of 2
(3,714 Views)

Hello Alex D,

 

There isn't a "good" solution for this unless the edges you're counting are very slow.  Basically what you would need to do is use a digital input task and monitor your digital signal and then save a reference to the counter value when it changes values and manually subtract or add the change to your "real" counter value (By “real” counter value I mean a software variable that you use to hold the current value after you manually add or subtract counts from the hardware counter to account for counting in two directions—the hardware counter will always be counting up) I.e.  If you put a DAQmx read for both the digital line and counter in a loop you would read both, take the difference between the current counter value and subtract it from the value from the previous iteration and then add or subtract that from a numeric value that would represent your "real" counter value.

 

Pseudo code:

1.  Initialize "real" counter value to 0.

2.  Read counter and digital line.

3.  If digital line is high add the counter value change to the "real" counter value; if the digital line is low then subtract.

4.  Repeat starting at step 2—make sure you add the change in the counter value and not the actual counter value (subtract from previous iteration).

 

This will have error due to the software timing--if the digital line changes in between reads then all of the counts between the two reads will be counted in one direction.  If you're reading signals slow enough this may be a satisfactory solution, otherwise, as you've suggested, you will likely need to get a different DAQ card.

 

I hope this helps.  Have a great day!

 

Cheers,

Brooks
0 Kudos
Message 2 of 2
(3,699 Views)