DIYPNP install: inital tuning - Page 11 - Miata Turbo Forum - Boost cars, acquire cats.

Welcome to Miataturbo.net   Members
 


MEGAsquirt A place to collectively sort out this megasquirt gizmo

Reply
 
 
 
LinkBack Thread Tools
Old 05-30-2011, 08:56 PM   #201
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

From MSExtra:
Quote:
If you thought that's what I was saying, you misunderstood.

There should never be a reason to enter negative numbers for the D term.

About the only thing I'd do in code is amplify its effect so you don't have to use such a large number for it.

Ken
Greg G is offline   Reply With Quote
Old 05-30-2011, 09:22 PM   #202
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

Hey Jason. Would getting the D response in 1 tick faster significantly shift the idle duty sinusoid to the left?
Greg G is offline   Reply With Quote
Old 05-31-2011, 07:01 PM   #203
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Doesn't appear to be anywhere as significant an issue as the inverted sign.
JasonC SBB is offline   Reply With Quote
Old 06-13-2011, 03:18 PM   #204
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Here's a code snippet from ms2_extra_idle.c

tmp1 = IACmotor_pos - (((long)(Kp + Ki - Kd) * ...

Why is Kd subtracted from the others and not added??
This appears to be the inverted sign problem.

How hard is it to get someone to change the sign, recompile, and for Greg to flash the new program in?
JasonC SBB is offline   Reply With Quote
Old 06-13-2011, 03:25 PM   #205
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,809
Total Cats: 1,780
Default

ask reverant.
Braineack is offline   Reply With Quote
Old 06-13-2011, 08:15 PM   #206
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

Quote:
Originally Posted by JasonC SBB View Post
Here's a code snippet from ms2_extra_idle.c

tmp1 = IACmotor_pos - (((long)(Kp + Ki - Kd) * ...

Why is Kd subtracted from the others and not added??
This appears to be the inverted sign problem.
If it is inverted, then it does makes sense that the recommended d is zero!

I hope it really is as simple a fix as it looks. It does explain the apparent shift to the right of the sinusoids with high d.
Greg G is offline   Reply With Quote
Old 06-13-2011, 11:27 PM   #207
Junior Member
 
Join Date: Apr 2010
Posts: 107
Total Cats: 0
Default

Quote:
Originally Posted by JasonC SBB View Post
What Ken said, "The D term is not coupled to error in the idle speed control loop, it's only coupled to change in RPM, which changes the sign you need to use to get the proper behavior." suggests that the code needs to be modified then, so that the sign is inverted, to get the proper behaviour.
I thought there was something odd about that code the first time I saw it. It doesn't incorporate the SP target at all, which makes me think it's not really acting like a normal PID control (and the sign inversion). Does anyone know why it it's just basing it on the difference between the past and present error terms instead of RPM alone? Is it so you get only the control loop induced rpm change instead of also incorporating a target change and possibly overshooting?

EDIT: Nevermind, I figured it out. If you assume the target is constant it cancels itself out of each first-order change calculation. Then you're just calculating the difference between the current stage error and the previous stage error.

Last edited by bearda; 06-13-2011 at 11:43 PM.
bearda is offline   Reply With Quote
Old 06-13-2011, 11:44 PM   #208
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Correct, the 'D' part of the algorithm only looks at the derivative of the RPM and not the derivative of the error. In the case of idle control, the target doesn't change very rapidly anyway, so it makes little difference.
JasonC SBB is offline   Reply With Quote
Old 06-14-2011, 03:52 AM   #209
Supporting Vendor
iTrader: (10)
 
Reverant's Avatar
 
Join Date: Jun 2006
Location: Athens, Greece
Posts: 5,440
Total Cats: 197
Default

Give it a try then.
Attached Files
File Type: zip ms2extra_3.1.1_PID_Kd.zip (808.0 KB, 32 views)
Reverant is offline   Reply With Quote
Old 06-14-2011, 04:37 AM   #210
Elite Member
iTrader: (1)
 
Join Date: Jun 2006
Location: Warrington/Birmingham
Posts: 2,658
Total Cats: 39
Default

Reverant:

1) Nice quick job!
2) Is that based on 'Mario b's' code changes?
richyvrlimited is offline   Reply With Quote
Old 06-14-2011, 04:55 AM   #211
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

Yay! Thanks Dimitris! Will try it out as soon as I get a chance!

And yes, is this based on the official 3.1.1 or the mario b 3.1.1?
Greg G is offline   Reply With Quote
Old 06-14-2011, 04:59 AM   #212
Supporting Vendor
iTrader: (10)
 
Reverant's Avatar
 
Join Date: Jun 2006
Location: Athens, Greece
Posts: 5,440
Total Cats: 197
Default

I don't remember whether the 3.1.1 directory I edited was the vanilla or the mario_b version, however, I didn't find the "tmp1 = IACmotor_pos ..." snippet, instead I found "tmp1 = IACmotor100 ..." which leads me to believe that I had in fact, applied mario_b's patch to that directory.
Reverant is offline   Reply With Quote
Old 06-14-2011, 06:44 AM   #213
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

Well I tried it! No dice. :(

The idle valve would immediately go to 60.2 (maximum open duty) and stay there. Idle RPMs stayed at 2k. Even setting PID to 0 0 0 didn't lower the idle duty. Setting it to PWM warmup lowered the idle duty as preset (so I know it isn't stuck).

Thanks again for the modified file Reverant!

Quote:
Originally Posted by Reverant View Post
I don't remember whether the 3.1.1 directory I edited was the vanilla or the mario_b version, however, I didn't find the "tmp1 = IACmotor_pos ..." snippet, instead I found "tmp1 = IACmotor100 ..." which leads me to believe that I had in fact, applied mario_b's patch to that directory.
The snippet from Jason came from me- I sent him the file from the mario b version. So you may have modified the release version of 3.1.1. Could that have caused the high idle issue?

EDIT: Oh crap I forgot to point the TS project to the correct firmware directory after flashing, maybe that's the issue...I found it set to 3.1.0 >.<
Attached Files
File Type: msl 2011-06-14_16.29.58pid000.msl (852.3 KB, 70 views)
File Type: msq 2011-06-09_20.47.47idleve3.msq (79.6 KB, 50 views)

Last edited by Greg G; 06-14-2011 at 07:08 AM.
Greg G is offline   Reply With Quote
Old 06-14-2011, 05:16 PM   #214
Junior Member
 
Join Date: May 2007
Location: Columbia, MD
Posts: 248
Total Cats: 0
Default

Quote:
Originally Posted by Greg G View Post
If it is inverted, then it does makes sense that the recommended d is zero!

I hope it really is as simple a fix as it looks. It does explain the apparent shift to the right of the sinusoids with high d.
Please see:

http://bestune.50megs.com/typeABC.htm

Specifically, I'm using type C.

Ken
muythaibxr is offline   Reply With Quote
Old 06-14-2011, 06:18 PM   #215
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

Thanks Ken! That is the controller output response that I'm trying to get from the idle valve, without much success.
Greg G is offline   Reply With Quote
Old 06-14-2011, 06:21 PM   #216
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,809
Total Cats: 1,780
Default

do the dual throttle body mod and then report back...
Braineack is offline   Reply With Quote
Old 06-14-2011, 07:31 PM   #217
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Hi Ken,

I understand that the "type C" controller in the above link removes the setpoint information from the 'D' calculation. My hypothesis as to the problem has nothing to do with this.

What I see from ggermar's datalogs is that the effect of the D term (comparing 0, to medium, to large values of D), seems to have its sign inverted. That is, a dropping RPM seems to reduce the solenoid duty cycle, and vice versa, instead of the dropping RPM producing an increase in solenoid duty cycle. I see comparing the RPM and duty cycle sinusoids.

With a pure P controller the sinusoids will be inverted from each other (sinusoid of duty will be upside down compared to the sinusoid of RPM). That's because a dip in RPM produces a rise in duty. The D term should "mix in" a 90* phase shifted sinusoid. So as D is added, the duty cycle sinusoid should start "shifting left" as compared to the old P-only duty sinusoid. That is, the duty sinusoid should peak *before* the RPM has reached bottom. This is from the math:

-Derivative of a sinusoid is a 90* phase shifted sinusoid.

- If you add a 90* phase shifted sinusoid to a regular sinusoid, it looks like a sinusoid that's phase shifted between 0 and 90*.

- If you add an inverted, 90* phase shifted sinusoid, it phase shifts between 0 and -90* instead. (visually it appears to shift in the opposite direction)

What I see in Greg's datalogs is that the phase shift is *to the right* instead of to the left. This suggests that the D calculation is inverted (subtract instead of add, or vice versa). And the code snippet I posted, appears to be it. The P and I terms are added, but the D term is subtracted......

This is why practical D circuits in electronics are called "phase lead" circuits. Its sorta kinda like leading the clay pigeons when you shoot 'em.

Cheers.

Last edited by JasonC SBB; 06-14-2011 at 08:56 PM.
JasonC SBB is offline   Reply With Quote
Old 06-14-2011, 07:42 PM   #218
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Quote:
Originally Posted by Braineack View Post
do the dual throttle body mod and then report back...
You don't think trying code improvements is easier?

Wouldn't it be cool if the MS were the only ECU that could idle an intercooled s/c without a dual TB?
JasonC SBB is offline   Reply With Quote
Old 06-14-2011, 08:40 PM   #219
Boost Czar
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,809
Total Cats: 1,780
Default

I have no issue with the code. but i don't have crazy throttled volume.

problem is, when they went to the ms3 they made a huge improvement with the a/c idle up adder...and they really have no motivation to backport things to older hardware and would like to move forward with ms3 features and improvements.
Braineack is offline   Reply With Quote
Old 06-14-2011, 08:59 PM   #220
Junior Member
Thread Starter
 
Join Date: Jun 2007
Posts: 411
Total Cats: 0
Default

I just feel the MS2extra code is very close to done. And it's very good. Maybe just a final update incorporating the mario b patch, and hopefully a solution to the D issue, and it'll be perfect. The data collected does show that the sinusoid moves to the right, not left. So there is something there not working properly...

I understand the focus is on MS3, but solving the PID issue will benefit MS3 as well.
Greg G is offline   Reply With Quote
 
 
Reply

Related Topics
Thread Thread Starter Forum Replies Last Post
Expected intake temps on the track? tazswing Race Prep 20 10-03-2015 12:04 PM
Time to start learning and play with tuning The Gleas MEGAsquirt 3 10-01-2015 10:30 AM
Are my coils failing? viriiguy General Miata Chat 5 09-28-2015 08:39 PM
Missing/knock at idle, can someone point me in the right direction? Mikel MEGAsquirt 4 09-28-2015 05:46 PM


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 07:40 AM.