-1

I'm using an Arduino and I am trying to make a fuel solenoid inject fuel when the throttle position sensor voltage increases by 0.10. I'll give you a little back ground on how the system works on the engine.

  • The throttle position sensor measures the position essentially of how far you are pushing down the gas pedal on a car.

  • The throttle position sensor voltage is 0.54 volts when the gas pedal is not being touched by my foot.

  • When I push the gas pedal, the throttle position sensor voltage increases the further I push the pedal.

  • When I am maintaining a steady speed, my foot is still on the pedal, and although not accelerating, the throttle position sensor voltage is still HIGHER than 0.54 volts, but it is not varying, it is fixed at one voltage because my foot is steady.

  • When I apply more pressure to the gas pedal, the throttle position sensor voltage increases and the engine requires more fuel when the throttle position sensor voltage increases by .10 or more. It only needs more fuel for half a second.

So essentially, I cannot have something like the following:

if (TPSvoltage >= 0.54 && TPSvoltage < 0.64){

  digitalWrite(fuelSolenoid, HIGH);   // turn the fuel solenoid on (HIGH is the voltage level)
  Serial.println("Fuel Solenoid Turned on");
  delay(500);              // wait for half a second
  digitalWrite(fuelSolenoid, LOW);    // turn the fuel solenoid off by making the voltage LOW
  Serial.println("Fuel Solenoid Turned off");
  delay(1);        // delay in between reads for stability
}

I need something where if only it increases by 0.10 volts regardless of the current throttle position sensor voltage, it will turn the fuel solenoid on.

Can someone please help me figure out this code?

Thank you very much.

  • 1
    You say, it should only turn the fuel solenoid on, if the voltage increases by 0.1 V. But in which time? If for example the voltage increases over 10 seconds, should this also trigger? I think, you can do that by differentiate the voltage. But you have to decide which change should trigger the fuel solenoid. – 3dz9j56 Nov 25 '15 at 18:23
  • 1
    Can't you save the voltage in a variable? `int myVolt = 0.54` And then, do this? `TPSvoltage >= myVolt && TPSvoltage < (myVolt + 0.10) ` – Paulo Lima Nov 25 '15 at 18:29
  • 3dz9j56, It would only need to turn the solenoid on if the TPS voltage increased by .10 within 0.3 seconds. Paulo Lima, wouldn't that basically be the same thing as what I have above except that I wouldn't have to type out each voltage number? – Daniel Ricany Nov 25 '15 at 19:32
  • @DanielRicany well, I though the problem was you didn't knew the sum exactly. I guess I didn't understand the problem very well. – Paulo Lima Nov 26 '15 at 10:15

1 Answers1

3

I think you should use 2 variables instead of only 1. the first will hold the current value u are having and the 2nd will store the updated one, and then inside "if" statement if the difference of two variables is 0.10 you said then you can write the code for it, and else it will skip the code. Hope it would work for u.

Gaurav
  • 111
  • 3