[info] electronic throttle body control ETB

It's all about the code!
Post Reply
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

puff wrote:
Mon Mar 04, 2019 2:37 pm
you want to feed that data to some AI model?
I need help with data analysis. There are so many ideas around but not many people trying ideas. Any chance you would be interested to get yourself a bench and play with this stuff?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
puff
contributor
contributor
Posts: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: electronic throttle body control ETB

Post by puff »

You mean a physical bench, trying to find the the best PID parameters for a certain throttle body? In that case, may be in May I will have some time for that.

If you are talking about interpreting your data, you haven't provided enough information about your tests. What are these columns, why do you use date? How the result value is determined?

The cited article from my previous post suggests that PID should consider spring tension, friction and some other unknown system parameters, which means, the optimal PID would be different for every model of throttle body - it would be different even for the new and worn-out throttle of the same model?
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

puff wrote:
Mon Mar 04, 2019 3:59 pm
If you are talking about interpreting your data, you haven't provided enough information about your tests. What are these columns, why do you use date? How the result value is determined?
result value is standard deviation of control error - i.e. sum of squares of (target - current) each 100ms during the test run.

first column date of the run is just there since that's part of my logging format. So, each log line has offset, P, I, D and result. Smaller result is considered better PID control for this test.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
puff
contributor
contributor
Posts: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: electronic throttle body control ETB

Post by puff »

For data analysis, for your Monte Carlo setup, in addition to PID figures, I would also capture the change in target - how fast it changed (was it from 0% to 5% or from 0% to 50%? or from 15% to 50%) over some time, and in addition to the overshoot value, I'd also assess, how fast it overshoots.
sum of squares of (target - current)
What is offset?

Are we trying to invent a new method of ETB control?
puff
contributor
contributor
Posts: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: electronic throttle body control ETB

Post by puff »

just 258 tests?
postMessage EtbMonteCarloSequence 29367,358 - is it some raw value corresponding to certain PID and offset?
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

puff wrote:
Mon Mar 04, 2019 5:18 pm
just 258 tests?
postMessage EtbMonteCarloSequence 29367,358 - is it some raw value corresponding to certain PID and offset?
29367,358 is number of seconds since start of test. Let me publish complete log once I am back home. Yes 250 tests took 10 hours, see https://github.com/rusefi/rusefi/blob/master/java_console/ui/src/com/rusefi/ui/widgets/EtbTestSequence.java for test scenario definition.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

mck1117 wrote:
Fri Feb 08, 2019 9:22 pm
edit: looked closer at the diagram and re-read kb1gtt, it's not two steppers, it's a doubly wound single stepper. So it'll probably work if you use one set of windings (ie two pairs of wires), and ignore the other.
I have this BMW M73 throttle body in my hands original post with information https://rusefi.com/forum/viewtopic.php?f=5&t=592&start=120#p31752

I am looking at wires #13 and #16. Which wire(s) shall I connect wire #13 to and which wire(s) shall I connect wire #16 to?

By the way resistance between #13 and #16 is 3.0 ohms.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

As a guidance for what variables needed, check the software and help-files for standalone ecu's with good working E-Throttle.

Screenshot from PC-Link Software:
Link-ECU.jpg
Link-ECU.jpg (435.58 KiB) Viewed 35225 times
Link-ECU_2.jpg
Link-ECU_2.jpg (495.2 KiB) Viewed 35224 times
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

ETB#1 has broke plastic gears probably while everything was hot and fragile.
I was able to revive ETB#2 - it just needed a push to open, it wanted to close itself so hard that it got stuck shut. Once pushed to open it is back operational!

ETBs #3 and #4 have arrived in the mail and @ has donated ETB #5. One of the things I would like to get soon is implement dual ETB control.
Attachments
etb_1.jpg
etb_1.jpg (254.35 KiB) Viewed 35170 times
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Abricos
contributor
contributor
Posts: 849
Joined: Mon Aug 18, 2014 12:32 am
Location: Carteret, NJ 07008

Re: electronic throttle body control ETB

Post by Abricos »

maybe you have the opportunity to make restrictions on opening and closing ...
let's say 100% is a fully open potentiometer (throttle body) you need to make a limit on closing of 0.5% and on opening of 99.5% ...
if you have already implemented a DC motor braking system ...

Maybe this help
Dynamic Braking
It is also known as Rheostatic braking. In this type of braking, the DC motor is disconnected from the supply and a braking resistor Rb is immediately connected across the armature. The motor will now work as a generator and produces the braking torque.

During electric braking when the motor works as a generator, the kinetic energy stored in the rotating parts of the motor and a connected load is converted into electrical energy. It is dissipated as heat in the braking resistance Rb and armature circuit resistance Ra.
Новый точечный рисунок (4).bmp
Новый точечный рисунок (4).bmp (1.76 MiB) Viewed 35145 times
8712.Wilson 3.png
8712.Wilson 3.png (26.74 KiB) Viewed 35147 times
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

MaxxECU's E-Throttle works good as well

