After some days of thinking about electronic fuel injection for a moped, ive decided to take it on. Parts come up to $80, and the rest is programming. I have never before programmed in c, c++, java, nothing! I'm quick to adapt and learn, might make some rookie mistakes but heres what I have so far. I'm programming for an Audrino UNO Board so really limited program space, but definitely doable at 300,000 cps hardware wise. ( I know spacing is atrocious but I've only been learning for 8 hours now, lol)
So Heres the question: I do not know where to begin with the loop program, I need pin6 to fire after every other highlow reading on A0. on top of that, simultaniously, i have to monitor pin A2 for a integer optimal reading of around 65 (each integer from the A/D converter is = to 4.9milli volts) int range of the A/D converter is 0-1023. if the reading is not 65, then the engine is running too lean or too rich. should i use an "if do" statement, and how would I have the program adjust the pulse width (on/off time) of the fuel injector to the right amount? would i have to make a int table, and do a little R/D as to how long with an int reading of 65 on pin A2 the solenoid opens? I don't even know what i should startoff with. below is the boot up to prep and start the engine with everything warmed up and primed
Code:
/*Goal is to manage the fuel system of a small displacement gasoline engine
using an open loop system, only anaylzing the exhaust gases through an O2 sensor.
The object is to have Audrino anaylze the voltage readings of the O2 sensor and adjust
the pulse width of the fuel injector to control the amount of fuel entering the engine.
Audrino has to be self correcting, and quick to adapt to different engine displacements of a
small range. The timing mechanism will be an analog magnetic pickup coil. The injector needs
to fire every other pass of the magnet on the flywheel
Pin labels
3=O2 Sensor Heater
4=Ready to fire LED
5=fuel pump
6=fuel injector solenoid
7=starter solenoid
8=warning LED, engine not ready
A0=RPM sensor
9=O2 sensor input
*/
void setup()
{
digitalWrite(3,HIGH); //Turns O2 Sensor Heater On
while(3,HIGH){digitalWrite(8,HIGH);delay(1000);digitalWrite(8,LOW);delay(1000);}
digitalWrite(5,HIGH); //Activates Fuel Pump
delay(3000);
digitalWrite(6,HIGH); //Fuel injector primes engine
delay(500);
digitalWrite(6,LOW);
delay(10500); //delay for the 02 sensor to finish warming up
digitalWrite(3,LOW);
digitalWrite(4,HIGH); //Indicates Engine is ready to fire
digitalWrite(7,HIGH); //turns engine over
delay(5000);
digitalWrite(7,LOW); //Kills Starter solenoid
analogRead(0); //sets A0 to read engine RPMS
analogRead(9); //reads o2 sensor voltage level
}
void loop()
{
}