ArduinoSquirt

Hi.
Im into car stuff too. And recently found the Arduino...
So now I find myself "sketching" on a kind of ArduinoSquirt. Also knowed as a type of ECU or as FuelInjection
But I dont like all the tables in a standard ECU. Its not easy to adjust and monitor.
So I have started to convert standard BPL:s (BreakPointLinearization) into a library. Then its all about curves instead of tables.
Monitoring is done via ModBus to a standard HMI.
To this point theres no hardware except a narrowband Lambda, as the first lineraization.
Its going to feed a -73 Corolla, so the first type is a monosquirt.

narrowband lambda would be quite limiting in terms of the amount of time you'll be able to go closed loop....

I know exactly what you are talking about. But its not 0V or 1V outside lambda1, even a narrowband is sort of analog between 10 and 19 afr.
Actually its just a backflipped S-curve in the specs, who is easy to linearize. Already done that, but not tested in the car yet.
Maybe its production tolerance is big, but I am pretty shure it works when calibrated. And if not, just switch to a wideband sond.
The goal is to construct a lowcost ECU, with decent performance, and a more industruial design. Not the state of art, just an ECU.
And "closed loop" is it all the way. Always calculating, but not adaptive from mappings. Just a series of BPLs. Think a little bit like fuzzy logic.

sweet!

Here is some code, well lets call it pseudocode.
When the sensors gets connected, Im going to do some filtering and averaging on the inputs too.
However,this is the principle.
All communication with the Carputer(...) is via Modbus.

#include <SRyLul/Scale.h>
#include <SRyLul/BPL.h>

// MAF, Mass air flow
float maf_inLimits[2] = {0.00, 1023.00}; // Analog in 0-5V
float maf_outLimits[2] = {0.00, 150.00}; // Air, grams/s
int maf_In;
float maf_Out;
Scale maf;

// Enginetemp
float temp_inLimits[2] = {0.00, 1023.00}; // Analog in 0-5V
float temp_outLimits[2] = {-50.00, 150.00}; // Temp -50-150 GrC
int temp_In;
float temp_Out;
Scale temp;

// Pedal position
float pedal_inLimits[2] = {0.00, 1023.00}; // Analog in 0-5V
float pedal_outLimits[2] = {0.00, 150.00}; // Pelalpos  0-100 %
int pedal_In;
float pedal_Out;
Scale pedal;

// Injector, open relative to mass air flow
float injector_X[10] = {5.00, 12.00, 16.00, 24.00, 32.00, 40.00, 48.00, 64.00, 80.00}; // open %
float injector_Y[10] = {0.00, 10.0, 20.00, 40.0, 60.00, 75.0, 90.00, 120.00, 150.00}; // 0-150 g/s
float injector_Min[2] = {5.00, 0.00};
float injector_Max[2] = {80.00, 150.00};
float injector_In;
float injector_Out;
BPL injector(10);

// Enginetemp, add fuel if cold engine
float enginetemp_X[10] = {25.00, 23.00, 20.00, 10.00, 10.00, 5.00, 0.00, 00.00, 00.00}; // open %
float enginetemp_Y[10] = {0.00, 5.00, 10.00, 30.00, 40.00, 50.00, 60.00, 800.00, 100.00}; // 0-100 GrC
float enginetemp_Min[2] = {25.00, 0.00};
float enginetemp_Max[2] = {0.00, 100.00};
float enginetemp_In;
float enginetemp_Out;
BPL enginetemp(10);

// Acceration, add fuel if "Pedal to the metal"
float acc_X[10] = {0.00, 1.00, 2.00, 4.00, 5.00, 6.00, 8.00, 9.00, 10.00}; // open %
float acc_Y[10] = {0.00, 10.00, 20.00, 40.0, 50.00, 60.00, 80.0, 90.00, 100.00}; // 0-100 % acc
float acc_Min[2] = {0.00, 0.00};
float acc_Max[2] = {10.00, 100.00};
float acc_In;
float acc_Out;
BPL acc(10);


// Lambda, narrowbandsond
float lambda_X[10] = {0.88, 0.84, 0.79, 0.66, 0.15, 0.08, 0.05, 0.03}; // 0-1V
float lambda_Y[10] = {0.68, 0.80, 0.90, 0.99, 1.01, 1.11, 1.20, 1.30}; // Petrol 10-19 afr
float lambda_Min[2] = {0.88, 0.68};
float lambda_Max[2] = {0.03, 1.30};
float lambda_In;
float lambda_Out;
BPL lambda(10);

