View previous topic :: View next topic |
Author |
Message |
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
pull up vs pull down resistors |
Posted: Wed Oct 24, 2007 12:20 am |
|
|
Hi there, been browsing through forum and saw a query about pull up resistors, and was wondering if it would be possible to connect the pins to ground through a resistor and then let the switch connect the pin to Vcc eg pull down.
This way your logic would be the right way around. Switch on = 1 switch off = 0. I'm busy with a project using a lot of DIP switches so i don't want to invert things the whole time.
Would this setup work or will too much current flow into the pin?? Or am i missing something else here?? |
|
|
Ttelmah Guest
|
|
Posted: Wed Oct 24, 2007 2:08 am |
|
|
No reason at all.
The reasons "pull up's", are more common, comes from a multitude of things. It allows one side of the switch to be grounded (potential safety improvement), it is also what the default internal "bias resistors" on port-B offer. These followed common practice dating back to older logic families, which often had some degree of internal pull-up. There is nothing to stop you using pull down resistors if this is what you want.
However there is really no 'inversion' involved in working the other way. Two comments apply:.
1) Some systems will have switches designed to 'fail safe', so an 'open' switch is the 'off' condition, so if a wire fails 'off' is always seen.
2) The processor itself, is just as happy testing for a '1' as a '0', so you can (for example), write like:
Code: |
#define ON (0)
#define OFF (1)
#bit SWITCH1=PORTA.0 //whatever suits your switch
if (SWITCH1==ON)
|
Which means you never have to worry about which 'way' the switch operates.
Best Wishes |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed Oct 24, 2007 8:52 am |
|
|
One reason pull-up resistors are more common is due to having open-collector outputs that allow things to be 'disconnected' from the rest of the circuit. These outputs pull the pin to ground via a transistor and when turned of the output simply 'floats' with no voltage level being forced. The only way to have this pin go high is to have some device, another output from a different chip or a pull-up resistor, pull it up. This comes in handy when you need to allow a different part take control of that particular signal pin.
Ronald |
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
Inverting port data |
Posted: Wed Oct 24, 2007 9:52 am |
|
|
Hi guys, thanks for the replies.
The reason i want to use pull-down is that the dip switches are to be used as the address for an EEPROM memory, so the whole port is being read. so i want things to work as you see them, no reverse/inverse operation. i havn't done any reading yet on inversing the results if i use pull-ups, any ideas or suggestions?? |
|
|
Ttelmah Guest
|
|
Posted: Wed Oct 24, 2007 9:55 am |
|
|
Not exactly hard.
val = ~input;
will invert all the bits.
Best Wishes |
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
invert bits |
Posted: Wed Oct 24, 2007 10:05 am |
|
|
Gee that was easy!!! I wil go and simplify my PCB design now, will save a lot of tracks.....
Thanks Ttelmah, shows you i should read the manual more...
Keep well |
|
|
|