http://www.maxxecu.com/webhelp/settings-ethrottle-throttle_control.html


Integral limiter extended information
A common problem with PID tuning is that you want to use a high I-gain to get a fast and exact response, but it might become unstable. This is because of "integer windup". The I-term (the part of the output that's a result of the I) of a PID controller gets larger the longer time the value has been far away from the target.

With a high I-gain, the I-term gets too large before the target is reached and this causes a large overshoot followed by oscillation.



To counteract this and allow you to use high I gains without overshoot and oscillations, you can use an "integral limiter", the limiter limits the I-term depending on how far away from the target the value is.

When the value is far from the target, you want only the I to do little work, because at this point, P is the most efficient and stable control parameter.

When the value gets closer to the target, the P-part naturally decreases, and at this point we want more of the work to be done by the I to close the gap and decrease the error to zero fast.



An "I limiter" in MaxxECU is set up as a list with the allowed I-term contribution as a function of the error (how far off the target we are).



At zero error we want to allow the I to do perhaps 40-60% of the work. When we're far off, the "I limiter" can be set to zero so that only P affects the output.

You tune how far from the zero error point you want the I to come in. Closer will allow you to increase the actual I-gain to get better precision and response from the controller.

The point at which the I-gain comes in must be far enough away to allow the P-gain to bring the value close before the I takes over.



The way to tune "I limiters" in MaxxECU is to turn them on, leave the default values and try to re tune the PID. Most of the improvement is found in the higher PID-values that enabling the "I limiter". If fine tuning is necessary, adjust how far from the target the "I limiter" comes in.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: electronic throttle body control ETB

Post by kb1gtt »

Etb's are reasonable fast acting with low inertia. Could they be controlled if every 1ms or so you simply check if you are above or below target and adjust the output. If below then output is 1. If above the target the output is 0.

If the inertia is a problem perhaps add a "D" term to limit the rate of approach.
Welcome to the friendlier side of internet crazy :)
Abricos
contributor
contributor
Posts: 849
Joined: Mon Aug 18, 2014 12:32 am
Location: Carteret, NJ 07008

Re: electronic throttle body control ETB

Post by Abricos »

kb1gtt wrote:
Tue Mar 12, 2019 1:22 am
Etb's are reasonable fast acting with low inertia.
EtB it has a heavy closing spring ... maybe 3-5 kg to closing force ...
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: electronic throttle body control ETB

Post by kb1gtt »

Springs have fairly low inertia.
Welcome to the friendlier side of internet crazy :)
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

kb1gtt wrote:
Tue Mar 12, 2019 9:08 am
Springs have fairly low inertia.
That's right.

I think with the gear ratio and motor effect, the spring dont affect the motor that much.
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

Had to do some PID reading, as I haven't used that since school ages ago.

Have you measured the current the throttle needs?

Does the H-bridge control method affect anything? (3 wire vs 2)?
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

960 wrote:
Tue Mar 12, 2019 2:05 pm
Does the H-bridge control method affect anything? (3 wire vs 2)?
Only minor software changes I guess?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

960 wrote:
Tue Mar 12, 2019 2:05 pm
Does the H-bridge control method affect anything? (3 wire vs 2)?
Only minor software changes I guess?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: electronic throttle body control ETB

Post by mck1117 »

kb1gtt wrote:
Tue Mar 12, 2019 1:22 am
Could they be controlled if every 1ms or so you simply check if you are above or below target and adjust the output
No. Bang-bang controllers are crap for anything that isn't really really slow. Older home thermostats are bang bang controllers (with some hysteresis), but for anything else they're pretty garbage. We have the CPU cycles to do it right.

My controller didn't even need I limiting to do a really great job controlling the throttle. Just the open loop table, plus a vanilla PID controller.

Here's how to tune it:
  1. Tune open loop controller. Set PID gains to all zero, and adjust the bias table so that at all points of the travel, the throttle stays where you leave it. If at some point the throttle tries to close itself, add power there in the table. If it tries to open itself, remove power (make more negative). Only continue to step 2 when the throttle behaves like it has no spring and you can easily move it, by hand, through its travel without interference from the spring.
  2. Tune closed loop controller. Zeigler-nichols worked pretty darn well for me. Crank up P until it oscillates, then measure oscillation period and use those two numbers to calculate final gains.
Why does this controller work?

While a normal PID controller would work, it would do poorly. The I term serves to compensate for any steady state error. However, it only works if the steady state error e(X) is relatively constant with respect to the state X. For a throttle body with a big centering spring, e(X) is nearly piece wise with a giant discontinuity in the middle, so any variant of a PID controller cannot control the system. It's a linear controller, and we're controlling a nonlinear system.

As suggested here https://en.wikipedia.org/wiki/PID_controller#Limitations_of_PID_control, we can solve the problem by adding a feed-forward term that provides knowledge about the system (linearizing it), so the PID controller can "think" it's controlling a linear system (only control error, instead of error and the system).

