Engine control Logic - enginelab example

Post Reply
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Engine control Logic - enginelab example

Post by mk e »

Not sure if this is of any interest to anyone other than me but I'll share anyway :)

Attached are:
Tuning manual - a word doc that explains how to use most of the furntions and kind of how they work
Engine_Sim_12_06_V97 - ECU code and engfine simulator write in EL Concole, free dowload
Engine_Sim_12_06_V97flow - The code flow chart writen in yEd, free download
Layout-Engine_Sim - the tuner interface infomation for EL console.

To play with it you need to download ElConsole:
https://enginelab.net/downloads/#

Unzip and open the model and layout, then hit altR and the simulator will start running. The ECU will run ans an engine simulator will alos run, the enign simulator reads the ECU outputs and feeds it sensor signals to make the ECU portion believe it's running an engine. It uses electronic throttle control so when you hit altR the throttle goes to the start position, the engine start cranking then starts and rpm surges are HP output exceeds friction loads then the idel control code grabs the throttle and it settles in to idle. Move the throttle pedal slider and simulated throttle actuator responds (PID controlled so you can tuning...or untune it as the case may be) and rpm goes up. Move the slider back and it will settle back to idle gentle with the idle ramp down model in operation. There is a coolant warm up function that heats the coolant based on heat capacity of the coolant/engine and the heat generated by the burning mass flow flow so rev it more and it warms faster so any coolant based function in the ECU code will be reacting. At idle you can turn on the cooling fan and the engine temp will go up/down as the fan cycles on/ff to keep the temp in range...but like a real engine it will over heat at higher rpm where the fan flow in not adequate to remove all the heat.

If you want to see the code, in ELconsole go Target>channel list

you can download yed at:
https://www.yworks.com/products/yed/download
And look at look at model flow.

edit - go Layout> hierarchical so it views right

I have more to do on the manual to include the sim function (its ecu only now) and better descriptions of function but it's a start and it should be able to run an engine...should.....
Attachments
Layout - Engine_Sim.zip
(6.75 KiB) Downloaded 389 times
Engine_Sim_12_06_V97flow.zip
(34.21 KiB) Downloaded 374 times
Engine_Sim_12_06_V97.zip
(28.54 KiB) Downloaded 362 times
Tuning Manual.zip
(1.31 MiB) Downloaded 388 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: Engine control Logic - enginelab example

Post by AndreyB »

This is very interesting stuff, thank you! I am still trying to understand what exactly is it I am looking at?

https://en.wikipedia.org/wiki/YEd
free general-purpose diagramming program with a multi-document interface.
written in Java

https://enginelab.net/products/ these looks the same as http://www.aemelectronics.com/?q=products/programmable-engine-management-systems/infinity-ecu and
EngineLab’s primary customer is AEM. The EL technology is at the core of AEM Infinity product line.
And "An end user can use the tool without a license."

So is this somehow a company independent from AEM which is the basis of AEM ECU, minus the actual 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
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

Engine lab designed the current line of AEM ECUs and they run on the enginelab firmware with a version of EL console modified to remove the ability to view or edit the model (algorithms). AEM had an exclusive license for automotive retail but that has now expired and enginelab is making a very slow entry into retail.

I don't know for how much longer they will do it but in the past you could buy an AEM ECU (I got mine on ebay for $1000) then send the serial number to enginelab and they'd register it and give you access to the full enginelab SW/FW.

The files I posted are items I wrote in the engine lab environment. It works a bit like c in that the best way to make a big file is with a lot of little files.....the model I posted is stitched together from around 100 submodels with a build script. There is talk that there will be a library of submodels available for download/sharing and I know at least a "demo" ecu model is under construction (I'm helping create it but it will different from what Ipost which is my own) but at the moment you're on you own model wise.

When you save a model elconsole generates 2 files. One is the actual model which is the x.elcfg and the other a x.graphml which is read by yed to show the model as a flow chart below is a screen shot of yed file from one of the fuel system submodel.....the full model version I attached to the first post is a tad more involved :)
Attachments
Cylinder base fuel.JPG
Cylinder base fuel.JPG (72.93 KiB) Viewed 21982 times
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

