The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 29, 2024, 01:44:50 13:44


Login with username, password and session length


Pages: [1]
Print
Author Topic: Reading 8 way dip switch  (Read 5565 times)
0 Members and 1 Guest are viewing this topic.
max
Senior Member
****
Offline Offline

Posts: 314

Thank You
-Given: 1595
-Receive: 52


« on: December 15, 2009, 04:43:07 04:43 »

Hi,
How to read a 8 way dip sw with uC using minimum number of i/o pins and
without using any ic.

tia
Logged

Fate arrived and made the conscious unconscious It silenced the activity of life.
leptro
V.I.P
Junior Member
*****
Offline Offline

Posts: 92

Thank You
-Given: 602
-Receive: 26


« Reply #1 on: December 15, 2009, 05:50:12 05:50 »

here are some ideas:

Multiplexing the switches like matrix keyb-->increase pcb routing difficulty

using diodes and sharing pin with other peripheric components.

or using (not wanted but usefull ) is shift register ic and you will need only 2 lines of your µc.

regards.
Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #2 on: December 15, 2009, 06:07:09 06:07 »

Use increasing size resistor on each of the dip switch leg eg 1k on sw1, 2k on sw2 ,3.9K on sw3 ,8.2K on sw4 etc. and then add the value an read it on an analog U/C pin.

Remember the resistor addition rule 1/R = 1/R1 + 1/R2 etc.
if for example you have sw 1 and 3 on then the value would be 1/(1/1 + 1/3.9)

If you dont have analog uc pin then add a capacitor on the pin and measure the time it took to discharge or charge the capacitor on a digital uc pin.

You only need 1 uc pin.
« Last Edit: December 15, 2009, 06:30:58 06:30 by Parmin » Logged

If I have said something that offends you, please let me know, so I can say it again later.
max
Senior Member
****
Offline Offline

Posts: 314

Thank You
-Given: 1595
-Receive: 52


« Reply #3 on: December 20, 2009, 04:29:33 16:29 »

I have found a circuit which can be used to read 12 switches using 4 io pins.
See attached sch.
To read the switch apply voltage to a row, read the inputs on other rows.
Logged

Fate arrived and made the conscious unconscious It silenced the activity of life.
titi
Active Member
***
Offline Offline

Posts: 229

Thank You
-Given: 3680
-Receive: 834



« Reply #4 on: December 21, 2009, 11:10:28 11:10 »

Hello,

This an other way to read switches from one ADC input.

When you push a switch you change the divide ratio, so the voltage is different for each switch.

After the simplest way is to display the value of ADC on LCD by exemple and for each button make this:

Example: the value read is 426 for Button 4.

if (ADC_Value>400) AND (ADC_Value<450) THEN 'Button=4
....

Best Regards.
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4639

Thank You
-Given: 823
-Receive: 4194


There is no evidence that I muted SoNsIvRi


« Reply #5 on: December 22, 2009, 09:21:18 21:21 »

Why not ask a few questions
1. is the DIP SW common to GND.
2. what voltage is DIP SW connected to 5+V or more
and then Do you know what a DIP SW is?
http://www.anykits.com/catalog/popup_image.php?pID=353

and the answer is still one input Smiley
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC