3 state switch detection

Hi all,

Not the brightest when it comes to circuit design but know the basics at least. Working on a project for a car more specifically the switches on the pedals. What I have found is that when the switch is pressed, it's connected to ground, when released, it stays at 5V. However this is only when the car is switched on to the run position, not accessory or off. This is a problem as I need to track the switch in all power states ideally and have it digital, either pressed or not.

Obviously the simplest solution is to add a second switch but as this project is supposed to be universal and not need extra items like switches or more permenant modifications, using the existing parts is what I want. I also don't want to feed stray voltage into the controller unit.

To add to the issue, the resistance off the circuit for the pedal when the car is off measures around 1k, however even using a 1k pull-up resistor will see the voltage only climb to around 0.9v.

I'm at a loss as I just cant think of anything easy to do.

IF anyone has a good idea please let me know!
Thanks

If the Arduino is powered independently of the car (or whatever) and the switch is pulled up to the Arduino's 5v it should work regardless of the car.

So is the switch pulled up through a resistor to another 5v source?

You could disconnect the switch from whatever it's connected to and connect it to a DPDT relay with the coil always "hot" (so the relay will function when the pedal is pressed under all 3 power conditions).

Use one side of the DPDT relay to replace the current switch, and do whatever you want with the other set of contacts.

The switch is connected to the ECU which has its own 5V internal supply through which it feeds the switch with a pullup resistor. The Arduino has its own 5V supply. I don't want to cut the original wiring if possible, just connect a wire to the existing one.

With regard to the relay, as above, I want to leave as much as I can original if possible.

I would think that if you add say a 100k resistor to your 5v it should work. 100k || ECU pull up will make no difference to the ECU and the switch will happily pull both down, but when the ECU is switched off you still have a pull up.

But you say that adding a 1k doesn't work. Then I can only assume that the "switch" is not a dead short to GND as one would expect. Can you verify that it is a dead short to GND when the peddle is pressed?

The Arduino has its own 5V supply. I don't want to cut the original wiring if possible, just connect a wire to the existing one.

Then you're stuck with what you're stuck with... :wink: The existing wiring & switch don't give you the "information" you need and that's pretty-much the end of the story. It's a logic problem, not an electronics problem...

A relay is the only foolproof solution when you've got an unknown circuit, because a relay is a (electrically controlled) switch so you're replacing a switch with a switch.

OK, here's another idea, but you still have to cut a wire... Stick a diode between the ECU and the switch so the switch can pull the ECU input down, but the ECU can't pull-down the switch when it's off. Then add a pull-up resistor directly to the switch.

But, there is a slight chance that the ECU won't sense the switch properly with the 0.7V drop across the diode.

The ground is dead short to ground. Measure the other terminal and had no resistance to ground. The 1k I believe was trying to power the logic inside the ECU is my guess.

DVDdoug, your idea actually might work well. After all, it's revertable, easy to implement and shouldn't cause ECU issues. I will experiment with the though, thanks :slight_smile:

NaokiS:
DVDdoug, your idea actually might work well. After all, it's reversible, easy to implement and shouldn't cause ECU issues. I will experiment with the though, thanks :slight_smile:

It will work and is the only way to do it, and some modification is unavoidable. Note that you must also put a diode between the switch and the Arduino with its pull-up. Do you see why?

Paul_B, the source code has the Arduino set the relevant pin to have it's internal pull-up disabled, I also don't see why it would be an issue unless you meant if the Arduino was powered off, however it's going to be attached to the car's always live circuit so it shouldn't shut off, atleast it won't when the ECU will be running

Nevertheless, the point is it might be.