[FW MOD] AC Idle Up Code

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: jsmcortina, muythaibxr

Post Reply
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

[FW MOD] AC Idle Up Code

Post by gslender »

Update 07 Nov 2011
* Fixed a idleup dashpot bug - which under some rare conditions, can leap idle up and up!!

This firmware mod contains updated TunerStudio configuration to address idle up when AC or load triggers, and also adds Battery Volt droop idle correction. Using this mod you can essentially get a smooth idle with zero droop or spike when AC, fans or other electrical loads are placed on the engine.

Use this firmware and make sure TunerStudio uses the new ini file - the code is based on the 3.1.4 release.
ms2extra_3.1.4_idleup_v7.zip
Follow these instructions:
1) Upload and use the firmware/ini in zip file above. Make sure TunerStudio is using the new ini file.

2) Configure the Idle Up on, set the input pin and idle duty settings - a value of 12.5 seems produce decent results.
TS_idle_up_W7.png
When AC goes on, and the idle input goes high, it adds idle duty and starts counting status4 in 10th seconds. When the input goes low, added idle duty is removed and status4 is instantly put to whatever value is set for "AC off status4 countdown", it then counts backwards to zero by the amount set in rate. So if you set rate to 1 it will goes backwards at the same rate as it counted up, if you set it to 5 it will count backwards 5x faster. Set "AC off status4 countdown" to a higher value (beyond the Output trigger) to have a small delay where idle duty is removed and fans/ac are still set on.

3) Configure in Output port Settings a port (eg WLED) that will go low or high based on a condition that test Status4 to be greater than (>) a Threshold value. The value is in 10ths of a second (so 20 would be 2 seconds).
TS_output_config_W7.png
In the config above, the WLED port goes active 2 seconds after PE1 goes low (and it also adds a condition where it only happens if the TPS is under 85%) - so the AC will activate after 2 seconds and only when throttle is less than WOT meaning AC deactivates under full throttle conditions - super cool hey ;-)

4) Enable battery correction to have duty auto-added when volts drop below 13.2, or duty removed when higher. Factor increases duty add/subtract impact (eg. 4 is twice as aggressive as 2 etc). A value of zero cancels the feature from impacting duty at idle. Formula being used is (132-CurrentVolts)*Factor, which for a factor of 1 adds 32 to the duty at 10volts and subtracts 8 at 14 volts.

In summary, the idle up for AC process is as follows: when Input PE1 goes high(due to AC switched on), the duty will increased based on % set, and 2 seconds later the WLED output will go high/low (to switch on the AC/Fans etc). If you get the duty value correct, and the time correct you'll see zero RPM dip at idle. As an added side benefit, you can now control AC on/off along with some other condition (such as TPS or kPa) to remove AC load at those conditions.

As always, keen to hear results of testing and any suggestions for further improvements.

If you'd like to see this in a supported release, I'd recommend you ask one of the developers as I've yet to hear from them (and yes I've asked). I'll keep updating and adding to which ever release I can for as long as I can.

===================================
Hi all,

I'm keen to start gathering requirements and thoughts/thinking about how to add AC Idle Up code to the MS2 family of firmware. I've been able to build my own release and I've changed some minor parts of the code. I can read/write C, but will struggle to know how MS works and what is required to play with inputs/outputs, manage idle target etc... so this is the significant learning area.

My target (at this stage) will be to modify the 3.1.x releases (probably start with the recent 3.1.3a updated by Jean).

Initial requirements (as I see them) would be to have a predefined input that when it goes high, force the idle duty up by a fixed % - this should be fairly easy to implement, but I'm expecting that this won't be good enough to control AC dip. As such, a next-stage requirement would be to have an output control an on-board relay circuit (if you have them) or a generic relay that would switch on the AC, and be timed to go high some fixed X seconds after the input went high. The final stage would be to convert all static values/input/output etc to TS configurable settings.

So, as I see them, the code would be developed and tested in stages....

Stage 1) when predefined input goes high, force the idle duty up by a fixed %

Stage 2) when predefined input goes high, force the idle duty up by a fixed %, and then start a counter that, after X seconds, sets predefined output high.

Stage 3) convert all static values and input/output to configurable values to be set by TS.

The work would be done and released in stages to understand impact to firmware, memory and available resources - being concious that things are tight etc.

