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?
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.
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.
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.
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...
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.
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:
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
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
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.
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.