Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question about AVR internal pullup for input

Status
Not open for further replies.

andyyau

Junior Member level 2
Joined
Jul 12, 2002
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
116
Hello,

When I use ATMEL AVR MCU, it has internal pullup for input. If I connect a push button switch to this pullup input pin, shall I add a resister to this pin? If so what is the value of the resistor or what is it current?

Thanks!
 

House_Cat

Advanced Member level 4
Joined
Feb 21, 2002
Messages
1,371
Helped
406
Reputation
812
Reaction score
98
Trophy points
1,328
Location
USA
Activity points
16,422
avr pullup resistor

The AVR datasheet will tell you what the I/O current limit may be. For the AVRs that I have used, it has been 20ma.

You do not need any current limiting resistor to pull an input low - a push button switch connected between the input and the power supply negative will do the job.

Often in AVR application schematics, you will see a resistor (about 470 ohms) added in series to limit the current to 10ma if the switch is accidentally subjected to a static discharge that causes the input limiting MOS pullup resistor to break down. In most applications the added resistor is unnecessary.
 

andyyau

Junior Member level 2
Joined
Jul 12, 2002
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
116
avr internal pullup

House_Cat,

Thanks!

I also find a problem for a normally open push button switch. If it is open and the micro is placed at high noise environment, I find that noise will make program reads "0" for the input pin even the switch is not pushed. Adding a small capacitor to the pin solves the problem. Is this correct way to do?
 

ME

Advanced Member level 4
Joined
Mar 14, 2002
Messages
1,309
Helped
55
Reputation
112
Reaction score
40
Trophy points
1,328
Activity points
14,861
avr pullup

Yew I think it's the right way.
 

Hero

Full Member level 2
Joined
Mar 6, 2002
Messages
145
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,298
Activity points
1,608
avr pull up resistor

Hi,

You can use and software solution instead capacitors.

Always be carefull with capacitator and pull-up inputs.

If you take large capacitors you will charge capacitor with constatnt current source and shift input DC level.

Beter solution is to use CMOS buffers (e.g Schmit triggers) without pull-up and capacitor.

Another solution is to turn of pull-up from AVR I/O pin and add external R and C to push button.

Optimal solution :) is to use software integrator without any external components.

You need to make finite loop and monitor state on I/O pin.

.equ INTEGRATOR_CONST = 64;

ldi r16,INTEGRATOR_CONST;

LOOP:
sbic PORTB,PUSHBUTTON
rjmp LOOP_EXIT
dec r16
brne LOOP

; Push button is pressed

. . .

LOOP_EXIT:

; Push button is not pressed

. . .


You can set desired time of integration (integrator constant) with .equ directive.

For better noise imunity use large integrator constant. This is equivalent to larger input capacitor and incresed time delay.

If time delay is not problem use large integrator constant for better noise imunity.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top