Goal would be to avoid deprecating things out of the existing release, but if push comes to shove, look for unneeded or less required features to go and make room for this feature/function.

Thoughts/comments appreciated and wanted (including pointers to how to recognise an input, set an output, change the idle target etc...) - happy to pay $$ for anyone who can volunteer correct/useful information.

G
Last edited by gslender on Sun Dec 11, 2011 4:00 pm, edited 10 times in total.
Mazda MX5 + MS3 Pro
Greg G
Experienced MS/Extra'er
Posts: 311
Joined: Thu Mar 10, 2011 11:33 pm

Re: AC Idle Up Code

Post by Greg G »

You can check out my thread to see some of the things I've tried, to deal with the AC issue.
http://www.msextra.com/forums/viewtopic ... 01&t=40229

I have 2 extra air solenoids which turn on once the trigger for AC activation (from 1J) goes LOW. The AC clutch engagement is delayed with a time-delay relay set to 1 second. So the solenoids can bump the idle up prior to AC activation. I also connected the AC trigger to PE1 to activate table switching on AC engagement (currently not using this).

So, yeah- if you could increase idle duty (by a user-definable %) off an input to PE1, that would be great. I could get rid of the extra solenoids. Perhaps you could also consider increasing the RPM target when AC is engaged, either a set value or a user definable percentage.

Definitely start with 3.1.3a, since the D term is correct already.

Good luck!
Last edited by Greg G on Wed Oct 05, 2011 9:15 pm, edited 1 time in total.
1996 Mazda MX-5 1.6L NA6/ Mazdaspeed M45 SC/ BSP AW Intercooler/ Maruha F-cams/ 425cc RX-8 injectors/ DIYPNP

MS2/Extra test mule :)
juansh2385
Master MS/Extra'er
Posts: 612
Joined: Fri Feb 25, 2011 4:28 pm

Re: AC Idle Up Code

Post by juansh2385 »

I think you should use goin low as and input. the circuit is also simple. Just my opinion.

Juan
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

juansh2385 wrote:I think you should use goin low as and input. the circuit is also simple. Just my opinion.

Juan
Ok, happy for you to explain why... how does it going Low make it easier vs going High ??
Mazda MX5 + MS3 Pro
transaxel
Helpful MS/Extra'er
Posts: 74
Joined: Tue Apr 22, 2008 10:41 am
Location: Austria

Re: AC Idle Up Code

Post by transaxel »

gslender wrote:
juansh2385 wrote:I think you should use goin low as and input. the circuit is also simple. Just my opinion.

Juan
Ok, happy for you to explain why... how does it going Low make it easier vs going High ??
In my case it doesn´t matter, because ac is switched as going high (i speak about the car wiring) and fan is going low. But it would be possible to code it in two ways. First way to activate if Input is Low, or input is active if Input is high (going low or high). Option can be set by the user. So both cases are available.

regards Gerald
Alfa Romeo 164 2.0 V6 Turbo running on MS2 Extra
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

I'm confused :? I think I need an explanation of what "going low or high" means and how this translate to 12V on the line and/or what the inputs are able to digest etc.
Mazda MX5 + MS3 Pro
transaxel
Helpful MS/Extra'er
Posts: 74
Joined: Tue Apr 22, 2008 10:41 am
Location: Austria

Re: AC Idle Up Code

Post by transaxel »

gslender wrote:I'm confused :? I think I need an explanation of what "going low or high" means and how this translate to 12V on the line and/or what the inputs are able to digest etc.
Ok....going high means the input is set to "active" as voltage changes from 0 to +5 or +12 Volt. So the Voltage is rising. Going Low means the input goes to active if Voltage changes from + 5/12 Volt to 0 (falling edge).
....hope my english is not too bad :oops:

Gerald
Alfa Romeo 164 2.0 V6 Turbo running on MS2 Extra
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

transaxel wrote: Ok....going high means the input is set to "active" as voltage changes from 0 to +5 or +12 Volt. So the Voltage is rising. Going Low means the input goes to active if Voltage changes from + 5/12 Volt to 0 (falling edge).
....hope my english is not too bad :oops:
That is what I thought... so how on earth would the fan blower be going low.... ie turning it on results in a voltage drop from the switch going from 12V+ to 0V ??

