Go Down

### Topic: 12 to 24V input (Read 2433 times)previous topic - next topic

#### fiddler

##### Sep 25, 2012, 11:31 pm
I want to be able to apply both 12 and 24VDC to an input pin though a switch.
I'm switching to ground/0V.

Using a couple of resistor as a voltage divider, I have the following questions:

1. do I need a resistor between the Arduino pin and the voltage divider as well ?
2. what is the input pin impedance ?
3. and does pin impedance change if it is a selected as an input or output

Trying to keep the smoke in :-)

K

#### retrolefty

#1
##### Sep 25, 2012, 11:39 pmLast Edit: Sep 25, 2012, 11:42 pm by retrolefty Reason: 1

I want to be able to apply both 12 and 24VDC to an input pin though a switch.
I'm switching to ground/0V.

Not sure I understand the 'switching' part statement, can you post a drawing?

Using a couple of resistor as a voltage divider, I have the following questions:

1. do I need a resistor between the Arduino pin and the voltage divider as well ?

No
2. what is the input pin impedance ?

An input pin is very high impedance, many megohms.

3. and does pin impedance change if it is a selected as an input or output

Oh yea. Once pin is programmed to be a output pin, it becomes a active current source or sink, rated at up to 40ma absolute maximum. Be sure you never make a pin an output by mistake. The AVR chip cannot prevent damage from brain farts. Upon power up or reset condition all I/O pins are set to input mode. They only switch to output mode as a result of program code.

Trying to keep the smoke in :-)

And that is always a good rule to follow.

K

#### fiddler

#2
##### Sep 25, 2012, 11:53 pm
Okay, I haven't posted a pic or file before, but here we go

#### retrolefty

#3
##### Sep 26, 2012, 12:28 amLast Edit: Sep 26, 2012, 12:32 am by retrolefty Reason: 1
Note sure that circuit will work or not. Also your voltage divider uses equal size resistors, so it cuts voltage in half, so 24vdc = 12vdc, which is still higher then the maximum allowed input voltage to a input pin, +5.5vdc?

I would change the lower resistor size and then first measure the voltage that the arduino pin will see in each switch state with a digital multimeter before wiring it to arduino pin. Again the arduino pin must 'see' less then 5.5vdc to be safe.

Lefty

#### MarkT

#4
##### Sep 26, 2012, 12:30 am
You need to divide the voltage down to the 0..5V range, thats a factor of 5, not 2
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### fiddler

#5
##### Sep 26, 2012, 11:59 amLast Edit: Sep 26, 2012, 12:11 pm by fiddler Reason: 1
Okay

here are 2 schematics with one being from a control board we use at work (uses a Freescale chip, not AVR)
I have transfered it over for the Arduino board, but as said it has to be a factor of 5.

So, how come this other one works when there are essentially two 330K resistor in series between VDD and GND, which should give 6 to 12V on the chip pin when the switch is O/C ?

The "IN 0-7" connector goes straight to the chip pin
CN8 connect to the outside world. Input is ON the switched to GND
VDD is 12-24VDC

K

#### retrolefty

#6
##### Sep 26, 2012, 04:35 pm
Quote
So, how come this other one works when there are essentially two 330K resistor in series between VDD and GND, which should give 6 to 12V on the chip pin when the switch is O/C ?

Possibly the are relying on the fact that very little current can flow through a 330k resistor even though the applied voltage is too high and will cause the pins internal clamping protection diode to turn on?
There is even an example given by the Atmel (or was it PIC) showing a direct input pin connection to 120vac, but applied through a high enough series resistor to limit the current such that there is no damage to the input pin. Most people would rather just limit the maximum voltage applied to a input pin to the datasheet maximum allowed voltage, but certainly if you wish to experiment with using high enough series resistance (like the values used in your divider) you may find it works fine for you.

Lefty

Go Up