11-15V to drive 2N3904 base

Hey all,

I’m trying to trigger a pin on an Arduino Nano (v3) using 11-15V. I’ve come up with the diag below, but am not sure if this is:

  1. correct (i.e. R1 and R2 values?)
  2. the most efficient way to “tell” the Arduino light the LED.

Basically, I want to be able to detect 11-15V on an Arduino pin, and have a sketch turn on the LED.

TIA for all help.
Dirk

12v_2n3904_switch.jpg

Drop the transistor, and just use a pair of resistors as a voltage divider.

dephwyggl: Hey all,

I'm trying to trigger a pin on an Arduino Nano (v3) using 11-15V. I've come up with the diag below, but am not sure if this is: 1) correct (i.e. R1 and R2 values?) 2) the most efficient way to "tell" the Arduino light the LED.

Basically, I want to be able to detect 11-15V on an Arduino pin, and have a sketch turn on the LED.

TIA for all help. Dirk

Make two small changes

1) Connect the Arduino Input Pin to the connection between the 10K and the Collector. 2) Connect the other end of the 10K to +5 Volts.

The transistor is active PULL LOW. The resistor is passive PULL HIGH.

Remove R2 (collector directly to pin D2). Use INPUT_PULLUP in pinmode. Change R1 to 100k.

Or, like Jack said, use a 1:2 divider. This is the safer way. No problems if you accidently set the pin as output. Leo..

As Leo said, it might be "safer" to use a wiring that does not present any opportunity for damage if you happen to power up you arduino with the pin configured as an OUTPUT instead of an INPUT.

Or, you can forget the arduino and get by with a resistor and a transistor.

Or, you can forget the arduino and get by with a resistor and a transistor.

except for one little detail…

I’m trying to trigger a pin on an Arduino Nano (v3)

Man, you guys all rock! :grinning:

jack wp: Not sure how I missed the voltage divider approach - probably thought the output V would be too variable for the Arduino, but nope; it's workable. I'm going with that, and, as the 11-15V can be noisy, will be adding a (zener/resistor?) over-voltage protection bit to protect the Arduino pin. Will post a schematic when done...

PS charliesixpack: raschemmel is right; this is only a one of four "trigger" circuits for an Arduino project. (I try to isolate and get answers for just the currently challenging bit.)

Dirk

dephwyggl:
…will be adding a (zener/resistor?) over-voltage protection bit to protect the Arduino pin.

Zeners don’t work as overvoltage protection.
The Arduino might be off at some stage, and then a zener is useless.

Pick the resistor values so high that the “hot” resistor can’t send more than 1mA into the pin when the Arduino is off.
So 15k for 15volt.
Calculate the “Ground” resistor to suit.
These are minimum values.
I would pick a lot higher values, e.g 47k:100k.
A 10-100n ceramic cap from Arduino pin to ground keeps the nasties out.
Leo…

A bit of background: I have programming experience, but am new to Arduinos and designing electronic circuits generally. I have a basic understanding of electricity and am learning (quickly!) about digital circuits and interfacing with analog systems. I hugely appreciate everyone’s suggestions and help - so far, and in the future.

Wawa:
Zeners don’t work as overvoltage protection.

Thanks, Leo; thought that might be the case. Thank you also for the additional voltage divider suggestions. After reviewing all the suggestions here, and my requirements for this project, I’m trying a different approach, but may return to a voltage divider arrangement.

A bit more about what I’m trying to accomplish: I need 2 parallel switches which can both provide power to the Arduino and one of them also provides a signal to the Arduino.

Required logic for the circuit:
S1 OFF, S2 OFF: Arduino powered off
S1 OFF, S2 ON: Arduino powered up; LED on (same as S1 ON, S2 ON)
S1 ON, S2 OFF: Arduino powered up; LED off
S1 ON, S2 ON: Arduino powered up; LED on (same as S1 OFF, S2 ON)

I’m expecting the Arduino to have to provide a max of 250mA (mostly to drive some 2N3904s and some existing switches on longish wires).