Just about all triggers/switches in a car would be going high yeah? (in saying that, I'm aware of my interior lights which switch to ground, and therefore would be going low I guess...) is that the point? - in which case it all depends where you patch in the trigger from.

G
Mazda MX5 + MS3 Pro
Black99rt
Experienced MS/Extra'er
Posts: 364
Joined: Tue Mar 14, 2006 10:38 am

Re: AC Idle Up Code

Post by Black99rt »

With only a very cursory PID tune my truck acccepts shifting into gear, AC, headlights and every load I can throw at it as fast as possible. I suspect the large rotating assembly and heavy torque converter are very forgiving. Do the people who experience stalls with the AC compressor engaging at idle have any problems just switching it on once they are in gear and moving? When you come to stop again will the motor stall when it enters PID?
1999 Dakota 5.9L R/T-
MSIIe 3.1.2 Batch Fuel/MSD single coil dizzy/Stepper idle
LC-1
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

Black99rt wrote:With only a very cursory PID tune my truck acccepts shifting into gear, AC, headlights and every load I can throw at it as fast as possible. I suspect the large rotating assembly and heavy torque converter are very forgiving. Do the people who experience stalls with the AC compressor engaging at idle have any problems just switching it on once they are in gear and moving? When you come to stop again will the motor stall when it enters PID?
Idle dip when turning on/off the AC - the stock ECU controls the AC and will up the idle before turning on the AC... this keeps the RPM stable. With MS2, folks spend a large amount of time tuning idle to reduce the dip when loads appear.
Mazda MX5 + MS3 Pro
Vicoor
Experienced MS/Extra'er
Posts: 305
Joined: Thu Feb 12, 2009 6:58 pm
Location: Manassas, Virginia

Re: AC Idle Up Code

Post by Vicoor »

I think you should try just increasing the Idle Duty% first and see how that works. I expect thats all that's needed. By instantly increasing idle duty% when a load is engaged should be plenty fast enough.

My truck is a 4cyl with a 14lb flywheel. It is pretty sensitive to load chages at idle. My A/C has an idle up solenoid, so that is not an issue. But I run an electric cool fan and when that comes on I get a pretty big dip in the idle.

Victor
Don't Talk About it,,,Just Do It!
1993 Toyota P/U 22RE V3.0 MS2/Extra 3.4.2 Full sequential Injection & Spark
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

Vicoor wrote:But I run an electric cool fan and when that comes on I get a pretty big dip in the idle.
That's the very thing I'm trying to avoid.

The point of this thread is to discuss how to make the needed code changes that eliminate the dip. Not to discuss addon solenoids or adjustments to idle recovery.

You don't happen to know anything about the source code yeah? Like how to test for an input going high?
Mazda MX5 + MS3 Pro
juansh2385
Master MS/Extra'er
Posts: 612
Joined: Fri Feb 25, 2011 4:28 pm

Re: AC Idle Up Code

Post by juansh2385 »

the reason for what I prefer going low is because the circuit that you have to built is a lot easier check the manual and you will see the diference in the circuits. going hi will require a transistor, going low only require 2 diodes and a resistance. And most of the cars the input that they send to activate the relay of ac clutch is ground. the the blower send ground throw a resistance that control the speed of the blower and the 12 volts that activate he clutch normally comes from a relay that is activated by ground.

As the code goes it almost the same difficulty i can think that either will be hard to implement if the require space and I/O are available. But remember is not the same to code a function that do what we want to do with an unused I/O and is other thing to code and I/O that the code use for different function at the same time.. the second is pretty much a hand full and I want you to know that the second is the one that you are getting into.

This "simple" function is going to affect the complete code you should be aware of this fact. There is a really good reason why the developers that have practically have max out the functionality of ms2 have refuse to do this we are talking of mayor changes to the code here. Good luck Man

Juan
Greg G
Experienced MS/Extra'er
Posts: 311
Joined: Thu Mar 10, 2011 11:33 pm

Re: AC Idle Up Code

Post by Greg G »

gslender wrote:
Vicoor wrote:But I run an electric cool fan and when that comes on I get a pretty big dip in the idle.
That's the very thing I'm trying to avoid.

The point of this thread is to discuss how to make the needed code changes that eliminate the dip. Not to discuss addon solenoids or adjustments to idle recovery.
You can't separate the issues. Eliminating the dip and adjustments to idle recovery are part of the same process. And I agree, add-on solenoids are not part of the discussion- they are an attempt to replace the software function you are trying to add (% increase pwm idle duty).

In any case, if you are attempting this, I do agree that just that instant hardware triggered % idle pwm duty increase alone will have a huge impact on decreasing the AC dip, even without a delay on the compressor engagement. The PID issue has already been addressed.

From what I gather, you are doing this on a Miata platform? If so, we shouldn't even be discussing the trigger issue. It is going low, to the AC relay.

With regard to the ms2 code being maxed out- I believe it is, and you would have to remove some parts of the code not needed on the specific platform.

Good luck.
1996 Mazda MX-5 1.6L NA6/ Mazdaspeed M45 SC/ BSP AW Intercooler/ Maruha F-cams/ 425cc RX-8 injectors/ DIYPNP

MS2/Extra test mule :)
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

