Water methanol injection and protection

Good day guys

This one should be easy for the experts heheh

My next project Involves controlling and monitoring of water methanol injection.


*Toggle switch
*adjustable boost presure switch( NO contact)
*check for injector energize (wire wound around the positive of the injector wire)
*methanol pressure switch.(adjustable and NO contact)
*methanol tank levle switch.


*Air solinoid
*Red LED
*Green LED
*Yellow LED

So this is what my thought process is.

The system wil be on with ignition on , but not Activate until the Toggle switch is set on.

When the toggle switch is set on the system wil go in "Arm" mode.

When in arm mode the air solid needs to energize if the Level switch is Active. If the level is low the red led needs to turn on also.

Then the system waits for the input of the presure switch. When it senses the presure switch, it needs to energize the injector. Then after a set amount of milliseconds if the controller doesn't see the input from the wire wound around the injector power leads , the controller needs to switch off the air solenoid. And stay in the Error mode until the toggle switch is Toggled off and on again. This will protect the engine if the injector fails electrically. And the red led must flash.
If at any time the level in the tank is low the air solinoid also needs to de- energize. And the red Led needs to turn on constantly.

This way i can see by the state of the red led what error occurred.

Then also the yellow led when the injector is energized and green LED when the system is In Armed mode.

What are your thoughts on this ? And also if there is someone willing to help me with the code i would appreciate it lots im still a noob at writing code but i can read it and the electronics side i know good.

Thoughts? I see pipe dreams. Do you have the components and have you written individual programs to learn how they operate and how to control them?


If you want someone to write the code please post in the Gigs and Collaborations forum.

I am very slowly working on a similar project. I do not quite understand what an 'air solenoid' does for water injection. Or is that what you use to cut boost on error?

I was considering similar safety sensors but I decided to go with a flow sensor instead. There appears to be a cheaper alternative on ebay now but the one I got was pretty cheap.

I also feel that a dry relay output is necessary to cut boost on error beyond just a red led.

Finally, I am using a pressure sensor instead of a pressure switch since it is both smaller and cheaper.

I am more interested in proportional water injection, so I am monitoring the voltage at a fuel injector to measure the pulse width and therefore the instantaneous fuel usage. (may not actually work on low impedance 'peak and hold' fuel injectors) Then, depending on the calculated amount of water desired, I will turn on or off several different sized spray nozzles.

I will probably add a manually built table of flow rates to trigger an error if too much or too little water is flowing based on tests with various spray nozzle configurations vs various manifold pressures.

I have bought and tested a few parts but my project is still mostly in my head. But anyway, it's not all that difficult if you break your project into single steps and write a program for each step and then combine all the steps for your final project. You will probably find that each step you want to learn is almost exactly the same as many of the simple beginner tutorials available here. Like measuring a voltage, or detecting a voltage, or blinking an led, etc.

I have bins full of components an have written many basic codes but nothing this complicated yet , if i posted this in the wrong section i apologize

As for the "air solinoid" what i meant was a pneumatic solinoid.
And the boost can be controlled by this solinoid, if the solinoid is not energized then the car wil only boost wastegate pressure. If the solinoid is energized then the pathway goes through a regulator witch will increase the boost pressure.

Your project sounds very interesting indeed.

Possible begin by writing down on paper what needs to be done in the beginning of the program to verify the operation of each component. Then on another paper write down the sequence of tests and operations that need to be done on a recurring basis for the main "loop" of your program.

Then you can think about what code to write and begin testing as you go along through your written documents. Never wait till all the code is done to begin testing.


Great advice thanks ill post my progress soon

Please advise me , i have written most of the code(i think) now i want to post it and ask for some advice coding in a time delay for the safety, is this the right part in the forum to post the code ?


okay so this is what i have so far


  The circuit:
  - pushbutton attached to pins from +5V
  - 10K resistor attached to input pins from ground


