Advice on speed measurement/control and self balacing

Hi guys

I have dc motors with quadrature hall effect sensors (just using one channel for now) that at full speed have a tick about every 20 ms (per channel).

I want to be able to do speed control and later on maybe self balancing.

To get speed, if i use time between ticks, as the motor slows down, time between ticks becomes larger and larger, meaning two very small speeds can have very large time difference between them causing problems for PID control.

Ideally i would have something that measures the amount of ticks during a certain time interval (value proportional to RPM) but given that the encoder is slow this time interval would have to be large, resulting in a slow update frequency, which would difficult self balancing later on.

It seems my best option would be to measure time between ticks (polling or interrupt) and invert the value (1/x). This would give me true speed but this means going into floats which i would prefer to avoid for the sake of update frequency.However given that worst case scenario i would have to do the 1/x operation twice every 20ms this probably is not that bad.

Any thoughts?

Regards

If you plan to use this input to tell you about small changes to the motor position then you need to decide what sort of resolution you need in your motor position. If you want to use it to indicate the motor's speed, then you need to decide what range of speeds you need to support over what time scale. For example, if your sensor only produced one pulse per revolution then you would only be able to calculate the average speed over a complete revolution. How the Arduino detects that pulse and how you store it and so on is irrelevant at this stage because no matter what you do, you're limited by the signals available.

Your a timer or input capture.