PID control discussion

Official FreeEMS vanilla firmware development, the heart and soul of the system!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PID control discussion

Post by Fred »

8InchesFlacid wrote:I thought when you do an interupt, it's transparent to what's interupted?
That entirely depends on what code runs inside the ISR. Remember that much of it for them is ASM and that THEY are responsible for saving and restoring values etc and may not be saving everything that is required each and every time. Could be wrong, but that could be responsible for it. As could use of some of those very same vars.

Use the stop/start pair and see how you get on.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: PID control discussion

Post by AbeFM »

It'd be mighty unneighborly of them if they did, but I guess it's worth a shot.

Anyway, here's a log. Not sure what good it is, and I'm not sure it's recorded right. But:

GPIOadc# Function
0 Error 0 - "now" error
1 Error 1 - last time error
2 Error 2 - previous time's error
3 PID Correction - PID control's contribution (After limits applied)
4 Open Loop Offset - Open loop, coolant based contribution, in percent
5 tmp1 - output to IAC valve (before limits applied)
6 targ_rpm - target rpm

Image
Here you can see the open loop offset behaves. But not at ~1000 rpm, the idle PID correction is higher the first time around than the second. This is it 'losing track', which I don't know how to deal with (diabling interuprts is coming)

Image
Just another view in case it helps. The logs show the coolant based offset and targets working.
thebigmacd
LQFP112 - Up with the play
Posts: 205
Joined: Thu Apr 10, 2008 5:51 pm

Re: PID control discussion

Post by thebigmacd »

I'm curious as to why your error is maxing out at 65535.

Edit: negative numbers? Wow am I rusty at raw binary lol

Can you write a MLV formula to show actual +- values?
Keith MacDonald
Control Engineering (Systems) Technologist
User avatar
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: PID control discussion

Post by AbeFM »

Never messed with it, though I imagine it's easy enough.

Did I attach the actual log file? I think that'll be more meaningful that images anyway
User avatar
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: PID control discussion

Post by AbeFM »

Ok, figured that out. Would rather have figured out my idle. :-)

Image
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PID control discussion

Post by Fred »

That dip after the big rev at the end clearly shows that the valve is closed. Based on your table of normal output that the PID only adds to, that should never happen. The MS2 code has a thing to close the valve when out of the idle region such that you pull more vacuum on lift off etc, so it closes, then opens again when you get close. you should turn off your PID stuff and get a decent open loop idle first, then use the PID to fine tune it. I think this is what Keith was saying as well.

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: PID control discussion

Post by AbeFM »

The dip in RPM? haha... Sorry, this is all jimstim stuff, there's no engine! I was just trying to show how the idle valve oftentimes opens at high revs.

My open loop idle works wonderfully, on the car.
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PID control discussion

Post by Fred »

8InchesFlacid wrote:The dip in RPM? haha... Sorry, this is all jimstim stuff, there's no engine! I was just trying to show how the idle valve oftentimes opens at high revs.

My open loop idle works wonderfully, on the car.
Post a REAL log of it failing to perform on the vehicle then. Open loop as in closed look without the pid doing anything? or some different mode? If not the former, you should do that...

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: PID control discussion

Post by AbeFM »

Er, so... I've got it running JUST proportional there. I'm looking to see the PID_correction term be proportional to the error.

If I can't get that working, there's little point to the rest. Integral just seems to mask that.
thebigmacd
LQFP112 - Up with the play
Posts: 205
Joined: Thu Apr 10, 2008 5:51 pm

Re: PID control discussion

Post by thebigmacd »

I don't see much wrong with the way the proportional is working. Your final rpm is below setpoint, so the proportional component is adding lots of pulse width. Why it creeps down is anyone's guess...are you sure your Ki = 0 for sure, as far as the minute details of the algorithm?

Perhaps substitute your PID calc line with the P-only version of the equation and see how it goes?
Keith MacDonald
Control Engineering (Systems) Technologist
Post Reply