Forgot to get to the main point. The software is free and the simulation ability is pretty good. You can create the ECU model then you can create a separate model by assigning the items to "plant". This is what I have in the model I posted so it's simulating the ECU and simulating an engine reacting to the ECU outputs and retuning sensor value back to the ECU.

The throttle control code a PWM to the throttle simulator that has a spring/damper+ applied force model that reacts. Tune the PID wrong in the ECU and you lose control of the throttle in the simulator, it will oscillate with massive overshots or never get to the target at depending on you error in tuming.....just like a real system.

The rpm works ina similar way. It looks at throttle position and and some basic approximations of engine pumping to calculates what MAP and MAF are and from that calculates a generated torque, then subtract friction and pumping losses and that net torque acts against the rotational inertia of the engine and it accelerated or decelerates accordingly. SO if you don't have the throttle cranking position correct the engine will not "start" and will remain at cranking rpm or will surge violently on startup. The idle controller is another PID that must be tuned and just like a real idle controler you get an unstable idle if it's wrong.

Any and all ECU control logic can be tested quickly.

Being able to do this makes testing control logic pretty quick. Then once it's working it can be ported to any final form you please so I was thinking it could be useful no matter what HW you actually use....I still have a vague plan to port it into o5e someday although I'm not sure why exactly :)
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

Here is my accel/decel mixture correction model separate from the main model. There is a complete write-up on the function in the tuning manual I posted. Maybe over complicated but it should work and can not become unstable like an x-tau try approach often can.
Attachments
Wall_Wetting_yed.zip
(2.82 KiB) Downloaded 391 times
Wall_Wetting.zip
(4.62 KiB) Downloaded 355 times
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

I found an error in the injector stuff and added something for the simulation use.
Attachments
Tuning Manual 2016_12_07.zip
(6.78 MiB) Downloaded 365 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: Engine control Logic - enginelab example

Post by AndreyB »

Slowly trying to figure all this out

EngineLab_ELC8431.zip downloaded & installed
yEd-3.16.2.1_with-JRE_32-bit_setup.exe downloaded & installed

I open Wall_Wetting_yed.graphml and it shows but not a human-navigateable diagram. What do I do wrong - what do I need to click to see a diagram?
Attachments
Wall_Wetting_yed.png
Wall_Wetting_yed.png (113.08 KiB) Viewed 21941 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
RustyGargoyle
contributor
contributor
Posts: 55
Joined: Sat Dec 03, 2016 2:57 am

Re: Engine control Logic - enginelab example

Post by RustyGargoyle »

russian wrote:Slowly trying to figure all this out

EngineLab_ELC8431.zip downloaded & installed
yEd-3.16.2.1_with-JRE_32-bit_setup.exe downloaded & installed

I open Wall_Wetting_yed.graphml and it shows but not a human-navigateable diagram. What do I do wrong - what do I need to click to see a diagram?
yEd is pretty cool

to organize it automatically you can go to layout on the top toolbar and select a style.

But yEd is just for visuals. its just flow charts and graphs , diagrams etc. No actual code on it.

I havent tried this Enginelab thing but if it really simulates an engine that sounds coool
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

russian wrote:
I open Wall_Wetting_yed.graphml and it shows but not a human-navigateable diagram. What do I do wrong - what do I need to click to see a diagram?
Sorry, click layout>hierarchical

That will blow it up to a proper looking flow diagram

That is just a viewing program, to run it you need to open el console and open the file >open session > Engine_Sim_12_06_V97

Then you need a layout so go hot>layout>open layout>Layout-Engine_Sim

then altR or Target>model mode>run

and the sim is running. you'll see the rpm pop up, there's a slider for throttle pedal, move it and the throttle opens and the rpm reacts.

to see the "code" Target>Channel list

You'll see all the same functions that you saw in the flow in yed but you can edit everything in elconsole (altS to stop the model, not editing while it's running).

I did some work Friday and found couple more errors...nothing that will affect playing with the sim really but it sure wouldn't work right on an engine (an error with VE and fuel calc).
RustyGargoyle
contributor
contributor
Posts: 55
Joined: Sat Dec 03, 2016 2:57 am

Re: Engine control Logic - enginelab example

Post by RustyGargoyle »

mk e wrote:
russian wrote:
I open Wall_Wetting_yed.graphml and it shows but not a human-navigateable diagram. What do I do wrong - what do I need to click to see a diagram?
Sorry, click layout>hierarchical

