Input Pullup Resistor always reading high

Hello all,

I am new to the forums and new to doing complex things with arduinos. I am attempting to use an arduino to create an intermittent windshield wiper system for a classic chevy truck. So far I have a 5v regulator that necks the voltage from 12V down to 5V for the arduino nano I am using.

I am using the original windshield wiper switch which works off of grounding, so in order to sense when the switch is in the different positions I had to use the internal pull-up resistors. However what I am finding is that for some reason one of my pins that goes to the switch to read whether to activate the washer pump relay is always reading high. I don't really have a good way to draw the full circuit for you so this was the best I could do.

Please let me know if there is any more information you need.

Hopefully that image helps a little (sorry that it looks like it was drawn by a kid).

Below is my code.

#define pot_pin A1
int Pot_Volt = 0;       //"voltage integer value 0 to 1023 from rehostat"
float Pot_Percent = 0;  //"Pot_volt value turned into a percentage"
int Pulse_time = 0;     //"time in ms of timer pulse"
int Pot_Volt_Map = 0;
int int_relay_signal = 9;      //Signal to activate intermittent relay
int int_relay_trigger = 7;     //Trigger to activate intermittent relay
int washer_relay_signal = 3;   //Signal to activate washer pump
int washer_relay_trigger = 5;  //trigger to activate washer pump relay
unsigned long pulse_previous_millis = 0;
unsigned long relay_previous_millis = 0;
unsigned long pulse_current_millis = 0;
unsigned long relay_current_millis = 0;
unsigned long monitor_previous_millis = 0;
unsigned long monitor_current_millis = 0;
const long monitor_interval = 2000;
int int_relay_signal_val= 0;
int washer_relay_signal_val= 1;

void setup() {
  // put your setup code here, to run once:
  pinMode(int_relay_signal, INPUT_PULLUP);
  pinMode(int_relay_trigger, OUTPUT);
  pinMode(washer_relay_signal, INPUT_PULLUP);
  pinMode(washer_relay_trigger, OUTPUT);
  digitalWrite(washer_relay_trigger, HIGH);
  digitalWrite(int_relay_trigger, HIGH);



  Serial.begin(9600);
}


void Monitor() {

   int_relay_signal_val = digitalRead(int_relay_signal);
   washer_relay_signal_val = digitalRead(washer_relay_signal);

  monitor_current_millis = millis();

  Serial.println();
    Serial.print("Monitor Previous Millis:");
    Serial.print(monitor_previous_millis);

    Serial.println();
    Serial.print("Monitor Current Millis:");
    Serial.print(monitor_current_millis);

  if (monitor_current_millis - monitor_previous_millis >= monitor_interval) {
    monitor_previous_millis = monitor_current_millis;

    Serial.println();
    Serial.print("int_relay_signal:");
    Serial.print(int_relay_signal_val);

    Serial.println();
    Serial.print("washer_relay_signal:");
    Serial.print(washer_relay_signal_val);
    
    Serial.println();
    Serial.print("Monitor Previous Millis:");
    Serial.print(monitor_previous_millis);

    Serial.println();
    Serial.print("Monitor Current Millis:");
    Serial.print(monitor_current_millis);

    Serial.println();
    Serial.print("Pulse Previous Millis:");
    Serial.print(pulse_previous_millis);

    Serial.println();
    Serial.print("Pulse Current Millis:");
    Serial.print(pulse_current_millis);

    Serial.println();
    Serial.print("Relay Previous Millis:");
    Serial.print(relay_previous_millis);

    Serial.println();
    Serial.print("Relay Current Millis:");
    Serial.print(relay_current_millis);
  }
}

void Wash() {
  if (washer_relay_signal_val == 0) {
    digitalWrite(washer_relay_trigger, LOW);
  } else {
    digitalWrite(washer_relay_trigger, HIGH);
  }
}


