View speed and length measurement

I want to connect an encoder (1024 pulse per rev;A/A-; B/B-) to view speed and length measurement, length increases and decreases; like 0 - 500 meters, stop, 500 - 350 meters, stop 350 - 400 meters; stop, 400 - 0 meters Stop. How can I determine the (IN/OUT) direction? The encoder in question is a Kubler.

We have a tech note that covers this question.
Take a look at Doc #1823 ‘Using Quadrature Counters Technical Note.pdf’.
The module - assuming you have a SNAP PAC system - is the SNAP-IDC5Q.

Hope that gets you going.

Do we have updated Quadrature tech note for PR1.

My application is for belt speed of conveyor, pulse to distance calibration, speed monitoring and PID Process Variable Measurements.

Right now, I am still unsure the importance of setting the “channel feature” that is: Frequency vs Counter vs Quadrature Counter.

Also I am confuse on the PR1 manual, saying I need to asign it to a interger 32 vs 64.

Really appreciate your advice.

Thank you.

The quadrature details for use on EPIC are now in the groov EPIC users guide, doc 2267 (built into EPIC/RIO or find it on the website)
You will find it on page 197.

To answer your question: Use Frequency mode for finding the frequency of a single digital input.
Use a counter mode to find the pulse count on a single digital input.
Find the pulse count and direction using quadrature mode for 2 digital inputs, Phase A and Phase B, with an optional index input.

If you are using PAC Control the logic is the same for EPIC as SNAP.

If you can point me in the direction of where the guide mentions 32 vs 64 ints I can take a look, but I could not find it while reviewing the material on quad input types.

Thank you Ben for making it simple.

On the latter, I mixed up, my bad, I was reading to fast without digesting what I read… It was on the help command button on code editor. But Don’t mind.

I have encountered new requirement related to the subject.

How do you average a per second signal so that it does not fluctuate too much on screen?

My code is reading the speed of belt encoder per second. Thats is: reset, wait 1sec, count pulse, compute speed, repeat.

But customer wants to not show fluctuation, bumpiness of signal.

There are different ways to filter your input signal, a simple way:

out = (in * 0.1) + (out * 0.9);

Run that at whatever interval you like - in your case probably once/second. You can change the constants to balance between response and noise, just make sure they add up to 1.

1 Like

Thank you. I will do just this. Sounds straight forward to implement and will satisfy this requirement.

I applied belt speed to:
out = (in * 0.1) + (out * 0.9)

I think this method does not suit belt speed application. Because, changing actual speed 0 to 50 speed is fast.
But speed display is crawling…

I need something like, as long speed measurement is within +/- tolerance the display should remain steady. But when speed moves display also moves.

if (abs(fHMIBeltSpeed - fRealBeltSpeed) > fHMIBeltUpdateThreshold) then
  fHMIBeltSpeed = fRealBeltSpeed;
endif

You probably want to also have a special case for when it stops to set the HMI display to zero.

1 Like

haha :slight_smile: YES! Thanks. I marinated your code.

if (AbsoluteValue(fBeltSpeed_ipm_out - fBeltSpeed_ipm_in) > fBeltSpeedDisplayTolerance) then
  fBeltSpeed_ipm_out = fBeltSpeed_ipm_in;
  n0Ctr = 0;
else
  n0Ctr = n0Ctr + 1;
endif

if (n0Ctr > 20) then
  fBeltSpeed_ipm_out = fBeltSpeed_ipm_in;
  n0Ctr = 0;
endif
2 Likes