Adding trim support

In an effort to more accurately track the target load, I’ve added some closed-loop feedback to the resistance setting code. This is just simple linear control for now, but appears to work well enough (it could be enhanced with a more sophisticated PID algorithm, but doesn’t appear to be necessary at this stage).

If the average power is greater than the target load, then the resistance is gradually decreased until they are balanced, and the opposite occurs if the average power is lower than the target load.

Tuning this behaviour consists of adjusting the responsiveness of the average power calculation, the threshold difference between power & load which triggers an adjustment, and the interval between subsequent resistance adjustments. This is mostly a matter of feel, but it’s fairly obvious when the adjustments are being made too aggressively, as the resistance will noticeably oscillate around the correct setting.

Here’s a screenshot from a new ergo session with two 20min intervals, and I’m pretty happy with the results. Seems to be doing a good job of tracking the target power, tested across a deliberately wide range of speeds in the second interval.

ergo4

Next post

While it feels like I’m making good progress on the coding, this prototype is still dependent on my bench power supply, and using an off the shelf development board hooked up to the motor with jumper wires. Would be nice to get the bike out of the house and back into the garage. So next task is to start considering the physical build, with a view to making it more robust & portable.

Advertisements