Quote:
Originally Posted by jman4747
I've been working on a VI to read counts from an encoder and get direction. I was looking for general feedback on it. Also, what would be a good way to get the period between pulses for a speed calculation?
|
Every time you see a rising edge, take the difference between the current time and the previously stored time. Then store the current time over the previous to be used at the next rising edge. This difference is the period between rising edges. Then you can take a rolling average over a user-defined sample size to smooth out noise.
But how fast do you expect this loop to be running? Are you compiling this vi as part of an FPGA image, or will it run in software? Make a rough calculation of what the period of your encoder will be in your particular application, and make sure the loop containing this VI can keep up.