int MafPin;
int TempPin;
int PedalPin;
int LambdaPin;
float Injector;


void setup()
{
  MafPin = 1;
  TempPin = 2;
  PedalPin = 3;
  LambdaPin = 4;
  
}

void loop()
{
    maf_In = analogRead(MafPin);
    temp_In = analogRead(TempPin);
    pedal_In = analogRead(PedalPin);
    lambda_In = analogRead(LambdaPin);

  
  maf_Out = maf.calc(maf_In, maf_inLimits, maf_outLimits);
  temp_Out = temp.calc(temp_In, temp_inLimits, temp_outLimits);
  pedal_Out = pedal.calc(pedal_In, pedal_inLimits, pedal_outLimits);


  injector_In = maf_Out;
  injector_Out = injector.calc(temp_In, injector_X, injector_Y, injector_Min, injector_Max);

  enginetemp_In = temp_Out;
  enginetemp_Out = enginetemp.calc(enginetemp_In, enginetemp_X, enginetemp_Y, enginetemp_Min, enginetemp_Max);
  
  acc_In = pedal_Out;
  acc_Out = acc.calc(acc_In, acc_X, acc_Y, acc_Min, acc_Max);

  lambda_Out = lambda.calc(lambda_In, lambda_X, lambda_Y, lambda_Min, lambda_Max);
  
  Injector = (injector_Out + enginetemp_Out + acc_Out)/ lambda_Out;

  delay(200);
}

Edit: I made a change in BPL, added min/max.
This code is 4442 bytes, still plenty of room for Modbus.

i've been toying with this idea too..
congrad's on starting.

i've built a couple of auto projects with arduino (i.e. piggyback/ smart map clamp(gear, boost), mapping wb02-nb02 driving a 24x4 lcd)

any special considerations needed for this project? (i.e. arduino is single threaded)

