Arduino Forum

Using Arduino => General Electronics => Topic started by: SkyDyno on Jan 18, 2019, 12:40 pm

Title: Diode question in my Arduino project...
Post by: SkyDyno on Jan 18, 2019, 12:40 pm
Hi there...

I want to power either a 12v socket or an Arduino using a spdt switch.

so,    ON(socket) - OFF - ON(Arduino)   but not both at the same time.

I wish to have a single warning light on when the switch is in either of the ON positions. Obviously I can't just power the light from both of the switch terminals - it would make all of it live.

I am, therefore, looking to use 2 diodes to resolve this...

(https://forum.arduino.cc/index.php?action=dlattach;topic=591625.0;attach=290703;image)

Is the diagram correct? Will it work as I want?


Thanks for your time, help and patience...
Title: Re: Diode question in my Arduino project...
Post by: bos1714 on Jan 18, 2019, 12:45 pm
Hello there!

The diode part of the circuit looks good, as each diode would prevent powering the unwanted unit.


Just a couple things.

First, do you have any sort of current-limiting device for the warning light?

Second, can the diodes withstand the current you want flowing through the warning light.

Third, are you making sure that the voltage you are applying to the Arduino is not too much for the on-board regulator?
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 18, 2019, 12:54 pm
First, do you have any sort of current-limiting device for the warning light?

Second, can the diodes withstand the current you want flowing through the warning light.

Third, are you making sure that the voltage you are applying to the Arduino is not too much for the on-board regulator?
Thanks for your reply... Unfortunately for me, I'm not an electronics person, so I'm always open to advice from those that are...  As it stands at the moment the answers are:-

1.  No

2.  I'd get relevant ones (with guidance)

3.  I thought the Arduino could run from 12v (supplied to VIN)?

This is why I ask those that know... :-[

Title: Re: Diode question in my Arduino project...
Post by: bos1714 on Jan 18, 2019, 01:00 pm
Excellent.

So you are going to need some current limiting device, unless you want the warning light to explode.

When you decide what current you want through the light, we can look at some diodes.

You are correct in that the Vin pin can take 12V! I just wanted to double check.

Have you already selected the light and the switch that you are going to use? If so can you post some electrical specifications like a datasheet?
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 18, 2019, 01:15 pm
I was thinking of an automotive dashboard light or 12v LED (12v LED (https://uk.rs-online.com/web/p/products/5414072/?grossPrice=Y&cm_mmc=UK-PLA-DS3A-_-google-_-PLA_UK_EN_Lighting-_-Indicators_And_Indicator_Components%7CIndicators-_-PRODUCT_GROUP&matchtype=&pla-441483921339&s_kwcid=AL!7457!3!243856784552!!!g!441483921339!&gclid=EAIaIQobChMIns_1_aX33wIVjrftCh22hA-jEAQYAiABEgL_Z_D_BwE&gclsrc=aw.ds))

The switch is a generic spdt one... it has  6A 125VAC ; 2A 250VAC  on it's side.

So, I have the switch the rest I can get once I know what will work....
Title: Re: Diode question in my Arduino project...
Post by: bos1714 on Jan 18, 2019, 01:22 pm
Awesome.

So the datasheet for the LED says that at 12VDC you do not need a resistor for current limiting. The datasheet also mentions, indirectly, that the current would not exceed 50mA, so a 1N4148 diode (https://www.digikey.com/product-detail/en/on-semiconductor/1N4148/1N4148FS-ND/458603) should work just fine.

As for the socket, how much current would it be drawing at any given time? You will have to make sure that the switch can handle that much current.

Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 18, 2019, 01:27 pm
The socket is so that the battery can be trickle charged in situ rather that used for power which is why I don't want it live all the time...
Title: Re: Diode question in my Arduino project...
Post by: bos1714 on Jan 18, 2019, 01:30 pm
Oh I see now.

I'd say you are ready to get the components and start assembling.
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 18, 2019, 01:47 pm
OK.. on looking at these, the LED is from RS and they only list the 1N4148TR (https://uk.rs-online.com/web/p/switching-diodes/6715477/) as a 400ma not 200ma... will this make a difference? If not, I can order it all from the same place.
Title: Re: Diode question in my Arduino project...
Post by: amdkt7 on Jan 18, 2019, 02:35 pm
Yes, you can use the RS diode. It can handle far more current than the LED can. That LED has a current limiting resistor built in so it is ready to operate at 12V. Looks like a good design to me.
Title: Re: Diode question in my Arduino project...
Post by: MarkT on Jan 18, 2019, 02:42 pm
The absolute maximum DC forward current for the 1N4148 is listed as 300mA, you want to be well
below that, 150mA perhaps, for trouble-free use and long life.  That 400mA is the absolute maximum pulse
rating, not useful to you...

The 1N4148 is a high speed signal diode, not a rectifier diode designed for power, but here the
load current is within its limitations, just be aware its not going to scale to higher current uses!
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 18, 2019, 02:48 pm
bos1714 - many thanks for your help, very much appreciated.

Thanks guys... Wasn't looking to increase the load, just if it would be an OK alternative  :)


This is exactly what forums should be like.. friendly, informative and helpful.  Thank you.
Title: Re: Diode question in my Arduino project...
Post by: amdkt7 on Jan 18, 2019, 02:50 pm
He is only running one led on the diode. That is less than 20ma. But yes, I would not want to run more than 100ma through a 1N4148 on a long term bias. I would pick a different diode if I needed current higher than that.
Title: Re: Diode question in my Arduino project...
Post by: Paul__B on Jan 18, 2019, 10:12 pm
3.  I thought the Arduino could run from 12v (supplied to VIN)?
Sort of.

Only if you do not expect to power anything from the 5 V or 3.3 V pins, or more than a couple of LEDs on the data pins.

No relay modules, no display modules, no shields ...

If you anticipate doing any of these things, you need a "buck converter" module to provide 5 V.
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 21, 2019, 09:59 pm
Sort of.

Only if you do not expect to power anything from the 5 V or 3.3 V pins, or more than a couple of LEDs on the data pins.

No relay modules, no display modules, no shields ...

If you anticipate doing any of these things, you need a "buck converter" module to provide 5 V.
only to send a signal to a servo.
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 21, 2019, 10:19 pm
So I connect it all up as per my diagram.  Just to make sure that it's behaving as I want I've checked the voltages at the switch

12v at the centre pin, OFF - LED off

ON 1 - 12v out to Aruino, 0v to Socket, LED on

ON 2 - 12v out to Socket, 0v to Arduino, LED on

now the problem is that in the centre - OFF position the LED is off but there is 2v at the other 2 switch pins.... and I need it to be 0v out, LED off

now, if I unplug the bulb, it all works as expected.

So, how do I fix it...

As I stated at the beginning, I'm not an electronics bod, so help and a solution is very much appriciated.
Title: Re: Diode question in my Arduino project...
Post by: amdkt7 on Jan 21, 2019, 10:35 pm
Sounds like power is leaking from the Arduino. Do you have it hooked up to the computer at the same time? The Arduino is the only place I can see power coming from resulting in 2 volts on the other switch contacts.
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 21, 2019, 10:45 pm
Sounds like power is leaking from the Arduino. Do you have it hooked up to the computer at the same time? The Arduino is the only place I can see power coming from resulting in 2 volts on the other switch contacts.

To protect it whilst I checked, the Arduino is not connected at all. The  2v only happens when the LED is wired in. Take it out and the system works as I want.

To check that all the components are OK I built a second basic switch.. just the switch, LED and 2 diodes... it does the same. OK when no bulb, 2v when a bulb is included... I can only assume it's something to do with resistance or some such... but i sure as help can't see why I get a voltage when the switch contacts aren't touching....
Title: Re: Diode question in my Arduino project...
Post by: amdkt7 on Jan 21, 2019, 11:04 pm
Perhaps you are just seeing residual voltage due to the capacitance of the LED. If you hold your meter on it for a little while does it start to drop? The caps on the Arduino might be feeding it, they might take a while to discharge. If you put a 10K resistor to ground I bet it would go to zero fast. Probably nothing to worry about.
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 21, 2019, 11:25 pm
The Arduino isn't / hasn't been connected at all...

As for a 10k resistor, how would that be added, exactly?

...and thanks for all your time and help again.
Title: Re: Diode question in my Arduino project...
Post by: TomGeorge on Jan 22, 2019, 12:08 pm
Hi,
What have you got the Arduino I/O connected to?
What model Arduino are you using?

If you have something plugged into the 12v outlet and turned ON, what voltages do you get when your selector switch is in the middle OFF position?

Thanks.. Tom... :)
Title: Re: Diode question in my Arduino project...
Post by: amdkt7 on Jan 22, 2019, 01:35 pm
The Arduino isn't / hasn't been connected at all...

As for a 10k resistor, how would that be added, exactly?

...and thanks for all your time and help again.
The resistor would go across your LED. One side to ground, one side to hot side of your LED. It would only be there to prove that the voltage is due to diode leakage, and has no significant meaning (any load will make it vanish). Probably just hooking the Arduino up would bleed it off.

I remember seeing two volts on a circuit recently when there was a diode involved. Pretty much the same situation, I was not expecting to see any voltage, but there was 2 volts anyway. I'm pretty sure it is normal diode leakage and will not be an issue because it is micro amps, very high impedance.

Tom's reply is also a way to test it. Any load on the 12V output will make that 2V disappear.
Title: Re: Diode question in my Arduino project...
Post by: SkyDyno on Jan 23, 2019, 12:52 pm
Tom...

I have a NRF24L01 tx/rx for receiving a go command which in turn actuates a servo.The servo is powered independently from a dc/dc buck converter 12v -> 6.5v

The socket is to enable the battery to be charged without removing it from the system. The switch was to ensure that whilst the battery is being charged, the Arduino is isolated.


I have since had a play and, by putting a 2k2 resistor inline with the power to the LED the 2v discrepancy has disappeared and I get 0v at both switch terminals when in the OFF position.

Now to test it as a whole and see if it all works as I hope....

Thanks for all the advice, help and your time... :-)
Title: Re: Diode question in my Arduino project...
Post by: amdkt7 on Jan 23, 2019, 02:33 pm
It sounds like you put the resistor in parallel, not "inline" with the LED. 2.2k is pretty low for a bleed off resistor. If you did put in in series your LED will not be very bright.

It should be about 10-47K, probably even 100k would make that phantom voltage go away.

I don't think you even need a resistor at all, all that does is confirm that the 2 volts was leakage from the diodes.
Title: Re: Diode question in my Arduino project...
Post by: arduin_ologist on Jan 23, 2019, 02:59 pm
only to send a signal to a servo.
As long as it is only the signal, not the power.