12-10-2021 06:00 PM
Hello, I'm struggling to find a way to measure speed from encoder using linx and arduino.
I have connected encoder and I can detect both A and B encoder signals (no need in Z index)
Using Linx on arduino nano i'm getting on/off signals, but cannot figure out how to convert to speed
The task is simple, but cannot figure out the proper way.
Please advice.
Thanks a lot
12-12-2021 12:08 PM - edited 12-12-2021 12:09 PM
If you know how many pulses there are in one revolution of the shaft.
Try counting the number of pulses during a defined time period and use some math to calculate RPM.
Also I think the Z (index) on an encoder like this would give you one pulse per revolution.
Try counting the number of Index pulses during a defined time period and use some math to calculate RPM.
12-12-2021 12:13 PM
Thought about, but my problem is the speed is crazy low. I will not get a full turn every time.
But i'm working now on calculating RPM
Going to use elapse time for one sec with reset and calculate pulses I got during this time.
I thought there an easy way to do it, without building own counter. Something like DAQ frequency measurement.
Again, thanks.
12-12-2021 12:24 PM - edited 12-12-2021 12:42 PM
@alexela wrote:
Thought about, but my problem is the speed is crazy low. I will not get a full turn every time.
But i'm working now on calculating RPM
Going to use elapse time for one sec with reset and calculate pulses I got during this time.
I thought there an easy way to do it, without building own counter. Something like DAQ frequency measurement.
Again, thanks.
Well you are basically making a frequency counter and you could start with an example program that does that. But the math will still have to change because you have to relate the number of pulses to rotational angle to know if you have made a complete revolution.
I just ran across this: How are encoders used for speed measurement?
Pulse counting
Pulse counting uses a sampling period (t) and the number of pulses (n) that are counted over the sampling period to determine the average time for one pulse (t/n). Knowing the number of pulses per revolution (N) for the encoder, the speed can be calculated.
ω = 2πn/Nt
Where:
ω = angular speed (rad/s)
n = number of pulses
t = sampling period (s)
N = pulses per rotation
Pulse timing
With the pulse timing method, a high-frequency clock signal is counted during one encoder period (the pitch, or interval between two adjacent lines or windows). The number of cycles of the clock signal (m), divided by the clock frequency (f), gives the time for the encoder period (the time for the encoder to rotate through one pitch). If the encoder PPR is denoted by N, the angular speed of the encoder is given by:
ω = 2πf/Nm
Where:
ω = angular speed (rad/s)
f = clock frequency (Hz)
m = number of clock cycles
N = pulses per rotation
At high speeds, there may be too little time between pulses for pulse timing (also referred to as pulse frequency) to accurately measure clock cycles, so this method is best for low speed applications.