Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 07, 2016, 09:09:09 21:09


Login with username, password and session length


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

Posts: 223

Thank You
-Given: 602
-Receive: 32


« on: December 15, 2009, 05:43:07 05: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: 61

Thank You
-Given: 240
-Receive: 20


« Reply #1 on: December 15, 2009, 06:50:12 06: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: 544

Thank You
-Given: 357
-Receive: 126


Very Wise (and grouchy) Old Man


« Reply #2 on: December 15, 2009, 07:07:09 07: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, 07:30:58 07:30 by Parmin » Logged

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

Posts: 223

Thank You
-Given: 602
-Receive: 32


« Reply #3 on: December 20, 2009, 05:29:33 17: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: 192

Thank You
-Given: 1434
-Receive: 705



« Reply #4 on: December 21, 2009, 12:10:28 12: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: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #5 on: December 22, 2009, 10:21:18 22: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: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
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