That will blow it up to a proper looking flow diagram

That is just a viewing program, to run it you need to open el console and open the file >open session > Engine_Sim_12_06_V97

Then you need a layout so go hot>layout>open layout>Layout-Engine_Sim

then altR or Target>model mode>run

and the sim is running. you'll see the rpm pop up, there's a slider for throttle pedal, move it and the throttle opens and the rpm reacts.

to see the "code" Target>Channel list

You'll see all the same functions that you saw in the flow in yed but you can edit everything in elconsole (altS to stop the model, not editing while it's running).

I did some work Friday and found couple more errors...nothing that will affect playing with the sim really but it sure wouldn't work right on an engine (an error with VE and fuel calc).

ffs, did you make this yEd diagram by hand?
Hurts just to look at. Can't imagine laying it all out.
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

RustyGargoyle wrote:
ffs, did you make this yEd diagram by hand?
Hurts just to look at. Can't imagine laying it all out.
NO!!!

any time you save a model in elconsole a yed file is automatically created for you.
Last edited by mk e on Sun Dec 11, 2016 1:05 pm, edited 1 time in total.
RustyGargoyle
contributor
contributor
Posts: 55
Joined: Sat Dec 03, 2016 2:57 am

Re: Engine control Logic - enginelab example

Post by RustyGargoyle »

mk e wrote: NO!!!

any time you save a model in elconsole a yed file is automatically created for you.
I must have missed something.
I got this el console fired up with your layout files.

I have one question...
Who do you work for?
CIA? NSA? is it the EPA? are you gonna assassinate us for running all these non emissions compliant vehicles?


This software is dense AF.
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

LOL.....I design medical devices in my day job so you're good :)
RustyGargoyle
contributor
contributor
Posts: 55
Joined: Sat Dec 03, 2016 2:57 am

Re: Engine control Logic - enginelab example

Post by RustyGargoyle »

mk e wrote:LOL.....I design medical devices in my day job so you're good :)
That sounds pretty serious. So your an EE?
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

RustyGargoyle wrote:
mk e wrote:LOL.....I design medical devices in my day job so you're good :)
That sounds pretty serious. So your an EE?
ME
RustyGargoyle
contributor
contributor
Posts: 55
Joined: Sat Dec 03, 2016 2:57 am

Re: Engine control Logic - enginelab example

Post by RustyGargoyle »

mk e wrote:
RustyGargoyle wrote:
mk e wrote:LOL.....I design medical devices in my day job so you're good :)
That sounds pretty serious. So your an EE?
ME
dear god, can't imagine the complexities associated with that.
Not like designing an adapter plate or something, has to work on a human.

unless you meant medical devices as in "marital aids". then that is another story. :lol:
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

RustyGargoyle wrote:
dear god, can't imagine the complexities associated with that.
Not like designing an adapter plate or something, has to work on a human.

unless you meant medical devices as in "marital aids". then that is another story. :lol:
It's a lot of statistics or at least it was when I was doing stuff for fixing hearts, I moved to dental a few months ago which for the most part isn't going to kill anyone and in most about aesthetic and price.

Back on topic, the layout is fast. Literally right-click>select what you want to add (gauge, slider, etc.), select the channel it should be reading/writing, the drag it into place. You could build that whole layout from scratch in under an hour.

For me, (not being a programmer and prone to many, many typos) its really nice to be able to get the ECU to do what I want and try it on the PC not an engine. Testing on a PC also means I can "work on the car" at lunch time so its not so hard to find quite time away from the kids to do it.
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

It did run the engine the other day for a couple minutes...before i set the shop on fire.

Note to self....don't start cars for the first time inside.........
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: Engine control Logic - enginelab example

Post by AndreyB »

mk e wrote:before i set the shop on fire
hold on, you serious? are you fine? is your garage fine? is the engine fine?

PS: is this picture upside down?
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
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

Yes......I had a pinched injector wire that i found and fixed, but the injectors are 1000cc/min and one was spraying fuel any time the key was on. Best i can tell it filled the muffler and when the engine started it spray about 1/2 - 1gallon of gas out in a 4x15 foot flaming mess. No injuries but the shop is in the basement of our house....28k in cleanup costs before repairs and ruined stuff is replaced which probably another 10k. The estmate for the car is 6k. The engine itself was not hurt.....thank goodness for insurance.
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: Engine control Logic - enginelab example