Question to the developers (or anyone equally smart)...

Found the section below in ms2_extra_user.c which talks about if you can toggle the value of status4 you can then use the existing tuner software to enable outputs... kinda suggesting it could be set within Tuner Studio.

Which part of Tuner Studio does this?

Code: Select all

void user_defined() {
/* 'user defined'
 *
 * So here is a place to put your code. The three variables are there ready
 * for you.
 * If you want to get data out to tuning software you can use outpc.user0 which is set
 * aside specially  (or outpc.status4 or outpc.istatus5 which are both free at time of
 * writing this note.)
 * Then those gauges can be enabled in Megatune or Tunerstudio.
 *
 * Other uses:
 * Make custom comparisons to turn outputs on/off. One way to simplify this somewhat
 * could be to use this code to change the value in status4 and then let the
 * existing "outputs" code that you configure in the tuning software actually
 * enable the output and turn it on or off - that might save a lot of customisation
 * and digging around in the code. Once you have status4 changing value, you are
 * nearly done.
 */

    if (flash10.user_conf & 0x01) { // is our user defined feature enabled
        //user_ulong = ????;  variables for your use
        //user_uint = ????;
        //user_uchar = ????;

        // flash10.user_conf   } These are the data 
        // flash10.user_value1 } you can prog to
        // flash10.user_value2 } flash from tuning software


        /*  if (user_uchar > 4) {
            outpc.user0++;
        } else {
            outpc.user0--;
        }
        */
    }

    return;
}
Mazda MX5 + MS3 Pro
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

gslender wrote:Question to the developers (or anyone equally smart)...
Not a single reply?

Appreciate devs are busy/got other jobs etc... just so that future expectations are set correctly, when and what would a dev be able to take time to answer reply to questions regarding development (posted in the forum area regarding MS2 development)... I'm not complaining at all, just trying to establish what to expect and how to behave etc.... so far, it is hard to judge what new folks like me should/shouldn't do to get assistance etc. I've yet to donate, but honestly I'm reluctant because whilst I'd made offers to support, with zero contact made, I'm unsure if my $$$ will actually do anything to get attention/assistance.

Again, not complaining at all, but I think others should know what to expect (inc me) so that they are aware on what to do and/or not do.
gslender wrote: Found the section below in ms2_extra_user.c which talks about if you can toggle the value of status4 you can then use the existing tuner software to enable outputs... kinda suggesting it could be set within Tuner Studio.

Which part of Tuner Studio does this?
I think I've figured this out, which means part of the Stage2 changes could be fairly easy - the Output port Settings dialog under the Extended menu seems to be where you'd define one of the many ports available to change value when status4 gets to a value required. So I'd only have to check an input for AC trigger, then wait a few cycles before setting status4 to a value that uses this config to trip an output to the value needed.

Seems a long way to do it, but it means the status4 could hold a mSec value and when it reaches, say 2500 you could then through config enable the output you need to go high or low. This means I've provided a user adjustable way to trigger when the AC activation occurs after idleup has started - so some people could have it early, or later depending on their engine needs - cool.

Any problems with this thinking?

Obviously I've still got to figure out the input detection and idle target changes.... working on that now.

G
Mazda MX5 + MS3 Pro
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

I think I've done it !! :D

The attached s19 files (both ms2 and uS2) have code changes that will add to the idle min duty after a user configurable delay. The code was from 3.13 but I don't have the source to Jean's recent 3.13a code... so I'll update when that is released.

Steps to setup/configure are...

1) Upload and use the firmware attached to this post.

