Go Down

### Topic: 5.9v wall souce to digital in of Arduino (Read 1 time)previous topic - next topic

#### kevinsa5

##### Apr 01, 2010, 04:40 am
Hey all, I want my arduino to monitor when a wall circuit is hot by seeing if current is flowing in a modded cell charger that outputs 5.9v DC. My brain's a bit fuzzy right now and I'd really love to not fry a pin/chip on my duemilanove, so I'm thinking that I big resistor will do the trick. I tried it with around 200k (I'm pretty cautious when I'm tired) worth of resistors with the built in 5v line and it worked just dandy.

First question: can a digital input pin handle 5.9v

if not, what sort of resistance do I need to bring it down to an acceptable level?

Thanks!

#### retrolefty

#1
##### Apr 01, 2010, 05:23 am
I believe that the spec is that an input voltage must not exceed .5vdc above the Vcc voltage powering the chip, so call it 5.5vdc max. What you need is a voltage divider, two series resistors connected between the 5.9vdc and ground with the junction of the two resistors wired to the Arduino input pin. Also the ground side of the power module must also wire to the Arduino ground pin.

A simpler method would be to use a small trimmer pot, say 5k or 10k ohms. Wire the +5.9vdc and ground  to the pot's top and bottom pins and wire the adjustable pin to the Arduino, along with the ground connection. I would be best to use an analog input pin rather then a digital pin.  Adjust the pot to give a mid range voltage to the arduino and your program sketch can read the pin anytime it wants to see if the voltage is present of not.

Lefty

#### dansteingart

#2
##### Apr 01, 2010, 10:49 am
Better yet use a voltage divider to an ADC with two 200 k resistors.  The overall current draw will be miniscule, and you will be within spec on the potential input to the Arduino.

#### Grumpy_Mike

#3
##### Apr 01, 2010, 11:52 am
Quote
use a voltage divider to an ADC with two 200 k resistors.

The A/D works best with an input impedance of 10K, with 200K you are likely to pick up some noise. Just to be on the safe side regarding noise put a 0.1iF capacitor from the input to ground as well.

#### AlphaZeta

#4
##### Apr 01, 2010, 02:26 pm
Wouldn't it be easier to use a diode (i.e. 1N4001) connected in series between the 5.9 and the circuit? It will bring down the voltage to approximately 5.2 and you don't have to worry about using resistors anymore...

#### Grumpy_Mike

#5
##### Apr 01, 2010, 02:33 pm
Quote
Wouldn't it be easier to use a diode

might be easer but it is not better. You still have an input that is in effect unprotected against anything but a 0.7V over voltage. At least with a potential divider you are protected against a much greater input voltage.

#### gbulmer

#6
##### Apr 01, 2010, 07:07 pmLast Edit: Apr 01, 2010, 07:08 pm by gbulmer Reason: 1
Quote
might be easer but it is not better. You still have an input that is in effect unprotected against anything but a 0.7V over voltage. At least with a potential divider you are protected against a much greater input voltage.

I agree, and he could put a 5.1V (or whatever maintains Vcc+0.5V) zener diode across the 'measured' resistors, providing even more protection for a few pence (cents).

Just to reinforce the point about using resistors of much less than 200K for the potential divider. The Atmel documet on the ATmega processor (doc8161.pdf, section 23.6.1 "Analog Input Circuitry") says:
Quote
The ADC is optimized for analog signals with an output impedance of approximately 10k[ch937] or less. ... The user is recommended to only use low impedance sources

HTH
GB-)

#### kevinsa5

#7
##### Apr 01, 2010, 07:08 pm
wow, thanks for all the responses! I think I'm going to go with a voltage divider, but I'm not completely certain what this bit meant:
Quote
The A/D works best with an input impedance of 10K

Does that just mean use 10k instead of 200k resistors? If not, can you put it in layman's terms?

#### gbulmer

#8
##### Apr 01, 2010, 07:21 pm
Quote

Quote
The A/D works best with an input impedance of 10K

Does that just mean use 10k instead of 200k resistors? If not, can you put it in layman's terms?

Yes, just use 10K instead of 200K

This is saying that the resistance that the ADC 'looks into' when it samples the voltage on the voltage divider should be 10K or less.

The ADC takes a bit of current to work, and that has to come through the voltage divider, so 10K is as big as you should use.

If the current to drive the ADC is restricted by something bigger than 10K, then the ADC-measured voltage divider will lag behind the real value when it changes; it'll start to take longer to detect and measure a change than technically necessary. So it'll lag behind a rapid change of voltage

HTH
GB-)

#### kevinsa5

#9
##### Apr 01, 2010, 07:32 pm
Awesome! My usage doesn't really need to be fast, so long as it doesn't take ten minutes to decide. But, I do have a bunch of 10K resistors laying around so that's not a problem. My last question: what does ADC mean? I'm guessing it's either Arduino Digital Current or Analog Digital Current.

#### gbulmer

#10
##### Apr 01, 2010, 07:43 pmLast Edit: Apr 01, 2010, 08:05 pm by gbulmer Reason: 1
Sorry, yes ADC means Analogue-to-Digital Converter (or Analog-to-Digital Converter, depending on where you learned English).

It's part of the electronics that sits behind the Arduino's 6 Analog inputs.

It wouldn't make things more than a few milliseconds worse (assuming I can extrapolate from what the spec does say). But it will lag, or not track the signal as closely as it could, which may cause problems.

Also, little voltage 'spikes' from noise might cause some angst. The lower the resistance the smaller the random effect (and in this case, random is bad   )

Think of a system like a radio with an aerial. If the resistance between the aerial and earth is big, you get a strong signal, if the aerial touches earth, the signal disappears or is reduced. A big resistance is like isolating the aerial from earth - the input to the ADC will be dancing with electromagnetic noise  . A low resistance will reduce the noise, a bit lke touching the aerial to earth, and the ADC will see the true signal that you are trying to measure.

HTH
GB-)

#### kevinsa5

#11
##### Apr 01, 2010, 07:47 pm
Great, thanks a ton!

Go Up