Battery backed ram and other wish list ideas

It's all about the code!
Post Reply
User avatar
UnaClocker
Posts: 46
Joined: Tue May 13, 2014 12:14 am
Location: Tacoma, WA

Battery backed ram and other wish list ideas

Post by UnaClocker »

Does the code/hardware currently have a battery backed ram? Ie, when I turn off the ignition, the unit remains powered, but goes into sleep mode and draws jack all for power. This is handy for down the road when you get adaptive spark advance and adaptive fuel trim. Burning the slight changes to flash constantly will eventually wear out the flash. But storing it in ram is no good if you have to start over each time you restart the car. Factory ECM's have pretty much always had this feature. Pretty much none of the aftermarket ECM's have it though. Should be relatively trivial to implement, so long as it gets planned for in advance while we're still here on the ground floor.

You guys have a wish list/to-do list somewhere? I've got some ideas for priorities on a to-do list, but before I start reinventing the wheel, I figure I'd see if you already have a list somewhere.
Brian from Tacoma, WA
84 Dodge Rampage
01 PT Cruiser
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: Battery backed ram and other wish list ideas

Post by AndreyB »

No sleep mode yet :( That's probably not that trivial because you have to turn off all peripheral devices carefully, so on the cost/benefit ratio that would be something I'd rather not think about yet. Also since we are lazy and we are using ChibiOS/RT, to some extent it's a question what kind of sleep support they have there.

I am not sure if we have a long-term TODO/dreams list anywhere. I know we have http://sourceforge.net/p/rusefi/tickets/ but it's more short&mid-term planning.
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
UnaClocker
Posts: 46
Joined: Tue May 13, 2014 12:14 am
Location: Tacoma, WA

Re: Battery backed ram and other wish list ideas

Post by UnaClocker »

I don' t really see the RTOS as a lazy route, I think it's brilliant and for all the reasons you've stated. It's a great idea to use one.

Ok, here's some things I see on your to-do list:
First and most important, you need to be able to select the engine type/wheel decoder in the tuning program. Hardcoding this might be great for keeping the compiled code lean, but worst case, have tunerstudio upload a table file with the wheel decoder info or something (THAT is totally non trivial, I understand). But you've got to be able to setup the engine constants/type and such in the UI, not by being hardcoded in the flash.
Second, you need to be able to define the number of cylinders, ignition type (wasted spark, coil on plug, single distributor being the big main 3), number of injectors, fueling algorithm (this goes along with the next to-do item).
Third, You've got MAF support right now. You also need alpha-N and speed density. Speed density is easy as pie, physics class covered this in high school, the ideal gas law. It's just a bit of math. http://en.wikipedia.org/wiki/Ideal_gas_law and this has great info and links: http://wikitest.pgmfi.org/twiki/bin/view.pl/Library/SpeedDensity You'll need a MAP sensor of course, and a VE table for the equation to reference.

At the moment, I see those as the most important areas to focus on.
Brian from Tacoma, WA
84 Dodge Rampage
01 PT Cruiser
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: Battery backed ram and other wish list ideas

Post by AndreyB »

UnaClocker wrote:Ok, here's some things I see on your to-do list:
First and most important, you need to be able to select the engine type/wheel decoder in the tuning program. Hardcoding this might be great for keeping the compiled code lean, but worst case, have tunerstudio upload a table file with the wheel decoder info or something (THAT is totally non trivial, I understand). But you've got to be able to setup the engine constants/type and such in the UI, not by being hardcoded in the flash.
Second, you need to be able to define the number of cylinders, ignition type (wasted spark, coil on plug, single distributor being the big main 3), number of injectors, fueling algorithm (this goes along with the next to-do item).
We are already half-there.
a) trigger shape definitions (Neon, Escort, Aspire, Miata etc) are currently hard-coded. Theoretically these could be defined via tuner studio, but that would be a nightmare - 60/2 would be defined as 116 weird numbers. I guess realistically this can stay hardcoded
b) number of cylinders, ignition type... etc. While we have a number of hard-coded presets, you can already change all of these via TunerStudio. 'engine type' is just a shortcut to get to one of the hard-coded presets, nothing but that. It might still have bugs in the code around all this customization, but there is a good chance it works. See also http://rusefi.com/wiki/index.php?title=Manual:Engine_Type where I have failed to go over it.
UnaClocker wrote: Third, You've got MAF support right now. You also need alpha-N
If I understand it correctly, table-lookup based on MAF is same exact thing as table-lookup based on TPS, you just use another sensor as 'engine load' parameter. If that's right, we already have alpha-n
UnaClocker wrote: and speed density. Speed density is easy as pie, physics class covered this in high school, the ideal gas law. It's just a bit of math. http://en.wikipedia.org/wiki/Ideal_gas_law and this has great info and links: http://wikitest.pgmfi.org/twiki/bin/view.pl/Library/SpeedDensity You'll need a MAP sensor of course, and a VE table for the equation to reference.
WIP
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
Nobody
Posts: 98
Joined: Wed May 28, 2014 9:12 pm