void Pot() {
  Pot_Volt = analogRead(pot_pin);
  Serial.println();
  Serial.print("Pot digital voltage = ");
  Serial.print(Pot_Volt);

  Pot_Volt_Map = map(Pot_Volt, 549, 1023, 0, 1023);
  Serial.println();
  Serial.print("Mapped Value:");
  Serial.print(Pot_Volt_Map);

  Pot_Percent = ((float)Pot_Volt_Map / (float)1023);
  Serial.println();
  Serial.print("Pot percenrtage = ");
  Serial.print(Pot_Percent);

  Pulse_time = ((float)Pot_Percent * (float)15000 + (float)5000);
  Serial.println();
  Serial.print("Pulse time = ");
  Serial.print(Pulse_time);
}

void relay() {

  relay_current_millis = millis();

  if (relay_current_millis - relay_previous_millis >= Pulse_time) {

    relay_previous_millis = relay_current_millis;
    pulse_previous_millis = relay_current_millis;
    digitalWrite(int_relay_trigger, LOW);
    Serial.println();
    Serial.print("Int Pulse Engaged");
  }

  pulse_current_millis = millis();

  if (pulse_current_millis - pulse_previous_millis >= 1000) {
    pulse_previous_millis = pulse_current_millis;
    digitalWrite(int_relay_trigger, HIGH);
    Serial.println();
    Serial.print("Int Pulse Disengaged");
  }
}

void loop() {
  Monitor();

  Serial.println();
  Serial.print("int relay signal:");
  Serial.print(int_relay_signal_val);
  
  if (int_relay_signal_val == 1) { 
    Serial.println();
    Serial.print("Int relay signal:");
    Serial.print(int_relay_signal_val);
    Pot();
  }
  if (washer_relay_signal_val == 0) {
    Wash();
  }
  if (int_relay_signal_val == 1) {
    relay();
  } else {
    digitalWrite(int_relay_trigger, HIGH);
  }
}

Now as you can see from the code there is a lot more circuitry and wiring other than what I showed in the image above, as there are two relays and a circuit to read the resistance of a rheostat (not potentiometer).

However none of those things should be the problem from what I can tell, unless they are causing some sort of noise that I am ignorant on.

The problem is that the washer_relay_signal is always high, the int_relay_signal on pin 9 works though. And I checked all my grounds, and ensured that the switch was grounding to the common when pressed etc.

Everything hardware side seems to be fine. My main question is if there is anything wrong with my code or if my sensing circuits need to be isolated or if there is a problem with some of the grounding routing. Also as you can see there are a lot of serial printing that I have added just to try and find where the problem is.

Hopefully someone can help me figure this out. Please and thank you.

That could be a problem, and we would never know.

The diagram you posted is not entirely clear. The switches need to be grounded to the Arduino, not to the auto body.

You show Arduino ground connected to the negative output of the 5V power supply, which may or may not be connected to the 12V ground.

If that is not an issue, then carefully check the continuity of all wiring using your multimeter, with switches closed and open.

I am aware of that, I figured I would see if there were any glaring problems with the code or the simple circuit first.

As far as this goes, I have double checked all grounds, everything grounds all the way back to the 12V negative post.

Does it matter that technically the pullup resistor circuit is parallel? What I mean by this is that to my knowledge the way the internal pullups work, is that arduino sends 5v to the pin, which then internally is connected to ground wtih a 20k-50k resistor, so when your switch is open, it takes the path of least resistance to ground through the arduino pin.

Where as when the switch is closed there should be <1 ohm of resistance so it grounds away, which makes the arduino pin read Low.

So as long as the switch is grounding back to the 12V battery, and I have double check the switch functionality and the ground that the switch goes to with a multimeter, then it should wired correctly no?

This is the rest of the circuit.

The relay board is this https://www.amazon.com/dp/B00E0NTPP4?psc=1&ref=ppx_yo2ov_dt_b_product_details

So it has a built in transistor circuit for backfeed etc.

As for why a rheostat over a potentiometer? because i am using the original switch and it had that so I am making due.

Other than that, this is the complete circuit except for the other wires for the switch, but those are simply just windshield wiper 12v+ to ground switching, which don't matter as the switch doesn't ground those in the two positions I am testing with, and I have checked there is no bridging/shorting.

Does this help show the whole circuit? again sorry I draw like a 5 year old with a mouse. Couldn't find any free software that was able to easily show the circuit.

Sorry forgot about this.

