LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter Input - Count Rising AND Falling Edges

Solved!
Go to solution

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.

0 Kudos
Message 1 of 4
(1,798 Views)
Solution
Accepted by jrdwight

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

-------------------------------------------------------
Control Lead | Intelline Inc
Message 2 of 4
(1,781 Views)
Solution
Accepted by jrdwight

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

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 3 of 4
(1,574 Views)

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.

0 Kudos
Message 4 of 4
(1,123 Views)