.5 to 4.5V pressure sensor to control pump

I am working on another motorcycle project, adding fuel injection. I searched this section and read a few posts about pressure sensors, but did not find exactly what I want to know.

I am using an Arduino Uno.

Here is my project concept:
I have a fuel pump that draws at most 10A on 12V. Instead of using a mechanical regulator, which adds heat to the fuel and requires a return line, I want to use a pressure sensor in the fuel rail to control the pump, which will also use less power (a factor due to the application having limited amps available). The pressure sensor uses 5V reference voltage, has a range is -14.7 to 60 PSI, and the output is .5 to 4.5V. I want to keep fuel pressure around 40 PSI.

I plan on outputting PWM through a Solid State Relay (SSR) since the motor is too large for the Arduino to control. I estimate a duty cycle of perhaps 50% will be sufficient, thereby saving power.

I have a table and formula to convert the sensor output to/from volts and PSI for any given value. The sensor also measures negative pressure, so .5 volt = -14.7 PSI. Of course, 4.5V= 60 PSI. My fuel rail will never see negative pressure. It seems like it would be best to have the Arduino's resolution only where needed, i.e. 0 to say 45 PSI. Maybe I am over-thinking this. :slight_smile:

I have read about analogRead and analogWrite, and my question is what about analogReference? Is it necessary to use this function since my sensor is not 0-5V?

Thank you for any help or advice, I am better with wrenches than volts and amps, but I enjoy learning about how to use the Arduino for projects such as this.

I plan on outputting PWM through a Solid State Relay (SSR)

Most all common SSR work only switching AC voltage on their output terminals. You would be better off using a power mosfet transistor suitable sized for the voltage and current requirements of the motor.

Lefty

I will look into that, thanks for the tip.

UPDATE
I found a relevant site here, it deals with DC motor control and gives a good example of using the MOSFET.
http://bildr.org/2012/03/rfp30n06le-arduino/

The MOSFET it references (RFP30N06LE) is shown as obsolete in the Mouser listings. I looked for similar ones and there are several to choose from. The Vishay IRLIZ44GPBF is close with 60V and 30A. Instead of a -8 +10V gate voltage, it is +/-10V.

You sensor range of -14.7 to 60 psi is obviously gauge pressure psig (pressure above atmospheric) since you cannot get negative pressures. In absolute terms (pressure above an absolute vacuum) the range is therefore 0-74.7psia

Therefore 0.5 volts represents a complete vacuum 0psia (-14.7psig) and 4.5volts represents 74.7psia (60psig)

So, simply draw a graph with .5 to 4.5 on the x axis and 0 to 74.7 on the y axis. To find what voltage is given for 40psig take a line from the 54.7 point (40 + 14.7) and where this crosses the graph will give you the voltage you are looking for. It actually works out at 3.43 volts.

Yes, you are over-thinking this.

The analogReference() can select fixed voltages. For the Arduino Uno, that is +5V or +1.1V.
Since your sensor is above the range of 1.1V, you must use the default range of 0V...5V.

I would suggest to use an integer or float variable for the pressure. And calculate the psi. So the result "could" be negative, even if that won't happen in you situation.
If you want to try using only positive values or any other kind of non-standard calculation, you end up with code that no one understands (including yourself).

There is some confusion about your sensor. Can you tell us the brand and type ?
Is it a normal (differential) pressure sensor or an absolute pressure sensor ?

Thanks for the clarifications. I came up with 3.42V @ 40 PSI.

The sensor is an AEM 5 bar pressure sensor.
PDF voltage chart

I bought the Arduino simulator program and it is very helpful. I found I don't need the analog reference at all.

Using the 3.42V as the desired input on input pin 3, this works out to 701 out of the 1023 steps (3.42V / 4.88 millivolts). I want to have the output pin (9 in this case) HIGH if the fuel pressure input value is <= 701. I also want to pulse the pump for 1/2 second when the board powers up.

I'm continuing to learn about coding. My coding is as follows and appears to work on the simulator, but I'm sure it needs refined:

int pwmPin = 9; // output pin supporting PWM
int inPin = 3; // voltage connected to analog pin 3, e.g. a potentiometer
int val = 0; // variable to store the read value
float volt = 0; // variable to hold the voltage read
// int fuelpress = analogRead(3) // Fuel pressure input on analog pin 3

