Adjustable PID for battery powered motors?

Hi guys,
a hoverboard motor usually runs on a 10-cell LiPo battery which means the bus voltage can vary from ~42V down to ~25V under load.
I’ve seen other PID setups (eg. for bed heaters in 3D printers) where the PID parameters are coupled to the actual voltage.
Would it make sense to implement the same algorithm in sFOC?

Well people frequently take shortcuts. So as a result, the PID gain can be just an integer, relating to other integers. This can lead to a situation where increasing the drive voltage basically equates to increasing the gains in the PID.

However if written more prudently the PID gains will be written so they are in rads/second or something, which is not dependent on drive voltage. I do not know exactly how things work right now. All I can really tell you is that you have to get in there and look at things because it hasn’t been sorted out thoroughly yet, unfortunately. If you want it well sorted, you sort of have to buy a VESC or odrive. We are getting there and the work that has been done is good we just need more more more.

The motor behaves different with lower or higher voltage. The PID algo should be able to deal with that.
I don’t see it as a shortcut?

Isn’t it just about feeding driver.voltage_power_supply with the measured bus voltage?
I think we discussed it on another thread.

That would probably work, IF:

  • you set motor.voltage = 0.5* driver.voltage in the main loop
  • you don’t have an application with fast or huge battery-load variations

Otherwise you’d need some improvement in the bus voltage measurement.
When would be the best time to measure bus voltage?
Before the space vector dent or during the dent?
Or simply at 50% of the duty cycle?

One last_minute thought: do we have to invert the PID-gain adjustment?
Lower voltage should lead to sharper PID-gain.

To my knowledge you can measure it anytime.
You need to filter it not to introduce noise in the control anyway.

The output of the current pid is voltage, but we are controlling the motor with the duty cycle, which depends on the supply voltage.
When using the real bus voltage we are probably making the pids life easier.

Rather than change pid gains, it’s much better to include battery or psu voltage in the calculations appropriately. If implemented well, the pid gains should be very stable with respect to voltage.

I think right now if you update the power supply voltage in operation it works pretty well. I’ve only done that once and it was on a pretty insensitive application, but everything worked great.

On battery sag, I think you want to compensate for that if you can measure it, the voltage change is just as relevant from sag as it is from discharge.