Re: Battery backed ram and other wish list ideas

Post by Nobody »

If a LTFT (long term fuel trim) and STFT (short term fuel trim) model was adapted, then saving to say a serial EEPROM would be viable.

LTFT can be considered course adjustment and STFT fine adjustment. LTFT can be saved to EEPROM maybe even Flash if done correctly (writes should be limited in nature). Most limit fuel trims to +/- 25% but have seen 50% on some aftermarket units (I think 50% is nuts).

Implementation varies greatly, but usually when STFT is pegged/or maxed out for x time it will increment or decrement LTFT by a set amount. What determines if LTFT is incremented or decremented is if STFT is positive (+) or negative (-) when maxed out. It should go without saying that you cannot have one trim set (LTFT + STFT), but need an array or table of them… You can be lean at low RPM low load, but rich at say slightly higher RPM with a little more load. Trims are usually setup as cells that cover x RPM - x RPM at x MAP - x MAP. Also if you have two O2 sensors then you have bank1 and bank2 trims (V-6, V-8…).

Also look at http://www.fujitsu.com/downloads/MICRO/fsa/pdf/products/memory/fram/SPBG_FRAM_Overview_BR.pdf
1 trillion read/write endurance, doubt you could wear it out, if implementation is correct.

Spark, that's testing knock threshold, maybe leave that for a while.

Some food for thought moving forward with firmware…
Last edited by Nobody on Thu Sep 04, 2014 9:52 pm, edited 1 time in total.
User avatar
UnaClocker
Posts: 46
Joined: Tue May 13, 2014 12:14 am
Location: Tacoma, WA

Re: Battery backed ram and other wish list ideas

Post by UnaClocker »

Another thing having the processor simply "sleeping" would be good for is being able to determine when the last start was. One thing that always drove me insane with the MegaSquirt was trying to get the first start of the day rich enough. Doesn't matter that the engine is the same temp it would be after having sat 3-4 hours, according to the temp sensor. It still wants far more fuel because it's truely cold, than simply sitting 3-4 hours. 12 hours after I've shut the engine off, everything is cold. Same kind of deal with hot restarts, it's got no way to know that I ran into the store for 15 minutes and now all these crazy high temp readings, especially the air temp, are erroneous. Sure, there are some clever ways to try to work around it, which led to some very intellectual debates on the MSx forum, but in the end, simply knowing how long the engine has been off will do wonders for solving these problems.
Brian from Tacoma, WA
84 Dodge Rampage
01 PT Cruiser
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

Re: Battery backed ram and other wish list ideas

Post by abecedarian »

If you have EMI, use FRAM instead of EEPROM and longevity issues are solved for at least 100 years.

Heck, even EEPROM would last once you consider that long term trim won't change very often... maybe once every few months. Short term trim is highly dynamic so no immediate need to save that unless it goes out of range and thus affects long term trim. Just ask my Toyota pickup.

If you have, say, 16KB tables, and 64KB EEPROM, you could offset / page through the EEPROM and extend the life of the EEPROM / tables by a factor of 4, so instead of 10000 writes (arbitrary limit) you would have 40000. That's enough for one write a day for more than 100 years.

Now, you could use external FRAM and more than quadruple that write limit. ;)
You can lead the horticulture but you can't make them think.
puff
contributor
contributor
Posts: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: Battery backed ram and other wish list ideas

Post by puff »

as far as i got the point, it's more the matter of clock (the time the engine was shut down), rather than safely storing extra tables...
User avatar
UnaClocker
Posts: 46
Joined: Tue May 13, 2014 12:14 am
Location: Tacoma, WA

Re: Battery backed ram and other wish list ideas

Post by UnaClocker »

Yeah, rather than beat around the bush with excuses to not do it, let's just do it. We're still in early days of the project, now is the time to put in fundamental features like this.
Brian from Tacoma, WA
84 Dodge Rampage
01 PT Cruiser
Nobody
Posts: 98
Joined: Wed May 28, 2014 9:12 pm

Re: Battery backed ram and other wish list ideas

Post by Nobody »

as far as i got the point, it's more the matter of clock (the time the engine was shut down), rather than safely storing extra tables...
I’m not sure I understand… Cold/hot starts should have nothing to do with fuel trims, unless engine is already warm enough to go into closed loop. Even then there is a delay. Cold/hot start issues are usually tune/calibration related, unless cranking functionality is missing. Time between engine starts should be irrelevant (it is on every ECU I’ve dealt with and not tracked, distance and time to clear codes is, but this is running time). NOTE, never used MS, but anything GM, Ford (mustangs), Motec, ProEFI, BigStuff3… I have used, so have a decent understanding on how to setup/calibrate/tune.

