Hill hold functionality

Topics about inverter software, improvements and bug fixes. Also release announcements are found here
Post Reply
User avatar
johu
Site Admin
Posts: 2918
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Contact:

Hill hold functionality

Post by johu »

Did something that I wanted to do for a long time, a hill hold function, so stopping the car from coasting forward or backward on a hill.

The strategy is to counteract the distance travelled since the time of activation. The more we move away from our reference point, the more we try to pull into the opposite direction.

So to the encoder class I added a function to measure the distance in radiants and a function to zero out the distance measurement. Rolling backwards gives negative distance, forward gives positive distance. When rolling backward we apply positive torque in order to stop rolling.

When pressing the brake pedal the function is armed and distance reset, as soon as you let go off the pedal the controller becomes active. When you give more throttle than hill hold requests the function is disabled and your back to manual control.

I tested it on a super steep incline that requires like 60% throttle to keep the car stationary and it works super well. The car rolls back about 20 cm then it stops. The distance can be configured with the proportional gain. Of course it mustn't be too high as that will cause oscillation. I set the parameter holdkp=-1

It didn't work so well when rolling forward, I have to investigate that. So the controller correctly commands negative torque when rolling forward but at some point FOC generates excessive id and almost no iq and therefor hardly any torque. Have to check if that is a principal issue with MTPA or FOC itself.

This may or may not work with induction motors, actually I'm quite sure it won't stop forward motion. Attaching a binary anyway.
Attachments
stm32_sine.bin
(47.77 KiB) Downloaded 29 times
stm32_foc.bin
(46.73 KiB) Downloaded 25 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
catphish
Posts: 64
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK

Re: Hill hold functionality

Post by catphish »

This is fantastic. Sadly I'm not in a position to test but very happy to see this added, and the approach of applying a proportional torque based on distance travelled seems very elegant. :idea:

If I might make one (hopefully trivial) suggestion, I would likely not want this feature to prevent forward motion (rolling in the selected direction), so when it comes to configuration, it would be great if this could be enabled independently.
User avatar
johu
Site Admin
Posts: 2918
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Contact:

Re: Hill hold functionality

Post by johu »

catphish wrote: Fri Nov 19, 2021 10:52 pm This is fantastic. Sadly I'm not in a position to test but very happy to see this added, and the approach of applying a proportional torque based on distance travelled seems very elegant. :idea:

If I might make one (hopefully trivial) suggestion, I would likely not want this feature to prevent forward motion (rolling in the selected direction), so when it comes to configuration, it would be great if this could be enabled independently.
Thanks :)
Yes that seems like a useful config option
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
ZooKeeper
Posts: 486
Joined: Mon Mar 30, 2020 10:23 pm
Location: USA

Re: Hill hold functionality

Post by ZooKeeper »

Superb!
Huebner VCU controlling a Gen2 Prius Inverter powering an MGR
"Talent is equally distributed but opportunity is not." - Leila Janah
yaroslav
Posts: 124
Joined: Tue Aug 13, 2019 4:32 pm
Location: Russia, Stavropol

Re: Hill hold functionality

Post by yaroslav »

Hello johannes. Great, I'll test the sine firmware in the near future, I wanted to ask you to do it earlier, but I kept forgetting something. Thank you for your work.
yaroslav
Posts: 124
Joined: Tue Aug 13, 2019 4:32 pm
Location: Russia, Stavropol

Re: Hill hold functionality

Post by yaroslav »

You can attach a file with the hex extension
Leo M
Posts: 67
Joined: Fri Oct 30, 2020 9:48 am

Re: Hill hold functionality

Post by Leo M »

:) 👍👍👍
User avatar
EV_Builder
Posts: 490
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands

Re: Hill hold functionality

Post by EV_Builder »

Maybe a strategy would be to opt for zero speed instead of distance traveled. And don't forget to include windows for small errors.
Also a maximum torque and speed would be wise to implement.
(While in this mode).

A counter option would be handbrake release request from the drive unit. But maybe that concerns me having a newish car.
User avatar
johu
Site Admin
Posts: 2918
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Contact:

Re: Hill hold functionality

Post by johu »

EV_Builder wrote: Thu Dec 02, 2021 12:50 pm Maybe a strategy would be to opt for zero speed instead of distance traveled. And don't forget to include windows for small errors.
Tried it, doesn't work. Speed info is much less accurate than position and thus distance info.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
EV_Builder
Posts: 490
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands

Re: Hill hold functionality

Post by EV_Builder »

johu wrote: Thu Dec 02, 2021 7:12 pm Tried it, doesn't work. Speed info is much less accurate than position and thus distance info.
Yes, because speed is the distance component * time component.
So distance = 0 would be then speed=0. Did you try distance =0?

To let this work better we would be helped with an inclination sensor... :D It would give us a pre-load idea for the control loop. :)

Saying that i would think that a Current / Distance Loop would be fairly quick in a PI Loop, but i have no clue yet where the challenge lies in that.
The problem with low speed motor control is that the encoder update rate is sensitive and very influential.
That's why a SIN/COS encoder is so brilliant for many applications instead of a incremental encoder.

What kind of motor / encoder is your test bench?

When i'm upto it i will try these features too.
User avatar
johu
Site Admin
Posts: 2918
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Contact:

Re: Hill hold functionality

Post by johu »

I'm trying on the Leaf motor with resolver.
It works very good, even on steep inclines. Current/Distance loop is what we have.

EDIT: I also found out why it doesn't stop forward movement: I'm not allowing negative q-voltage while forward gear is selected. That was to get rid of the startup oscillation. Might have to temporarily allow that while hill hold is active. Or only allow hill hold to stop backward motion.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
EV_Builder
Posts: 490
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands

Re: Hill hold functionality

Post by EV_Builder »

Yeah "the loop needs room to move". How well would this work on the encoder based motors like Tesla?

The Tesla M3 motor does it has encoder or resolver?
User avatar
johu
Site Admin
Posts: 2918
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Contact:

Re: Hill hold functionality

Post by johu »

EV_Builder wrote: Thu Dec 02, 2021 9:42 pm Yeah "the loop needs room to move". How well would this work on the encoder based motors like Tesla?
It should work reasonably well, as the Tesla encoder is 36 pulses delivering 144 edges (falling, rising, channel A, channel B). So we still have 2.5° resolution. A resolver is not much better, maybe 0.5-1° of noise-free position resolution.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply