Using an Arduino Uno in an automotive application

I hope this is the correct place to ask this...

I'm trying to control a crankcase vacuum pump via accelerator position. I had an Arduino Uno V3 wired to the accelerator position pedal (APP2) in my car as an analog input, an output driving the gate of a 2N3904 transistor which energizes a relay to turn on the vac pump. I have AREF wired to the supply of the APP2 since it's not referenced to the 12V feeding the Arduino. APP2 is 0.4V to 2V roughly.

It was working, but the car would occasionally throw a check engine light for P2138 (Throttle/Pedal Position Sensor/Switch β€œD”/”E” Voltage Correlation) seemingly after the output was energized. Sometimes it would throw the car into limp mode. Thinking maybe the Arduino was drawing too much current and pulling the supply down, I wired APP2 to a 4558 op amp wired for unity gain. Still didn't work and threw the same code. Realizing that I have a 2 step also wired to APP2 so maybe it's still pulling the supply down too much with both devices, I changed the Arduino input to APP1 (0.8 - 4V) and adjusted the analog values in my sketch. Now it's throwing a code for P2135 (Throttle/Pedal Position Sensor/Switch β€œA”/”B” Voltage Correlation).

I've attached a rough drawing of how this is wired. Anyone have some insight on what I may be doing wrong and how to correct it?

Hi, @mikey383
Welcome to the forum.

The throttle has two pots in it, wired differently, the ECU measures the position of each.
If you are drawing current off one of the pots, then the ECU will see an imbalance and assume the throttle has a problem.

What is APP Vref, APP and App RTN, are they the vehicle throttle pot connections?

Why have you got APP VREF connected to the UNO AVref?
The default Vref is 5V internal of the UNO. Disconnect that wire.

Your buffer amp 4558 is probably loading the pot down.

You may need some resistors in the OpAmp circuit to use it as a buffer and not affect the pot.

Also you need to add a base series resistor to the 2N3904 BJT.

I assume you want to turn the pump ON when the throttle is passed a certain position?

Can you please post your code?

Tom.. :smiley: :+1: :coffee: :australia:

Thanks Tom.

Correct, I'm wanting this to turn on once the pedal position is above roughly 70% for a second or so, then turn off a second or so after it drops below that point. I'm trying to reduce the crankcase pressure the engine sees at full throttle when engine vacuum is at its lowest (car gets drag raced often). My code works, but it has the above mentioned side effect. I'll have to post it later when I get home and back on my other computer.

APP Vref, APP, and APP RTN are the pedal pot positions. I have APP VREF connected to AREF because I was under the assumption that since the pedal pot goes through the ECU and the Arduino power feed doesn't, there wouldn't be a reference point for the analog in without having AREF connected. I tried at first without AREF connected but couldn't get it to function...but this was when I was first digging into how everything works with the Arduino, so perhaps I was doing something wrong at first.

Thinking a little more about it, the buffer amp probably isn't even needed and is loading the circuit more than just going straight to the input. A quick search led me to believe the Arduino inputs pull around 20mA while the op amp is around 2ma, but 20mA seems rather excessive to me for an input. I'll try taking that back out tonight and see what happens, maybe take my ProcessMeter home tonight and see what the actual current draw looks like.

As for the resistor, I'll add one later tonight. I'm no electronics guru by any means, but I have an electrical background and dabble in electronics here and there. My experience is more PLC programming and industrial controls, so some of this is familiar yet foreign at the same time :slight_smile:

I think you got inputs and outputs confused. The inputs pull a few uA. The 20mA is probably the max current the input protection diodes will support. How many 2N3905s have you destroyed? You need a resistor from the output pin of the UNO to the base of the transistor, try about 220 Ohm. Also add something in the 10K range from the output pin of the Arduino to ground, this will keep the relay off during reset, init, etc. A complete annotated schematic showing all power and ground connections as you have wired it will help a lot. What voltage is the op amp powered with. Why is there not something in the 20K range on the input of the op amp? What limits the voltage/current to A0? Since this is an automotive application what have you done to protect the electronics. The battery can see 24V with transients up to about 60V, the UNO will not survive. What if somebody connects the battery backwards? Where are you placing this, under hood ratings can go above 125C. This is a start. We can give you a lot more answers after the schematic (not a frizzy picture) is posted. Also post a link to technical information on the relay.