While I-term limiting is wise to prevent melted motors in case of a stuck throttle, it's not necessary in a FF+PID controller because the I term doesn't have to carry the burden of the spring.
Last edited by mck1117 on Wed Mar 13, 2019 1:34 pm, edited 1 time in total.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: electronic throttle body control ETB

Post by mck1117 »

russian wrote:
Tue Mar 12, 2019 3:09 pm
960 wrote:
Tue Mar 12, 2019 2:05 pm
Does the H-bridge control method affect anything? (3 wire vs 2)?
Only minor software changes I guess?
Correct, it's no big deal at all. There's already an abstraction available for controlling a DC motor that abstracts away things like PWM and direction control, which may be different for different controllers.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

mck1117 wrote:
Wed Mar 13, 2019 1:29 pm
As suggested here https://en.wikipedia.org/wiki/PID_controller#Limitations_of_PID_control, we can solve the problem by adding a feed-forward term that provides knowledge about the system (linearizing it), so the PID controller can "think" it's controlling a linear system (only control error, instead of error and the system).
Is the feedForward variable in master implementing this already or not really? https://github.com/rusefi/rusefi/blob/master/firmware/controllers/electronic_throttle.cpp#L207

It would be great to have a teamviewer Zeigler-nichols training session one day when you have time.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: electronic throttle body control ETB

Post by mck1117 »

russian wrote:
Wed Mar 13, 2019 9:44 pm
Is the feedForward variable in master implementing this already or not really? https://github.com/rusefi/rusefi/blob/master/firmware/controllers/electronic_throttle.cpp#L207
Yes. Though my bias table is wrong for your ETB.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: electronic throttle body control ETB

Post by kb1gtt »

If you get Zeigler-nichols to actually work well, I'm interested in learning your system. I think Zeigler-nichols had been made famous by Wikipedia. I have tried it on several systems and real work signal delays seen to bugger that approach.
Welcome to the friendlier side of internet crazy :)
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

Just tested in vehicle, and at least it's moving

If i keep the padal still, the throttle slowly opens and tps counting upwards.
When releasing pedal it closes, and full throttle it opens.
So issue is only when keeping it still between closed and full.

Btw, the firmware build are not working now. When flashed it does not recognize usb.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

Please provide more details. Your throttle settings and a log would really help.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

I have a idea what could have been wrong.

I had set second tps sensor as TPS2 input, maybe some conflicting signals?

Going out for a new test(drive?) when I get board working again.
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

I have started to play a little with the throttle, but doesnt understand too much.

Can you explain a litte about the E-Throttle settings in TS?

What kind of values are typically at the P, I and D settings? Something like 0,1 or 50?

Isn't any setup procedure like Maxxecu have needed(Link does not have it eighter)?
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: electronic throttle body control ETB

Post by AndreyB »

My best results so far are at https://rusefi.com/forum/viewtopic.php?f=5&t=592&start=120#p31943

offset 80
pFactor 1.07
iFactor 0.18
dFactor 0.24

With the following default bias curve
engineConfiguration->etbBiasBins[0] = 0;
engineConfiguration->etbBiasBins[1] = 1;
engineConfiguration->etbBiasBins[2] = 2;
/**
* This specific throttle has default position of about 4% open
*/
engineConfiguration->etbBiasBins[3] = 4;
engineConfiguration->etbBiasBins[4] = 7;
engineConfiguration->etbBiasBins[5] = 98;
engineConfiguration->etbBiasBins[6] = 99;
engineConfiguration->etbBiasBins[7] = 100;

/**
* Some negative bias for below-default position
*/
engineConfiguration->etbBiasValues[0] = -20;
engineConfiguration->etbBiasValues[1] = -18;
engineConfiguration->etbBiasValues[2] = -17;
/**
* Zero bias for index which corresponds to default throttle position, when no current is applied
* This specific throttle has default position of about 4% open
*/
engineConfiguration->etbBiasValues[3] = 0;
engineConfiguration->etbBiasValues[4] = 20;
engineConfiguration->etbBiasValues[5] = 21;
engineConfiguration->etbBiasValues[6] = 22;
engineConfiguration->etbBiasValues[7] = 25;
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: electronic throttle body control ETB

Post by kb1gtt »

For the short term, start with @'s above noted but change this for the time being. The integral term is most likely what is causing your gradual wandering to 100%. Once it works with out the IFactor, then you can add the IFactor.
iFactor 0.00

There is a strong chance your PID Factors will need to be adjusted for your particular ETB.
Welcome to the friendlier side of internet crazy :)
960
contributor
contributor
Posts: 336
Joined: Mon Dec 10, 2018 1:22 am
Location: Norway

Re: electronic throttle body control ETB

Post by 960 »

How do I set up the Duty bias and calibrate TPS?

The best would be to "turn off" PID and Pedal position influence somehow, and test what duty are needed.

I am not so deep into this yet, so it might be I just misunderstand.

A basic setup procedure would be nice, as I think having the exact correct duty are a must before the PID tuning.

Btw, it was the duty that caused all the issues for me.

I had it working best and even idling with -6 to 20.
Post Reply