also, i like the idea of using a wbo2, and running ultra lean (closed loop) on the highway (similar to honda's)

why curves? if curves are needed use them to generate the tables

The o2-sensor isn't really correct used in the code, but I need it to tune and to read whats happening. Next step with the sensor is to request a lambdavalue corresponding to my actual mood... :wink:
One fun, but not difficult, use of the o2-sensor is to estimate the amount of etanol in the fuel.
I dont think its going to be an issue with speed, maybe I'm optimistic? The air flow dont actually change much faster than the trottle.
About tables: there are none, I dont want them. Thats the point of my project. Its just curves. Easy to visualize, understand and change from a laptop.
And simple code. Well, thats from my eye.
Please tell me if I'm totally lost.

Hello.
I like this project.
Do you read the wbO2 with your arduino?

I made a post here earlier about wbO2, but got no response.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1258329148/5

What do you think?

Hello andpe,
what I think? hmm...
I will read your thread tonight, look at the schematics and get back to you in your thread later. The preview answer is; yes eveything can be done, but is worth the effort in this case? How much accuracy do you need? Is it likely that the tuning guys in the BIG garage call its value "the real and only truth"? Its a good indicator, not the only.
A wideband lambda is absoulte more accurate than a narrowband. But only if its handled correctly. If you know the specs of a specific narrowband sond, then its just a matter of matematics to make it useful, sort of.
NB sonds comes with 1,2,4 or 5 wires. 4 and 5 does have the heating to keep the temerature correct.
My plan is to keep lambda around 1.00 as long as the temp isn't whitin acceptable limits and not use a heated sond.

i'm familiar with the diy-wb project -- and i decided to get the lc1 (http://www.innovatemotorsports.com/products/lc1.php), on ebay for $150 shipped.

Yepp, thats a problem solver. If its hard to build, buy it assembled.
If it was a scale, I dont care for milligrams when using i for bags of potatoes!
I'm not going to finetune my nb, just use it to teach me before and after squirting... When I know how the carb performes, my first goal is to copy that. Later on its all about a richer mix.

this is getting complicated fast

Is this the complete list of inputs?
analog -AF (narrow band-- may need option for wide band)
analog -MAP (manifold absolute pressure)
analog -engine temp
analog -IAT (intake air temp)
analog -TPS (throttle position sensor)

also needed
-RPM
-Speed
-knock sensor
-gealr detection (i.e. vary power as a function of gear: 50%-1st, 70%-2nd, 100%-other)
-drive ignition coil(s)

outputs:

  • N x injector PWM (pulse width)
  • fans?
  • fuel pump?

i'm sure there are others, short list
-LCD display (4x24 ?), 4 pins?
-tune select (min fuel, max power, etc.)
-rev limiter

Thats a long list!
My sketch is a carburetor replacement. But yes, lets do a better one.
Dialogue about what we need to measure:
Map: Rather not, Maf is better. However, more money.
IAT: Only neede if we use a Map or not a mass MAF
Engine temp: Already there.
TPS: Already there.
RPM: OK, lets add it. Doing what? CutOff?
Speed: Do we really need it? Ok, can calc gears that way.
Knock Sensor: Thrust the code? The lambda should be enough?
Ignition sensor: Yes, the code is just the input handling.
Exhaust temp: To get accurate readings from the lambda.

And what we need to control:
I want to use only 2 injectors, one big and one small. But its not cemented, a choice with numbers, size and mono/multi might look good?
FuelPump: on/off

And how we need to visualize:
A lcd is maybe (not?) fun to code. pc with a HMI software gives us the overview we need at the beginning. And saves space in the Arduino for code to run the ecu.

one of the reason I got into the arduino was to use it as a additional injector driver for turbocharged engines. I have thought it would be rather simple just using a Map and TPS as inputs. Which led me to think why not try and make it into a whole ecu.
Now for what sensor inputs you would need I believe the more you have the less drivability issues you would have. Like you say though for a simple carb replacement, just think what a carb does. They use a vacuum signal and throttle plate angle to run an engine.
As whether to use a MAP or MAF, I would say it depends on personal choice or application. I like MAP sensors my self because 1 to 3 bar sensors are easily obtained, cheap, and compact. Im thinking of motorcycle applications.
So my guess for sensors would be TPS, MAP/MAF, Engine Temp (for cold start circuit), Wideband O2 (accurate and use a 0-5V range)
outputs just would need injectors and fuel pump
this would be a good starting point for an "electric carb"

The communitys voice is Map? So be it.
Where can we find VE tables to use for converting pressure, rpm and temp to massflow? Tried to ask mr Google, but either he or me is a little bit lazy this saturday...
We are not going to use the tables as is, but convert them to formulas.

Engine Dyno 2000 is a engine simulator that I have used in the past to judge what cams I should run for my desired powerband. This program has many engines on file and you can tweak them for what ever cam, head flow, bore stroke, etc. it has seemed fairly accurate to me and it does give vacuum curve and VE across the engine rpm range. it could be used as a base line tune. Nothing out of the box will be programed right for any combo so it would all be guesses until you have some data to reference.

this link give voltage output for all GM MAP sensors aswell

When I read your link, chvyrulz350, I realized one thing:
With Map, if we only use one, we are always wrong! We need a reference to compensate for altitude and atmospheric pressure.
Yes, the lambda can correct the error, but making it right seems like a better idea? I hope we can use the lambda to tell the type of fuel but then the calcs have to be closer to correct.
So, now its 2 Maps. The second one is read by the analog mux where the most temps are too.
I will spend the week on a simple, graphical, frontend, just to be able to verify all params and inputs. Please try to remember whats left out. And choice of sensors to use, for basic tuning.
It shure accelerated when we went from basic. I might have to switch my 168 to a 328.

http://sdsefi.com/techtps.htm
they managed to tune a turbo supra using the TPS as the load input.
They also have a good tech section for tuning their ecu but i think it is generally helpful. They also rely on a narrow band O2 sensor for tuning.
Ive have close to 15 years in auto repair but im a newbie in computer programming. I have access to a Snap On tools Vantage which has sensor data for most manufacturers so if you have a particular sensor you would like to use i can probably find the values.

Exactly the right skills! Please select good, low cost, sensors and find the corresponing datasheets.
This is the second toyota link... Coincidence? My object is a 73 Corolla.

Did anything come of this?

I'm not so much interested in igntion timing as using Arduino to drive and LCD with Speedo, RPM and fuel guage and another arduino seperately for "other" diagnostic options.