0
\$\begingroup\$

I've been playing around with logic gates and RAM chips and stuff the past week or so, but I can't figure out how to get a DIP switch to represent a digital '0' while still being able to represent '1' when turned on. Having no current running through doesn't work, and the switch only has one input for each bit. How would I do this?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ What do you think about using of pull-down resistor? More information here: en.wikipedia.org/wiki/Pull-up_resistor \$\endgroup\$ Nov 8, 2012 at 23:45
  • 1
    \$\begingroup\$ @GeorgeGaál You should make that into an answer. That seems like what the question is about: if we have a single pole, single throw switch, how do we use that to switch between a high and low voltage level for logic. \$\endgroup\$
    – Kaz
    Nov 8, 2012 at 23:49

1 Answer 1

4
\$\begingroup\$

You are right, you need something more than a simple single pole single throw switch to make a digital logic signal. Usually that something is a pullup resistor. The resistor goes between the power supply and the logic line, and the switch between ground and the logic line. When the switch is closed, it hard-shorts the line to ground. When the switch is open, the pullup resistor provides a weaker drive to power.

The tradeoff is that you want the pullup stiff enough (low enough resistance) so that it can overcome any current that other parts on the digital line might be leaking to ground. It has to be weak enough (high enough value), so that the current is limited to a reasonable value when the switch is closed.

Most CMOS logic gate inputs leak little enough that a few 100 kΩ to power is enough to guarantee the voltage will be interpreted as a logic high level. However, you don't want the line to pick up stray noise and of course you want some margin. If in doubt, use a 10 kΩ pullup.

This same concept works flipped around too. You can use a pulldown resistor and put the switch between power and the logic line. For various reasons, switches, whether mechanical or transistors, are usually connected to ground, and therefore pullups are more common than pulldowns.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.