How to measure speed, distance, direction and acceleration using encoders?

Hi All,
I want to measure speed, distance, direction and acceleration of a moving object. Is it possible to do it using an encoder? If possible, what type of encoder is better? Absolute or Incremental?
I did not find any relevant links for the same. Can you please provide some helpful links particularly for getting acceleration and direction while measuring speed and distance?

Do not cross-post. Other thread removed.

Depends on your budget and how precise it should be. I have been looking into the uBlox ZED-F9P which should be very precise but costs a lot of money.

But if it all doesn't matter, then a normal GPS, like a uBlox M8N should be fine.

Hi..
Thanks for your reply.
Sounds interesting.
But I'm interested in Encoders. Any solutions still?

What is the moving object?

An encoder can NEVER measure speed. You need to compute it based on distance traveled and the time to travel that distance.

Paul

Wheel encoders can be used to keep track of distance traveled, and from the change in distance with time you can calculate the speed and acceleration.

However, wheels slip (especially when the device turns), introducing significant errors.

Intruder195:
Hi All,
I want to measure speed, distance, direction and acceleration of a moving object.

Far too vague. What object? moving how? Distance to what? Object might be a football, truck, drone,
pet cat, person, or parcel in mail, or anything.

Hi,

You are not specifying any details in your application / problem but, regardless to that, let me offer to you some "light" on how to measure position, speed, acceleration using an encoder.
Starting from position measurement, using an encoder I assume you have found a solution to make it work a.k.a. measure the position. There are plenty of free codes to do this out there, so I assume you have what they just provide, the position ready served to you any time you ask for it (in "clicks", one click is 1/100 of a rotation for example, your encoder is providing this info)
About speed:
You can ask the position in time intervals (the longer the more accurate). Assume you store the time (millis()) on a variable (e.g. time_now) the position in another variable (e.g. pos_now) and use two more variables for the previous values of those, time_prev and pos_prev. your code should do:
pos_prev = pos_now;
pos_now = get_encoder_position(); // whatever call you do to get the position
time_prev = time_now;
time_now = millis();

having done this every X time interval you can calculate speed by the simple formula:
speed_prev = speed_now;
speed_now = (pos_now - pos_prev) / (time_now - time_prev);

and guess what, acceleration is:
accel = (speed_now - speed_prev) / (time_now - time_prev);

Units of distance may need a multiplying factor to convert to convenient units (e.g. from clicks to meters), that factor should be applied (multiplied) on position only at the first step or if last at all: position and speed and acceleration. The time is in milliseconds so they need to be multiplied by 1000.0 as well. Use floating point types (float variables) as much as you can.

Last, direction can be calculated if you measure two encoders simultaneously and then use atan2(speed1, speed2)

Hope I got you further
Jim
P.S. If you search for a great way to learn more around practical electronics and measurement techniques, I have written a nice book, Amazon.com that is just published, hopping to bring more people to the electronics creativity. In all cases come back with more details on your system (is it a X,Y system?)

@jfragos
Thanks for understanding my question and for your answer.
Very nice explanation.
I'll follow your steps and get back to you.

Intruder195:
@jfragos
Thanks for understanding my question and for your answer.
Very nice explanation.
I'll follow your steps and get back to you.

Good explanation given by jfragos,
For the direction, you can use an encoder with two channels A and B. You can determine the direction by verifying which channel is leading.