gemellocattivo.com

Which means "Evil Twin". Lets see your projects where you change boring into fun or create the fun from scratch.
It is currently Thu Mar 28, 2024 7:38 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Oct 18, 2016 8:33 am 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
The project here is to create a simulation of the engine that will allow everythign in the ECU programming to be "bench" tested. EL console has a pretty powerful simulation ability and I've done a lot of test with little patched together bits.....but that has some limits in that only bit of stuff can really be tested. What I want to do now is start to build what they call a plant model which is effectively a simulation of the engine.

t will be simple at first then get fancier as Ihave time. Like I just wrote a little program that sets the RPM to be a % of redline X TPS...change the throttle position, the RPM changes. I put it on a 50msec thread to put some lag it which will cause over-soot in any idle control code. simple but it shold work and I can fancy it up over time if need be.

Once this is done I can check all the state control I just wrote and really everything else so it will be worth the effort I think.


Top
 Profile Send private message  
 
PostPosted: Tue Oct 18, 2016 8:57 am 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
I just realized it will probably be sooner rather than later that the RPM simulation gets fancier.....if I want to model traction control RPM needs to be tied to tire friction.........hmmmmmmm. I'ts still ok for now to get the sim working but I'll need to come back to this.


Top
 Profile Send private message  
 
PostPosted: Wed Oct 19, 2016 10:52 am 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
mk e wrote:
I just realized it will probably be sooner rather than later that the RPM simulation gets fancier.....if I want to model traction control RPM needs to be tied to tire friction.........hmmmmmmm. I'ts still ok for now to get the sim working but I'll need to come back to this.


Yeah...and it utrns out that with the rpm= TPS link there is no way to test the ETC code...... :?

maybe not my best idea


Top
 Profile Send private message  
 
PostPosted: Thu Oct 20, 2016 3:55 pm 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
I've got a nice coolant temp simulation running. It looks at the mass air flow, assume 30% ends up at heat in the coolant and warms up the engine. So higher rpm or load and it warms up faster. Then when the cooling fan kick on it cools back down. So you can either set the temp you want directly or let it change in a natural like way.

Simple one done...on to something harder.


Top
 Profile Send private message  
 
PostPosted: Thu Oct 27, 2016 2:43 pm 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
More progress here even if not on the real engine.

I added a couple more little features to the coolant program. There's a thermostat setting and when it warms up and hits it the temp holds and the output is the min air flow required to keep the engine at temp.....which can be used for radiator sizing.

I also completed the throttle simulator so the throttle body moves with the pedal controled by the ECU throttle control....there si lag and overshoot and it tunes just like real.


Attachments:
throttle sim.JPG
throttle sim.JPG [ 80.25 KiB | Viewed 20507 times ]
Top
 Profile Send private message  
 
PostPosted: Fri Oct 28, 2016 3:47 pm 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
I think Ihave MAP link to throttle position in a useful way. I made 2 tables, one for the % flow of the throttlebody and 1 for the max vacuum the engine can pull at any rpm, then MAP is the flow% x the MAP range.....it seems to work.

Now I shold be able to tie RPM to throttle and have a decent simulation working....we'll see.


Top
 Profile Send private message  
 
PostPosted: Tue Nov 01, 2016 12:47 pm 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
I have RPM linked to MAP and it sort of acts right. Sort of because VE has to actuall be right in that if the engine pulls to say 70kpa with the throttle slammed shut then VE at that point in by definition 0.....and that has to be what the VE table says the way I set out the simulation or power generated will exceed the power of friction and the RPM will run away.

I think this is a real thing I never really thought much about before....and mixture can go way rich if the VE isn't set correctly at the point where the engine is pulling all the vacuum it can pull.....VE is zero so fuel flow should be 0.

Also while it seems to accelerate correctly it decelerates way to slow......I need to do something more with pumping losses think.

Back to it I guess....once I get this part sorted I want to add gears and wheel speed into the main code, then I can tie that plus veicle weight into the simulator so it will accelerate correctly "while moving" vs just against the flywheel like I have now. I want to play with tuning the idle control too.


Top
 Profile Send private message  
 
PostPosted: Fri Nov 04, 2016 9:08 am 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
Ok.
You hit start
The engine cranks
.
If you've throttle crnaking posion wide enough or manually open the throttle enough the engine will "start"

If the throttle is open too much it will surge until the idle control grabs it and takes over...if you've tunes the idle contol proberly, if not it surges will idle bouncing around.

As it "runs" it warms up and the idle setpoint drops.

Move the throttle pedal the rpm reacts.

Kind of cool. The simulaotr code is separate from the ECU code and they only touch in the SIm reads the outputs fron the ECU and supplier sensor voltages back to the ECU so the ECU thinks it's running an engine. To make the throttle work right you need to tune the throttle control properly in the ECU. To make it start and idel right you need to tune the idle control correctly.

I still have some work to do to make it so you can tune mixture.....right now the sim is reading MAF from the ECU so mixture can never be wrong. Also I don't like how I have the "engine" decelerating, that needs some work. But it already helped find and fix a couple little issues with the throttle control code and Iwant to add more safety/error checks to the throttle and everything else and this will let me test them well in a safe place away from my expensive engine.


Top
 Profile Send private message  
 
PostPosted: Mon Nov 14, 2016 10:30 am 
Offline

Joined: Thu Jan 01, 2015 6:47 pm
Posts: 4250
So the more correctly I get the sim to act like an engine the more it becomes obvious that the throttle controller is probably not going to be ably to do idle control very well......at least not on a race engine wiht huge TBs. I'll keep playing with it but I think I need a new plan....


Top
 Profile Send private message  
 
PostPosted: Fri Dec 16, 2016 11:00 pm 
Offline

Joined: Sun Oct 11, 2015 2:07 pm
Posts: 134
Have you ever used a HIL ('Hardware-in-the-loop') simulator? What you're doing is software-in-the-loop, but the end result should be similar in theory. HIL lets you test all of the hardware also.

What's the volume between each ITB and the engine (including the ports)? If it's at least the displacement of the cylinder, you could probably use some fluids equations to calculate MAP.

Basically, you need a few things:
-Table/curve of either sonic flow (flow through orifice at mach-1 flow velocity) or equivalent area or discharge coefficient.
-Pressure upstream of throttle (probably baro for you), temperature upstream, temperature in the manifold (they should be the same for you)
-VE map of the engine
-Displacement of the cylinder
-Volume of the manifold

The model needs to solve the ideal gas law several times, and the flow through an orifice.
-Store the mass in the manifold between iterations, this is the only state variable
-Calculate the pressure in the manifold from the last mass, measured temperature, and known volume (ideal gas law). This is MAP as read by the MAP sensor.
-Calculate the pressure ratio across the throttle - MAP/TIP
-Calculate the flow through the throttle from TPS and throttle pressure ratio
-Calculate mass flow into the engine at estimated MAP. This requires indexing VE, then solving the ideal gas law (P * V * VolEff) / (R * T kelvin) is Charge, multiply by RPM/120 to get mass flow per second.
-From throttle and engine flow rates, calculate flow over the calculation period, add throttle flow and subtract engine flow from manifold mass estimate, to calculate new mass for next iteration

You could either run 1 model, 2 models (front/rear), or 12 instances of the model (per cylinder). I'd start with 1 and copy-paste it when it works.

_________________
"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack

"Any sufficiently advanced technology is indistinguishable from magic" ~Arthur C. Clarke


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group