As mentioned earlier, the 11-15V can be noisy, and I’m trying to minimize parts count, minimize required PCB real estate, and maximize efficiency (aren’t we all?) Again, the attached circuit is only the particular parts of the project with which I’m experiencing some challenges. I’m hoping there may be a simpler way to accomplish this.

TIA for any and all suggestions.
Dirk

A 5volt Nano needs at least 6volt on Vin, because it's pre onboard 5volt regulator. 7-12volt is recommended. You're giving it 5volt - 0.7volt (diode drop) - ~1volt (regulator dropout) = ~3.3volt. It might work on that low (out of spec) voltage, it might not.

R3 is not needed if you enable the internal pullup resistor in pinmode. R2 should be 100k. The 2N3904 is only switching 500uA current from R3. R4 could be 1k for a modern LED, unless you want max brightness.

With a double pole switch with center off, you only need one (7808) regulator. The other contact can be used for ? detection. I don't understand why the two switches are needed. Leo..

Your circuit might work using LM7808 regulators

Leo, raschemmel, thank you both for your replies.

This is not a critical project and I’m (likely obviously) not in any hurry; as I said, I’m learning this stuff as I go - which you guys are making tremendous fun. :slight_smile:

{It may simplify things for everyone if I could say what this is for, but on other forums, my particular application is not allowed to be mentioned.}

The two switches are needed for the behaviour I’ve described; they are already existing switches with already existing behaviour which I’m trying to replicate with the Arduino: S1 provides only power, and S2 provides power and signals the Arduino. The LED is only there to test everything else; the actual final circuit involves two - maybe three - more existing switches and using PWM outputs to drive the base of 2N3904s which, in turn, will drive the gates on P-channel MOSFETs. The switches are on what I think would be considered “long” leads (2-5 feet, maybe more) and are inviolate (they - and the points to which I’m attaching - cannot be moved or altered).

So, from what I’ve learned so far:

  • replace 7805 with 7808
  • use INPUT_PULLUP on D7 instead of R3 (this may simplify other aspects of this project; see below)
  • as Leo suggested, I’ve added a 100nf ceramic cap from D7 to ground (C4 in attached)
  • as learned elsewhere, it appears ceramic caps may work everywhere

Concerns/questions:

  • Is the 1N4007-1 necessary? (1N4007-2 is required as it prevents S1 from triggering D7.)
  • I’m trying to decipher the L7808CV specs and they seem to indicate a Vi of 14V. Is 11V (nominally the lowest at which I’d expect everything to work) going to be sufficient, or should I be looking for something else to give 7-8V?
  • If changing to 7808s and removing R3, what should R2’s value be? (I’m thinking 100k is still OK.)
  • Also, if removing R3, the Arduino may be powered up and have the 2N3904 grounding D7 before it can be set to INPUT_PULLUP. Any concerns or does anything need be done to manage this?
  • Speaking of, the Arduino’s power-up time (seems to be .5 to 1.5 seconds) is not critical/of concern, but any of the switches may be closed when it is powered up. Does anything need attention in this regard?
  • I’m not sure of the arrangement, types, or values of the caps. I’m thinking C3 may not be needed at all (the LM7808 outputs will be close to - within 2 inches of - the Arduino’s VIN), and would prefer to use ceramic or electrolytic caps.
  • I have three other switches in the project which, when closed, go to ground and they are all spec’ing pull-ups. Instead of pulling these pins up, perhaps I can set INPUT_PULLUP for these and use a resistor in series to form a circuit from the pin to ground?

In the attached, I’ve re-arranged things to (hopefully) be easier to follow and indicates what cannot be changed. I’ve also added a third switch (S3) and second LED (LED3) to illustrate the additional switches for this project; this is to explore the possibility of not using pull-ups for the existing, grounded switches.

As always, TIA for all replies.
Dirk

That depends . Are you building an IED ? This is an Arduino forum . WE decide what is allowed (well, actually, the Global Moderators ) so why don't you tell us and let us decide if it is allowed or not. If it is not allowed, we will never speak of this again and this conversation never took place.... ;)

raschemmel: That depends . Are you building an IED ? This is an Arduino forum . WE decide what is allowed (well, actually, the Global Moderators ) so why don't you tell us and let us decide if it is allowed or not. If it is not allowed, we will never speak of this again and this conversation never took place.... ;)