1 Like

Why not just fit a switch connected to the throttle pedal ( or at the carb end) that switches at the desired point .

1 Like

You're correct about the inputs pulling little. I checked with a meter and it was 2uA, so I removed the op amp entirely. No transistors have been destroyed so far, but I did put a 470 ohm resistor on the base of the transistor tonight. Also added a 10K resistor from the output to ground as you mentioned.

I removed AREF from the pot, and changed the code back to internal reference, and that seems to be working. Also it has more counts than using AREF. Without I'm getting around 800-825, with I was getting about 650.

A0 is limited by the voltage/current coming from the ECU. The UNO is tucked up under my dash, away from any heat and where I can get to it easily. The only protection I have on it right now is the 5A fuse that feeds it and my 2 step on the 12V keyed-on power.

Hopefully this image is okay. This is how it's set up at the moment.

Vac_Pump

Doing that was my first thought. If it was an auto car I would have probably gone that route, but being a stick car I didn't want the pump cycling rapidly during shifts. So I had to come up with something that I could put a timer on. I had all this stuff laying around, so I figured I'd give it a shot.

@TomGeorge
Here's the code:

//Arduino Uno controlling a relay for a vacuum pump. Accelerator Pedal Position (APP1) is the analog in, the LED output controls a 2N3904 transistor which toggles the relay to energize the pump
// If APP1 is above threshold for set time, energize the output until APP1 goes below the threshold for set time to allow for shifting. 


const int analogPin = A0;  //pin that APP1 is attached to
const int output = 2;   //pin that output is attached to
const int threshold = 850; //point at which output should energize
const int timer = 1200;  //value for delay timer
const int debounceDelay = 1000;  //debounce timer (to prohibit false readings)

unsigned long startMillis;  //when to start timer
unsigned long currentMillis = 0;  //comparator for timer
unsigned long lastDebounceTime; //last time output was toggled


void setup() {
 
  pinMode(output, OUTPUT);
  Serial.begin(9600); //initialize serial comms at 9600 baud
}

void loop() {
  
  int analogValue = analogRead(analogPin); // read the value of APP1 (NOTE: APP1 is 0.8-4V)

  if ((millis() - lastDebounceTime) > debounceDelay){

      if (analogValue > threshold){
        digitalWrite(output, HIGH);
        currentMillis = millis();}

  else if ((millis() - currentMillis) > timer){
    digitalWrite(output, LOW);
    lastDebounceTime = millis();}

    Serial.print("sensor = ");
    Serial.print(analogValue);
    Serial.print("/t output = ");
    Serial.println(output);

    delay(2); //wait 2 ms before the next loop for the A-D converter to settle
    
      }
  }

Hi,

You can connect to Vref, but you need to declare Vref as external in your code.
Also as long as AppVref is below 5V.

Tom.. :smiley: :+1: :coffee: :australia:

I had it declared as external in the previous code I was using when I had AREF connected to Vref. I took that code out after removing AREF.

So far it seems to be working better that way. I just came back from a test drive and no codes have been set in the ECU. I'm not sure what I did wrong originally when I tried without AREF.

If you are using an aftermarket ECU. You may have an auxiliary output you can use . Or you could fix a pot to the throttle linkage somewhere and use that .

Why not use a normal crankcase ventilation system where the crankcase is connected to the inlet manifold via a non return valve and oil trap - and runs the crank case at a slight negative pressure . Have you worked out if this will make a difference - I would have thought such pumping losses small - the change in crankcase pressure you can achieve verses combustion pressures will be very small .

( combustion pressures are far higher , than crankcase pressures say 1000psi ? - if you got the crank case pressure down to 10psi absolute , the difference is less than 1% , and getting the pressure that low is unlikely to be achievable .)
If you engine β€œ breaths” a lot , then that needs investigating

Your pump may use more power than you gain !

Your schematic doesnt show a protection diode across the relay?

2uA would have had NO effect on the throttle pot.

How does your vacuum pump cope with the oil vapour? Would it not be easier just to vent the crankcase to the outside via a trap (I did this on my rally car)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.