Post by AndreyB »

Wow.
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
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

It's all fun and games until someone sets their house on fire..... :oops:

The car got banished to the garage today....and got it's first bath in 10 years on the way. then I'm losing most of the basement and the shop will need to be walled off with double drywall and it's own hvac. Lots to do
Attachments
basement 2cropped.jpg
basement 2cropped.jpg (107.36 KiB) Viewed 21785 times
wash.jpg
wash.jpg (83.15 KiB) Viewed 21785 times
garage.jpg
garage.jpg (48.68 KiB) Viewed 21785 times
megatroneye
Posts: 18
Joined: Mon Jan 09, 2017 10:52 pm

Re: Engine control Logic - enginelab example

Post by megatroneye »

mk e wrote:Yes......I had a pinched injector wire that i found and fixed, but the injectors are 1000cc/min and one was spraying fuel any time the key was on. Best i can tell it filled the muffler and when the engine started it spray about 1/2 - 1gallon of gas out in a 4x15 foot flaming mess. No injuries but the shop is in the basement of our house....28k in cleanup costs before repairs and ruined stuff is replaced which probably another 10k. The estmate for the car is 6k. The engine itself was not hurt.....thank goodness for insurance.
First of all - I'm sorry for the incident. On the other hand, let's look at it this way - you cannot make important stuff without making important mistakes from time to time.

Now, thanks a lot for this thread! I am a computer engineer currently interested in car mechanics and car tuning, and this engine simulation environment has made my day. I will keep tinkering with it for a while.
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

megatroneye wrote: First of all - I'm sorry for the incident. On the other hand, let's look at it this way - you cannot make important stuff without making important mistakes from time to time.

Now, thanks a lot for this thread! I am a computer engineer currently interested in car mechanics and car tuning, and this engine simulation environment has made my day. I will keep tinkering with it for a while.
The mess is pretty much all cleaned up at this point....and finalizing the plans for a detached garage/shop.

Glad its useful.

I made a few little changes to the engine control code, the attached version seems to run the engine correctly. I'm still working on a lot of other things so I can't say everything works the way I planned yet but it seems to be pretty close.

If you figure out how to make the simulator better please share :)
Attachments
Build_2017_03_09_V97.zip
(30.83 KiB) Downloaded 262 times
jalava
Posts: 30
Joined: Sat Apr 08, 2017 8:48 pm

Re: Engine control Logic - enginelab example

Post by jalava »

So.. we could connect brain board to this using the usb drivers provided if we can emulate the AEM/EL protocol and then develop the ECU without having it bolted on engine all the time you want to test stuff?

Of course that would be as good as the engine simulation but would allow testing quite a lot of stuff out.
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

jalava wrote:So.. we could connect brain board to this using the usb drivers provided if we can emulate the AEM/EL protocol and then develop the ECU without having it bolted on engine all the time you want to test stuff?
You don't need to connect anything, this runs on a Windows pc. You can only run EL models but you can still test any control logic you're interested in. I could probably make the engine simulation better and more complete but it's pretty good I think.
jalava
Posts: 30
Joined: Sat Apr 08, 2017 8:48 pm

Re: Engine control Logic - enginelab example

Post by jalava »

I meant from the point of integration testing it would be a nice way of developing ecu if rusefi running on actual firmware could be ran against good software emulating sensors based on injection and ignition.

That would allow us to estimate effects of jitter to afr, ect and cylinder pressure?
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

Running! ......and it only took me 9 frikin years

https://youtu.be/Pz-Oj4xJi2w

Tonight or was running without any backfiring or any other drama with 1.0ish lambda on both banks idle redline. Time to drink.
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: Engine control Logic - enginelab example

Post by AndreyB »

Big day!
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
mk e
Posts: 486
Joined: Tue Dec 06, 2016 7:32 pm

Re: Engine control Logic - enginelab example

Post by mk e »

russian wrote:Big day!
The excitement was short lived though once I calmed down and had a look at the logs.....lots of stuff need attention everywhere ...including the lying O2 sensors.

Tonight it was a little Smokey but it's finally starting to sound right

[video]https://youtu.be/2cOeKkw_0JI[/video]
Post Reply