2) Configure in Output port Settings a port that will be the needed trigger when the conditions Status4 > Threshold value. The value is in 10ths of a second.

3) Make sure Input PE1 goes low when the air/cond or load is on.

What happens is that when PE1 goes low, a variable ACDuty is set to 33 (roughly 13% more), which is then added to the idle code to increase idle duty. Then in the main loop, when ACDuty is set to non-zero, it starts counting on 1/10th second values to Status4... this is then picked up by 2) above to finally turn a Output high which you use to on your AC/Fans etc. The Status4 is limited to 120 (as the compare is an unsigned char) which means you can't have more than 12 seconds delay (but that should be long enough for the new idle value to have effect).

Keen for someone to try and give feedback etc... seems to work, and work well. 8)
ms2_extra_us.s19
ms2_extra.s19
Next step is to take on feedback and then think of a way to have that idle duty value user configurable via TunerStuido?? Tips appreciated. :RTFM:
Mazda MX5 + MS3 Pro
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

Here is the source files I changed from 3.1.3 release (for those that are curious about how it works etc)...
ms2extra.zip
Mazda MX5 + MS3 Pro
Greg G
Experienced MS/Extra'er
Posts: 311
Joined: Thu Mar 10, 2011 11:33 pm

Re: AC Idle Up Code

Post by Greg G »

That was quick! Did you end up removing anything in the code to make room for this?

Has this been tested on a stim, or on your car? The idle duty goes up when the compressor goes on, and the AC fan adds to the load after a few seconds? That could work...but yeah, a user defined percentage would be great for fine-tuning. Perhaps an increased rpm target also triggered by pe1 going low would help too.

Edit: oh, it needs a rewire for the AC clutch signal as well. :RTFM:

So for an NA Miata you rewire it such that 1q (AC switch) goes to pe1, then an output port triggers a relay which gives a ground signal to 1j (AC clutch) and to the AC fan relay. The time delay is preset in the code? I don't need to set it in the output conditions? So the only trigger will be status 4? If that is the case, then the other condition can still be used to implement a tps based AC cutoff?
1996 Mazda MX-5 1.6L NA6/ Mazdaspeed M45 SC/ BSP AW Intercooler/ Maruha F-cams/ 425cc RX-8 injectors/ DIYPNP

MS2/Extra test mule :)
gslender
Super MS/Extra'er
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia
Contact:

Re: AC Idle Up Code

Post by gslender »

Greg G wrote:That was quick! Did you end up removing anything in the code to make room for this?
Nope. I think the issue must be lack of input pins and maybe when you add room for TunerStudio detailed configuration etc... the developers are suspiciously vague about the "space" issues so I guess I won't know what does it until it does. But this mod seems to fit fine.... :?
Greg G wrote: Has this been tested on a stim, or on your car?
Both.
Greg G wrote:The idle duty goes up when the compressor goes on, and the AC fan adds to the load after a few seconds? That could work...but yeah, a user defined percentage would be great for fine-tuning.
yeah, I'm sure this will require a user setting as a fixed 33 add to the idle duty probably wont be enough, or might be too much for some.
Greg G wrote:Perhaps an increased rpm target also triggered by pe1 going low would help too.
Sure, need to figure out what controls the rpm target in the code.... if you sniff around the source and see something, yell out and I'll take a look.
Greg G wrote:Edit: oh, it needs a rewire for the AC clutch signal as well. :RTFM:

So for an NA Miata you rewire it such that 1q (AC switch) goes to pe1,
As long is PE1 goes to ground, yes.
Greg G wrote:then an output port triggers a relay which gives a ground signal to 1j (AC clutch) and to the AC fan relay.
Yes, I used one of the spare relay IN/OUT circuits on the DIYPNP board, but a plain relay would work too.
Greg G wrote:The time delay is preset in the code? I don't need to set it in the output conditions? So the only trigger will be status 4?
Yes, but the value that status4 climbs to is the number of "tenths of a seconds", so if you have the condition to be > 20 then it will pull up the output in 2 seconds. Cool hey... user configurable.
Greg G wrote:If that is the case, then the other condition can still be used to implement a tps based AC cutoff?
Yep, that's true, you could have AND TPS < 80% to ensure that aircond is only running in the best scenario.

G
Mazda MX5 + MS3 Pro
Post Reply