Dead-zone for PWM velocity control?

Hi All

Next question. I have PWM control of my scooter hub drive wheels working, but with the ODrive being as accurate as it is, there doesn’t seem to be any concept of “stopped”. At the moment with my RC control sticks centered there is still a good chance the ODrive will register around 0.1RPM and if I left my robot alone for 10 minutes it would be half way across the room.

So, my question is where do I start with trying to add a dead-zone to the speed control in the ODrvie firmware. It should be pretty easy, something like:
If(requestedspeed > -0.2rpm and requestedspeed < 0.2rpm) then requestedspeed = 0

Unfortunately I am no C or C++ programmer and the source code is well over my head. Any suggestions at where I could start looking?

Obviously this would be best set as a configurable value, something like “minimum speed” under which the speed would drop to exactly 0.

Any advice would be appreciated.


Ok, I had a fresh look at it, and it looks like it would be possible to add at the same place that the velocity limiting is done in controller.cpp

Something like:

    // Velocity limiting
    float vel_lim = config_.vel_limit;
    if (vel_des > vel_lim) vel_des = vel_lim;
    if (vel_des < -vel_lim) vel_des = -vel_lim;

    // Velocity dead-zone
    float min_vel = 0.2f;
    if ((vel_des < min_vel) AND (vel_des > -min_vel)) vel_des = 0.0f;

Does that make sense?

Obviously it would be better to not use hard coded minimum speeds but for my use I can work with that.

Yes you can do that.

For the future, we should probably have an “input filter module” for things like stick mixing, deadband, and setpoint filtering. I added a feature request here.

Hi guys, is that feature already in the latest’s firmware? This PWM deadband would be very welcome as my RC car radio (with the wheel) has like about 2% accuracy when returning to zero. This will make motors creep at like .5 rpm and since the machine is tracked and 100kg they will start to warm up quickly and past 70 deg C all sorts of bad things start happening. A configurable dead band would be an absolute luxury.