• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

PID control for speed limit on DM01?

polyglot

New here
Joined
May 17, 2025
Messages
6
Location
Adelaide Hills
I've just got a DM01 installed on my tandem and it's (mechanically) great. The control scheme has some shortcomings though, particularly wrt speed-limiting. For legal reasons, I need to have 25km/h speed-limiting enabled which would be fine except that it looks like the controller is using a PID loop to do the speed control.

I live in the hills, and when a tandem descends a big hill, it spends a lot of time at 35-60km/h and the integrator in the PID winds up. When I reach the bottom of the hill and start climbing, the motor gives NO assistance for up to 15s after my speed goes below the limit-speed, which in some cases had me slowing down to 10km/h while pedalling at full effort before the assist would come back on. The longer you've been going faster, the longer it takes before the controller realises that you're no longer overspeed and comes back on. There's also a minor mirror issue of the motor overshooting to 32km/h if you accelerate quickly, as the integrator is causing control lag.

As an engineer who very occasionally writes control firmware, this looks to me like classic PID behaviour when there is nothing to prevent integrator windup. I know that the motor has correct speed estimates because it appears on the display. Assuming (I haven't looked) that the firmware allowed me to change the Kp/Ki/Kd values on the PID, I don't think that would work correctly because a PID with Ki=0 will always have an output offset which will result in it limiting to the wrong speed.

IMHO the correct way to do speed limiting is for the power to taper across a speed range (e.g. 25-27km/h), using the instantaneous (or very slightly filtered) speed measurements. I think that's how Bosch works, and it is instantly responsive - power cuts off immediately when overspeed, and comes back immediately when underspeed. There are other ways of fixing it while retaining the PID code, e.g. by clamping the integrator as soon as the PID output saturates at either full power or zero power.

Is there any way in the menues to set speed limiting to be either a hard-stop based on speed, or a taper with respect to instantaneous speed, instead of PID?

Otherwise, does anyone have contact details for the to7 firmware developer? I can totally help fix this.

Edit: yes I have set Filter=0 on the speed menu, and changed the torque-sensor control from Safe to Sensitive. Neither of those prevents the integrator windup though.
 
Last edited:
I've noticed a similar issue on the DM02 running July 2024 firmware. Power doesn't resume when pedaling after coasting for a bit, and even the throttle doesnt work when this happens. However, the speed limits on mine are disabled because I don't like how rough they are, and I'm in PAS mode because my torque sensor is unresponsive.

I've found that when the motor fails to provide power after coasting, turning the cranks backwards a few turns seems to help. Once I start pedaling forward or use the throttle the power comes back on. I suggest you try that and see if it helps, because it could provide a useful clue about the issue.

As for changing the settings, all firmware updates after July 2024 have been locked down and require authorization from Toseven to access the advanced menus. This is true for both the DM01 and DM02. I've been through the menus before the lockout and have never seen anything related to PID parameters.

There is a very informative wiki that shows all the settings and explains what most of them do.

 
Last edited:
Thanks, I hope to get out tomorrow and will try the backpedalling thing.

The response I got from to7 was "update the firmware to latest" but I'm not very willing to do that because I don't think I will be able to properly configure the speed and power limits anymore.

Update: backpedalling doesn't change anything on my motor.
 
Last edited:
I don't have answer to your questions, not familiar with DM0x's either, but just curious whether it indeed is integrator windup

tandem descends a big hill, it spends a lot of time at 35-60km/h and the integrator in the PID winds up. When I reach the bottom of the hill and start climbing, the motor gives NO assistance for up to 15s after my speed goes below the limit-speed, which in some cases had me slowing down to 10km/h while pedalling at full effort before the assist would come back on. The longer you've been going faster, the longer it takes before the controller realises that you're no longer overspeed and comes back on.

If assist is turned off at the top of the hill & turned on near the end of descend (either by power switch or assist level or brake), uphill no-assist problem goes away?
 
I don't know about setting it to level 0, but a dab of the brake (wired in) changes nothing.

But then why would it? If they were worried about windup, why put in the effort to reset the integrator from the brake? There are much much easier fixes.
 
I don't know about setting it to level 0, but a dab of the brake (wired in) changes nothing.

But then why would it? If they were worried about windup, why put in the effort to reset the integrator from the brake? There are much much easier fixes.
Not as a deliberate fix, rather as a side effect of the implementation (integrator reset), seems not
 
Last edited:
Thanks, I hope to get out tomorrow and will try the backpedalling thing.

The response I got from to7 was "update the firmware to latest" but I'm not very willing to do that because I don't think I will be able to properly configure the speed and power limits anymore.

Update: backpedalling doesn't change anything on my motor.

If you can access the advanced menus now, you're probably running pre-October 2024 firmware. Updating to the latest version may help, and if you are on pre-October firmware then there is a chance you would still have access to the advanced settings after the update.

Supposedly this only works on motors which were already running unlocked firmware, whereas motors which were already locked out will remain that way with each update. That is my understanding based on the wiki.

If you do decide to update and get locked out then there is still a way to access the advanced menus, but it will compromise your warranty if you do.
 
Back
Top