Automotive. (I've noticed others posting automotive stuff, but still was not sure what is allowed...)

My frustration level has not approached the "IED point". Yet. :astonished: Dirk

You're in the General Electronics Topic, which includes Automotive, so you are cleared to speak freely...

This might give you some ideas.
47uF cap can be bigger (not an option in bloody Fritzing).
You could add a 15volt TVS diode (super zener) across that cap for extra protection.
This diagram is ok if you draw <=80mA from Nano and outputs.
Otherwise lower R1 to 33ohm.
Leo…

raschemmel:
You’re in the General Electronics Topic, which includes Automotive, so you are cleared to speak freely…

Thank you for the clarification, raschemmel.

This project is an attempt to replace vehicle turn signal flasher modules; I’m trying to make it relatively generic so it could be used on any number of vehicles. Of course, some constraints will be applied. Initially, this is for a 2014 Scion FR-S (mine) and a 2015 Yamaha V Star 1300 (my brother’s). The bike has some funky requirements, but we’re getting there slowly.

Wawa:
This might give you some ideas.
47uF cap can be bigger (not an option in bloody Fritzing).
You could add a 15volt TVS diode (super zener) across that cap for extra protection.
This diagram is ok if you draw <=80mA from Nano and outputs.
Otherwise lower R1 to 33ohm.
Leo…

Leo, thank you tons for this! While I have little doubt that this would work, I do have a few questions/concerns:

  • I asked if the diode on S1 was necessary, and looking at your circuit, I really don’t see why it’s still there. I’ve removed it.
  • I mentioned earlier that I anticipate needing around 250ma and you’re suggesting your circuit is good to 80ma. I’ve re-inserted a 7808 with clamping caps on either side. With a (likely smallish) heat sink on the 7808, will this be sufficient to provide 250ma? (Keep in mind that I’m still learning how to estimate power requirements for this type of stuff; this project may well need less than 250ma. We’ll see in the end, but I can’t see it hurting to over-design in this regard.)
  • I see you went back to (are sticking with?) a voltage divider on D7 - with C2 added to dampen spikes. (Aside: When a voltage divider was originally suggested, I did some research and came up with the same 100k/47k combination as a decent compromise on V ranges and efficiency. :slight_smile: )
  • I don’t understand enough about caps yet. What types are your C1 and C2? And why?
  • Also, for their use in mitigating spikes, is bigger generally (always?) better with caps?

All in all, I’m liking that it’s being simplified.

{I agree with your sentiment about Fritzing. On Linux, this is the best tool I have available and it - aside from some of its quirks and limitations - has been an awesome tool for learning.}

I’ve attached the Fritzing file this time as well. Note that the PCB and Code are not done/empty.

Ongoing feedback is hugely appreciated, guys!
Dirk

12v_7805_switch_d.fzz.zip (21.3 KB)

D1 is indeed not needed if nothing else depends on S1. Schematic diagram seems ok now.

Look at the datasheet for the cap value on the output of the 7808. AFAIK 10uF is common there. Or 100n ceramic and 10u electrolytic. No problem if you make the input cap also a bit bigger (10-100u).

Power (heat) generated in the 7808 is the voltage across the regulator times current draw. 15 - 5 = 10 * 0.25A is 2.5watt. A regulator with tab could dissipate ~1watt (stinking hot). For 2.5watt, a small clip-on heatsink is required. Leo..

Thank you, Leo.

Wawa:
Power (heat) generated in the 7808 is the voltage across the regulator times current draw.
15 - 5 = 10 * 0.25A is 2.5watt.
A regulator with tab could dissipate ~1watt (stinking hot).
For 2.5watt, a small clip-on heatsink is required.

This brings up a question for me: why are we having to manage that much heat with a 3-7V drop and .25A if the Nano’s internal regulator (AMS1117) can manage a 2-7V drop and .5A without a heat sink? This appears to be due to differences between the L7808CV and the AMS1117. I’d really like to stay with the TO-220 packaging, and after a bit of digging, I found the LM2940T-9.0 and also the LD1086V90. It seems these would dissipate somewhat less heat than the L7808. Thoughts?

Dirk