Switch from pid to bang-bang to energy dissipation as function of speed, error