03-08-2024 05:13 PM
Is there any way to count both the Rising AND Falling edges for a counter input? If I can't do it programmatically, I'm thinking I'd need to wire the signal into multiple channels, and count Rising on one and Falling on the other, then add the counts from each channel together.
Solved! Go to Solution.
03-08-2024 06:42 PM
It depends if you use E series or M/X series. How to make E Series Counter to Detect Both the Rising and Falling Edges
03-09-2024 09:46 AM
Building on ZYOng's answer...
Many modern era NI DAQ devices will support change detection with a digital task which you can configure to respond to both rising and falling edges. Such changes cause a brief internal pulse of a signal known as the change detection event which you can then count with a counter. Conceivably, you could also just keep track of the total # samples acquired from the DI task you configured for change detection.
M-series, X-series, and many cDAQ chassis are among the devices that will support this usage.
But also, FWIW, the total count for both edges will always just be 2x the count for 1 edge, plus or minus 1 count. The only way to get a 2nd rising edge is if there was a falling edge in between the 2 rising edges. They always come in alternating pairs, so their counts can never be more than 1 apart.
My point is that in most circumstances, counting both edges *barely* tells you anything more than counting just 1 edge. Consider that and evaluate whether you have a situation that benefits from the extra work of counting both.
-Kevin P
03-14-2024 01:35 PM
Thanks ZYOng and Kevin! I tried it both ways, and both were successful:
1. Use a separate counter for each edge parameter (rising or falling) and add the counts together
2. Configure a DI task to detect state change and use an event structure registered to the state change event to count the state changes
For context, I'm using this VI as a coarse measurement of a motor's position. The motor outputs 16 pulses/rev with 50% duty cycle. So in this case, detecting both rising AND falling edges was advantageous because it increases the resolution from 16 to 32 segments per rotation.