PID controlled motor controller (based on measured RPM instead of PWM)

Some Characteristics:

  • PWM input: -255 to +255 (where the negative range is reverse and the positive range if forward).
  • RPM range: 0 - 3000 (the encoder are mounted directly on the motors but a reduction will take place afterwards (using a timer belt) 3:1 to increase torque). After the gear ratio, the effective RPM will become 1 - 1000. But all calculations are done based on 0 - 3000!
  • Current sensing is done from 0 to 2000 mA (probably not necessary but worth to mention :slight_smile:

I know I can use PID with current RPM and desired RPM as input and simply map this to a PWM value. This is no problem if the load on the motors is constant (I am building an UGV so terrain properties change over time).

But when the resistance on the tracks increase more PWM needs to be delivered to reach the desired RPM. I know that taking the old PWM value and adding the PID part to it will work but I don't know if that is the best way to go?

So I thought that I might can use the current draw bu the motors.

Example:

  • The motors both rotate at 1000 rpm with no load going (mA value 200 mA) from 1000 to 2000 rpm takes relatively not that much extra PWM.
  • But what if both rotate at 1000 rpm with a load going (mA value 1000 mA) from 1000 to 2000 rpm takes more PWM (If the max RPM can actually be reached!).

So I thougt: what if I know the actual RPM and current value? Maybe I can optimize the PID algorithm with the extra data?

Maybe I first have to do some testing to see what really happens......

Cheers.