What are fuel trims? They are O2 based feedback vs base engine definition, represented as a + or – error based on stoichiometric value for a fuel. What is a base definition? Doesn’t matter if it’s S/D (speed density) or MAF (mass air flow), but it’s what injector pulse width is calculated from (over simplified)…

Why should you use O2? Well AFR (air fuel ratio) changes with fuel type, for gasoline its 14.7:1 but if you use ethanol blend (10% - E10) its 14:6:1. Also you will have variations over time such as MAF getting dirty and underreporting mass flow…

If at this point, if there is such an aversion to tables then not sure what to say??? To have a reasonable ECU, you need 12+ tables. Most decent units have 50 or more… factory (OEM) units exceed 100 easily. No it’s not for the sake of adding tables, but covering robust set of conditions/states without baking in fudge factors.

In looking at STM32F4xx datasheet there is 4KB of battery backed-up ram, why not use it? It’s on smallish side, but basic adaptive functionality can be utilized.
Last edited by Nobody on Thu Sep 04, 2014 9:52 pm, edited 1 time in total.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Battery backed ram and other wish list ideas

Post by kb1gtt »

On the brain board, there is a battery located on the bottom side of the PCB, which via jumper setting can power the "vbat" pin. Does that offer the feature that's being talked about? Seems that from a hardware side of things, we may already be planning for this option. If that is correct, then can I encourage someone to draft the code or draft the flow diagram of the code?
Welcome to the friendlier side of internet crazy :)
Nobody
Posts: 98
Joined: Wed May 28, 2014 9:12 pm

Re: Battery backed ram and other wish list ideas

Post by Nobody »

Well one thing that surprises me is, I have not seen any mathematical or systematic approach mentioned on this forum on how to actually control an engine. I have yet to see a book on coding of an ECU, so work is required here.

A few examples;
* How much timing do you pull vs IAT (inlet air temperature) and how. Each engine is different so can’t hard code, also what works for naturally aspirated does not work for forced induction (supercharger/turbo/nitrous oxide). How much advance an engine will tolerate vs temperature can vary by over 20 degrees.
* How to handle startup enrichment.
* How to handle engine over temperature? Enrich, pull timing, skip every other cylinder and not fuel???
* How to handle wide open throttle, can’t be at 14:7:1 AFR as engine will not live long.
* Idle control.
* Critical characterization i.e. MAF.
* Injector characterization - this could be a short novel.
* How to actually run closed loop and under what conditions. With narrow bands they are pretty much useless outside lambda of 1. Read into this, that you will ignore them under higher loads.
* DFCO - decel fuel cut off.
* Clear flooded engine.
* Knock sensors could become another short novel.

The equations when broken down into smaller subsets are not that complex.

Also if it wasn’t clear in previous posts, trims are an autotune function under low load conditions…

What I'm trying to get at, is it needs to be looked at as whole first...
Last edited by Nobody on Thu Sep 04, 2014 9:53 pm, edited 1 time in total.
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: Battery backed ram and other wish list ideas

Post by AndreyB »

Elaborating all these questions in a good systematic way would be writing that 'ECU coding book' exactly :)

I am one little man so I can only digest one topic at a time - right now I am focused on SD (that's on top of moving my apartment to the East Coast). Once/if we have more active software developers, more topics could be worked on simultaneously.

Your own project, would it need any of these algorithms?
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
Nobody
Posts: 98
Joined: Wed May 28, 2014 9:12 pm

Re: Battery backed ram and other wish list ideas

Post by Nobody »

All I’m trying to do, is to nudge/push certain topics forward… If as an example a few people tackled one very simple aspect, ECU coding could be defined within months.

As far as my project, defining critical algorithms was done before a single line of C was written. They have been tweaked/enhanced over time. As an example I have switched to a different “fuel trim” model, in which I use PID (proportional integral derivative) control loops, more complex but faster responding. Currently bench testing DBW (drive by wire) with 2 different throttle bodies (90 and 87mm). On my end I’m set at this time (have what I need), also mine is not open source.

I started with simple equations just like the one I posted for S/D (speed density) and expanded upon them. This can initially be done in excel or Mathcad or similar (much easier to catch mistakes then trying on engine, safer too).

My $0.02.

Good luck on the move.

EDIT - I'll help push certain aspects forward...
Last edited by Nobody on Thu Sep 04, 2014 9:53 pm, edited 1 time in total.
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: Battery backed ram and other wish list ideas

Post by AndreyB »

Nobody wrote:Currently bench testing DBW (drive by wire) with 2 different throttle bodies (90 and 87mm). On my end I’m set at this time... I'll help push certain aspects forward...
Here you are - http://rusefi.com/forum/viewtopic.php?f=5&t=592 :)

There are multiple ways to cook this cat - there is too much work and not enough Indians. I am attacking it a more agile way, what you suggest is more waterfally. Just different approaches, same goal. I would not be able to pull this by myself - I am focusing on having SOME implementation and some hardware to have enough people interested so that hopefully this would become a joint effort.
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
Post Reply