The reason I can't ground from the switch directly to the arduino is because the other 2 positions on the switch simply switch the ground wires for the 12V windshield wiper motor. So one is low and one is high. Which even though they are after the motor, to my knowledge that would still be putting a considerable current through the arduino if I tried to ground it all through the arduino.

Does this really matter though? I don't see how this could matter unless the resistance through the auto body was greater than 20Kohms, which it isn't since the other wire on pin 9 is reading correctly and they ground through the same common.

Could it be my internal pullup is fried?

And side note, as for the reason for electromechanical relays, it was simply I didn't know about mosfets at the time, so when these die from pulsing too many times I will replace with a mosfet board, as long as they don't generate too much heat since this is in a sealed box.

No. Arduino 5V is connected to an internal ~30K resistor, which is connected to the pin (if you choose INPUT_PULLUP).

The switch must either be open, in which case the pin reads HIGH, or the switch is connected to Arduino GND, and the pin reads LOW.

The reason I can't ground from the switch directly to the arduino is because the other 2 positions on the switch simply switch the ground wires for the 12V windshield wiper motor. So one is low and one is high.

Sorry, I don't understand what is connected to what. If there is any chance that the Arduino is exposed to 12V, it will be instantly destroyed.

For the switches to work, they must be connected to Arduino GND. If that is not the same as the automobile GND, you will have many troubles, and will probably destroy some Arduinos while on the steep part of the learning curve.

Optoisolators are used to switch circuits if the grounds can't be connected.

Let me ask this then. As long as when I test with a multimeter from arduino ground to automobile ground it does read continuous then would that be okay and should work properly? I guess what I'm trying to wrap my head around is whether the flow of current matters, in other words it doesn't actually need the flow to ground through the arduino, but rather just needs it to ground somewhere other than through the pullup pin with less than the resistance on the pullup? Am I way off?

As far as this is concerned there shouldn't have been any bridging between the contacts in the switch. But I will check this tomorrow and make sure that whenever the contacts with the 12V on them are being grounded that the other pins aren't also connected. I believe I already double checked this before wiring it all up, but I will check again.

Just out of curiosity, if you send 12V to an input pin would it only damage the input pin or all of the arduino?

Yes. When the switch is grounded to "whatever", there should be very close to zero Ohms resistance from "whatever" to Arduino GND.

When closed, current flows through the switch to Arduino GND. Any resistance in between causes a voltage drop, and acts as a pickup for electrical noise that interferes with switching.

Read up on "ground loops", which is a very, very serious problem in industrial and automotive settings.

if you send 12V to an input pin would it only damage the input pin or all of the arduino?

It would fry all of the Arduino and any connected displays or sensor modules, seeking all possible paths to ground.

I guess I'm confused by what you mean by this.

I would agree with this statement if I was powering the system from my arduino/USB. But the arduino is not the power source.

So this might 100% be the problem, being that I might be misunderstanding everything from the basics. But isn't digitalRead simply reading voltage of either 5V or 0V? To my knowledge the circuit of the internal pullup can be simplified and show as such:

and the reason it works is due to the high impedance value of the input pin. So basically due to the impedance the 5v from Vcc will only flow to the input pin if the resistance of the "ground" after the switch is higher than the impedance of the input pin.

Is this correct so far?

If this is correct, then it shouldn't matter whether it grounds back to the arduino or the power supply, no? all that matters is that the resistance in the ground circuit is less than the impedance of the input pin, making it read 0V or more specifically <1.5V correct?

And when I say it shouldn't matter, I mean because, everything is being powered by the 12V battery, which means that all circuits have to lead back to it, so even if it grounded through the arduino it would then continue to ground through my regulator to my 12V battery?

I think I kinda understand the ground loop ordeal, but honestly it is over my head, I am simply an MET trying to do things that are in an EE's wheelhouse.

Good engineering drawing just missing one ground point which I have added (Fig-1).
relayContact
Figure-1:

I expect you will have a lot of problems when you get this installed. If my memory is correct wipers are classified as one of the critical systems that need special care. Be sure you can turn the wipers on when your Arduino circuit fails. Read this, there is a good app note AN2689 by ST on automotive electronics. reading it will help you a lot.