// constants won't change. They're used here to set pin numbers:
const int ActiveToggle = 2;     // Arm toggle switch
const int BoostSwitch = 3;  // Boost switch activate
const int LevleSwitch = 4; // Tank Levle
const int InjectCheck = 5; // Check if injector is on
const int Solinoid = 6;    // Pnumatic valve
const int Injector = 7;    // Injector
const int RedLED = 10;    // Red led
const int YellowLED = 11; // Yellow LED
const int GreenLED =  13;      // Green LED

// variables will change:
int ToggleState = 0;         // variable for reading thestatus
int BoostState = 0;
int LevleState = 0;
int InjectState = 0;

void setup() {
  // initialize the output pins:
  pinMode(GreenLED, OUTPUT);
  pinMode(YellowLED, OUTPUT);
  pinMode(RedLED, OUTPUT);
  pinMode(Injector, OUTPUT);
  pinMode(Solinoid, OUTPUT);
  // initialize the input pins:
  pinMode(ActiveToggle, INPUT);
  pinMode(BoostSwitch, INPUT);
  pinMode(LevleSwitch, INPUT);
  pinMode(InjectCheck, INPUT);

void loop() {
  // read the state of the Input values:
  ToggleState = digitalRead(ActiveToggle);
  BoostState = digitalRead(BoostSwitch);
  LevleState = digitalRead(LevleSwitch);
  InjectState = digitalRead(InjectCheck);

  // Check the state is HIGH(ON):
  if (ToggleState == HIGH and LevleState == HIGH){
    // turn Green LED on and solinoid:
    digitalWrite(GreenLED, HIGH);
    digitalWrite(Solinoid, HIGH);
  } else {
    // turn Geen LED and solinoid off:
    digitalWrite(GreenLED, LOW);
    digitalWrite(Solinoid, LOW);
      //this is where the program must check if the boost switch is activated with all other conditions.
       if (ToggleState == HIGH and LevleState == HIGH and BoostState == HIGH){
    // turn Green LED on and solinoid and Injector and yellow LED:
    digitalWrite(GreenLED, HIGH);
    digitalWrite(Solinoid, HIGH);
    digitalWrite(Injector, HIGH);
    digitalWrite(YellowLED, HIGH);
  } else {
    // turn Geen LED and solinoid off and yellow LED:
    digitalWrite(GreenLED, LOW);
    digitalWrite(Solinoid, LOW);
    digitalWrite(Injector, LOW);
    digitalWrite(YellowLED, LOW);

The code so far in Simulation seems to be working just fine , but the next step is still vague to me,

after the BoostState is high(with all of the other states also high) , the program must wait a few millisecond after it has set the Injector to high, and then check if Inject state is high( in other words this is the safety feature, if the program dosn't detect that the Inject state is HIGH after lets say 5 milliseconds it needs to set the Solinoid state to LOW , The Injector to low and also Flash the RED led , the program should not start up again until the ToggleState is Set to LOW and Then HIGH again

i am not relay sure how i would go about to program that in

I would create a variable to hold the last time all statuses were good.
Every loop through the program, I would check that all statuses are good, and if so, reset the variable to now.
If the time between the last good status and now ever gets larger than your error window, then do whatever error process you need.

If your 'good' status is not cleanly on or off you might need to debounce or average the results. It would depend on how noisy your environment is.

Note, remember to allow for timer rollover:
If (millis() > LastGoodStatusTime + ErrorWindow) ; // BUGGY version
If (millis() - LastGoodStatusTime > ErrorWindow) ; // CORRECT version

Although you will probably never rollover millis() (50 days). You could run long enough to rollover micros() (70 minutes).

A simpler method might be to create an error counter.

Every pass through the loop with bad status, you add one.
Every pass through the loop with good status, you subtract one. But stop at zero. (or subtract 2, or reset to zero, etc.)
If the error count gets above the error threshold, do the error subroutine.

This method is not time based, it depends on the number of loops executed per second.

Lots of different ways to do this.