void setup()
{
pinMode(pwmPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(inPin); // read the input pin

if (val <= 700)
analogWrite(pwmPin, 255);
else analogWrite(pwmPin, 0)

}

My goals now are to have an initiation sequence that powers the pump for 1/2 second and then to see if I can use variable values vs 255 (or a lesser value such as 125) when the fuel pressure is less than 40.

Other features I may add would be up/down buttons to vary the pressure point for fine tuning while it was installed, and an LED to show operation. I have a lot to learn, but am pleased with what I have thus far.

Should I start a new thread in another section since my issues now are coding?

EDIT
I think this will work for the goal of using variable PWM based on the input pin value (val) up to 700:

int pwmPin = 9; // output pin supporting PWM
int inPin = 3; // pressure sensor voltage connected to analog pin 3 
int val = 0; // variable to store the read value
float volt = 0; // variable to hold the voltage read

void setup()
{
pinMode(pwmPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(inPin); // read the input pin

if (val <= 700) // 700 is about 40 PSI
analogWrite(pwmPin, val); // runs pump until pressure reached

else if (val > 700) // 700 is about 40 PSI
analogWrite(pwmPin, 0); // shuts pump off


}

That's going in the direction I warned you about.
If you want to change something after a year you don't know what this is about : "val <= 700".
700 what ?
A computer is ment to do caculations, so let the Arduino do just that.

// Example code, not actually tested.

void loop ()
{
  int raw;
  float voltage;
  float pressure;           // pressure in psi

  // read the input pin
  raw = analogRead( inPin);

  // Calculate the input voltage
  // Using the full input range of 5V.
  voltage = (float) raw / 1023.0 * 5.0;

  // The pressure is with a linear scale.
  // 0.5 V = -14.7 psi
  // 4.5 V = 60.3 psi
  // That is 18.75 psi per voltage.
  // At 0V the (theoritically) pressure is -24.075 psi
  pressure = -24.075 + (voltage * 18.75);

  if (pressure > 40.0 )      // test pressure (in psi)
  {
    ...
  }

For the sequence, you could take a look at this MultiBlink : Arduino Playground - MultiBlink
But it is complicated. There are easier ways to do it.

UPDATE
Here is the latest sketch, with notes to myself in it for future reference:

  • Added a 1/2 second pump run time in the setup area,
  • Used map to invert the PWM output so the pump will run 100% duty at 0 PSI and taper off to about 25% just before it hits 40 PSI.

I cannot get it to turn on using the pressure formula. I am still trying to understand the pressure calcs, and will update this once I figure it out. For the time being, this does what I need it to do.

// Arduino motorcycle fuel pump controller
// Saved by Simulator for Arduino V0.98
int pwmPin = 9; // output pin supporting PWM
int inPin = 3; // pressure sensor voltage connected to analog pin 3 
int val = 0; // variable to store the read value
float volt = 0; // variable to hold the voltage read

void setup()
{
pinMode(pwmPin, OUTPUT); // sets the pin as output
analogWrite(pwmPin, 128) // primes the pump at half power
delay(500) // pump runs for 1/2 second
analogWrite(pwmPin, 0) // shuts off the pump
}
void loop()
{
val = analogRead(inPin); // read the input pin

// values for AEM 0-75 PSI presure sensor
// range of -14.7 PSI to 60.3 PSI and .5 to 4.5V
// .5V = -14.7 PSI, 4.5V= 60.3 PSI
// At 0V the theoritical pressure is -24.075 psi
// That is 18.75 psi per voltage
// Volts= (PSI+24.075)/18.75
// PSI= (18.75*(Voltage))-24.075
// 40 PSI is about 3.42V

 
// Input pin takes voltage .5 to 4.5 for 
// this sensor and converts it to a number between 0 and 1023
// Each number is .00488 millivolt (Mv) (1024/5.0 volts)
// To get PSI 0-1023 number from Mv divide input volts by .00488
// 40 PSI is about 700.
// PWM pin converts this to a number between 0 and 255 
// where 0 is 0% duty cycle and 255 is 100% duty cycle

// using map to invert PWM output so higher duty cycle at lower pressure
int valMap = analogRead(inPin);
  valMap = map(val, 0, 1023, 255, 0); // This inverts the pump's duty cycle
// to allow it to run 100% at 0 pressure and about 25% at higher pressure 
// using the 0-255 PWM value. Lower PWM can be restricted to 50% (128) by using 255, 68.

if (val <= 700)
analogWrite(pwmPin, valMap); // runs pump until set pressure reached 

else if (val > 700) // 700 is about 40 PSI
analogWrite(pwmPin, 0); // shuts pump off

}