What is the complete existing circuit for the wipers? I remember that when I put intermittent wipers on my first car, which I think will have been built in about 1970, the circuit wasn't as simple as you seem to be suggesting for your car. The circuit in my car included provision to short out the motor when off so as to brake it in the correct rest position.

Hello All,

Thank you for all the help and discussion so far, it is truly greatly appreciated.

Now for the answers to some of your questions. First and foremost here are the relevant pictures for this post:

Figure 1:

Figure 2:

Figure 5:

Edit: (Disregard the weird figure numbers didn't realize I could only post 3)

So first and foremost this is on a 1978 Chevy K20, of which I am using the wiper motor off of a 1983-87 truck. These trucks originally had intermittent as an option and I am using the switch for that system, however they had a pcb pulse board that control the pulsing, and even though I replaced the capacitors and resistors, it still didn't function right on 3 different boards I got at a junkyard, and the wiring I know is correct.

So instead of wasting more money on things I don't fully understand or can troubleshoot I thought I would come up with a solution using what I do kind of know from college. Arduinos.

So first and foremost as you can see in Figure 1 there are two circuits in the switch, one is just for the rheostat which I am using to determine the pulse duration, and the other is for switching between intermittent, low, high, and washer. The washer is only grounded when the selector is pushed in, it is spring loaded. Where as the other ones as you can see have spots where they are open vs closed on the path.

So as far as my system is concerned, the only two wires that are going to my Arduino are the intermittent wire signal and the washer signal, on Figure 1 pins 1 and 9. Using the internal pull up resistors I can tell when those two contacts are shorted.

However as @jremington mentioned, I know see I have a potential for 12V to back feed to the Arduino if the washer is pushed while in Low or High.

Same with the moment the switch is switched from intermittent to low.

The only other wires I have going to my Arduino are the pins 7 and 8 on the switch. 7 is simply 5V+ from my regulator and 8 is going to my Arduino analog A1 pin. Of which I am reading the voltage on to determine the pulse time. (I am aware that I need a resistor in parallel with the circuit after the rheostat to read the voltage linearly which I have added). The rheostat is a 1.47 Mohms.

As for the rest of the system, it is being left exactly as GM designed it on the non-intermittent models, as you can see from Figure 5 the way the windshield wipers originally worked is there is 12V+ with ignition on to the motor at all times, which then has two grounds in the motor, Low and High, those two go to the switch on pins 3 and 4 from Figure 1, and then get linked to common to ground through the switch. The park brake is handled internally in the windshield wiper motor with a contact arm built into it as you can see in Figure 5 originally this ground went to pin 5, but I just grounded it the firewall, as all pin 5 does, is make it so the park brake isn't grounded during low or high. I don't think that changes anything.

Now the problem, the washer pump it is the two contacts next the park brake connector in figure 5 , it works the same way as the motor, by having constant ignition 12V+ that then grounds through the switch. I originally thought I would need to run this on a relay and sense when it is pressed due to how the switch works, which is where I was having troubles with the pullup resistor and sensing it. However I am now looking at it after today and realized I have a problem where if I'm in low, high, or spring loaded low, then I have a chance of 12V grounding through the Arduino from the washer or intermittent signal wires.

So the solution I thought of was to simply keep the original system and ground the washer pump through the switch and have a diode inline with the intermittent signal wire.

Is my logic sound and would a Zener diode (first time reading about diodes if this isnt the type I need let me know) inline to the Arduino on pin 9 allow the internal pullup to still short through the switch but also protect the Arduino from the 12V?

Okay so with that book novel out of the way, let me respond to some of the questions.

I believe this is answered above, let me know if I missed anything or am wrong. I have tested this and it works.

As far as this is concerned, as you can see from my explanation, even without the Arduino, the windshield wiper will still be able to go into Low and High. So short of the motor dying it is perfectly safe. I had thought about this and made sure. Couple years as a Manufacturing Engineer handling EHS sadly programs me for this.

As far as the AN2689 goes, that is actually super interesting to read, but way over my head, and as of right now I am testing all of this will the truck off. I do have 355 ci with Edelbrock Pro flow 4 EFI, so once I get it working with the truck off, I will try it with it running and see if I have any nasty EMI noise problems, which I don't fully understand, so that will be some research.

If you have managed to read this far in, I truly thank you for your time and help. Please let me know if my new proposed plan will work, and if possible help fill in some blanks on Diodes and what I need to look out for/calculate/source. Thank you very much.

Sorry, no, you have answered very little. Lots of words. The language of electronic is a schematic, not words. In trying to read your description I have to then try to translate them into a schematic, which is difficult and error prone. Please draw a schematic with all the details. On second thoughts, please draw 2 schematics, the first showing how the thing was designed by GM and the second showing your proposed modifications. This will achieve 2 things: you will get a better understanding of what the circuit does and we will be able to see what you are doing.

While there are excellent software packages, such as kicad, for creating schematic a pencil and paper work really well too.

Is the switch in your first post connected to 17 and 18 in what you label as Figure 5 in you #12 post?

If so, please redraw those clarifications into a copy of your schematic.

Hello All,

Thank you for the feedback, hopefully this will help clarify.

This will have to be split into multiple replies due to limitation of 3 pictures per post. So first and foremost I will show the GM Schematic. (continuing with Figure numbering)

Figure 6 GM Wiring Diagram

Figure 7 Pulse Board Top

Figure 8 GM Pulse Board Bottom

Hopefully this helps someone, I understand you probably didn't want a wiring diagram, but rather a circuit for the pulse board, however that is a little above my ability, and I am not sure what a couple of the components are, as when googling the label that is on them, I find nothing. This is the reason why I am changing it to my system, because I don't know how to repair the module. So this modification isn't being done because I think I am smarter than GM engineers or anything like that, but rather because I think I am more dumber and can't reverse engineer their system.

Moving on to my circuit and system:

Figure 9 Whole Schematic

Figure 10 Windshield Wiper Switch Schematic

Figure 11 New Proposed Circuit

Again these are basically just wiring diagrams, as I am not very good at turning wiring diagrams into actual circuits, sorry.

So Figure 9 is currently what I have wired and am testing with my current code posted in the beginning. Everything works perfectly except for the windshield washer pump. So that leads to Figure 11.

Figure 11 is the new circuit that I think would solve my issue, by making the Arduino only control the intermittent and everything else be original. Everything not pictured in Figure 11 is the same as in Figure 9. Please let me know if there are bullet holes in the new plan, of which I would basically just remove the void Wash() from my code and the wash_relay_signal and wash_relay_trigger variables. The only thing I don't know is what Diode I would need to put in place on Switch Pin 9 to D9, not sure how much wattage or what voltage.

As far as Figure 10 goes, that is my crude way of visually showing how the wiper switch works, basically there are 5 positions as you see on the left(if rotated) and anything that is shaded in the row of the position is all bridged together and going to vehicle chassis ground. The pins 7 and 8 are on a separate circuit, but are only connected with each other when in "int". Hope this helps? maybe?

Again not an electrical engineer, so sorry I can't produce exact circuits for you for the GM stuff.

Let me know if this successful fulfills your request, and thank you very much for the help.

If you disconnect the wire from Arduino pin 3 and connect it to your red ohmmeter lead, then connect your black ohmmeter lead to Arduino GND, then turn the washer switch ON, what does the ohmmeter read?

1 Like

nor even posting them the right way up

image

Your new idea is that the arduino pin will handle all of the current from the washer pump? No. Thats why you need a relay.

1 Like

Ok, heading in the right direction. However, I still don't know what any of the connections to the motor do and the switch is somewhat confusing.

You are powering the Nano with 5V to Vin. If you are powering it with 5V then the 5V should go to the 5V pin. Vin feeds the on board regulator and requires a higher voltage.

If I understand correctly pin 2 on the switch is grounded and can, in some positions, be connected to both the motor and the Nano. This is risky because, especially when the switch is operated, there is a risk of high voltage being injected into the Nano, damaging it.

I suggest that the whole idea of having the switch control the motor directly and have it control the Nano, which also controls the motor, is flawed and is asking for trouble. I think a better approach would be to have the switch control the Nano only and the Nano control the motor via a relay or relays.

1 Like

Hi, @mslaven78
Welcome to the forum.

Do you have a DMM, Digital MultiMeter?

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