PDA

View Full Version : Dipswitch matrix



DynamoBen
- 7th October 2007, 22:59
A project I'm working on uses a 9 position dip switch to set the starting address. Normally I would dedicate 9 I/0 pins to it but I only have 7 available. I thought maybe I could create a 3x3 matrix and read it like a keypad. My only concern is unlike a keypad multiple switches may be on at one time. Am I over thinking this? Will this method work? Is there a better way?

Jerson
- 8th October 2007, 01:24
Connect the dip switch to a 74165 type shift register and stream the bits in via 3 lines.

Jerson

DynamoBen
- 8th October 2007, 02:17
While that’s a great idea, and one I had considered, I don't have any lying around. Makes you wish Radio Shack still carried electronic parts. :(

mackrackit
- 8th October 2007, 02:24
You could set this up as a voltage divider network and us the ADC to read the voltage.

By the time you work it all out though I bet you could have the shift register shipped to you:)

DynamoBen
- 8th October 2007, 02:27
Getting one shipped isn't the issue its the huge shipping charges. I could order a sample but it would be weeks before I see it.

BTW this is a 9 position dipswitch not 8.

mackrackit
- 8th October 2007, 03:55
This is not the same one Jerson recommended but should work.
http://www.allelectronics.com/cgi-bin/item/74LS597/285/SERIAL-OUT_SHIFT_REGISTER_.html

$7.00 shipping ground no matter the size of order.



BTW this is a 9 position dipswitch not 8.
You said you have seven pins...register takes 8 inputs and uses three on the PIC. Now you have four left. Use one for the left over switch, now you have three pins left. :)

DynamoBen
- 8th October 2007, 04:26
Sigh, let me make this more clear.

I'm not interested in ordering one part and paying $7 shipping. I'm trying to make this work with what I have because I'm under a very short timeline. If the switch matrix idea won't work then I will move onto my backup plan which will be hard programming the ID for now and dealing with the dipswitches later.

mackrackit
- 8th October 2007, 04:41
GOT IT :D


My only concern is unlike a keypad multiple switches may be on at one time.
Try the ADC voltage divider. Even it all of the switches are on it will not matter.

Have the calculated values far enough apart that temperature variations will not cause an overlap and code for a plus or minus reading.

DynamoBen
- 8th October 2007, 16:07
After digging around in my desk at work I have located a 74LS165, which should do the job.

mister_e
- 8th October 2007, 17:04
:( i second the Voltage divider option too. Look at the Microchip appnote bellow

http://ww1.microchip.com/downloads/en/DeviceDoc/40040C.pdf

See tip #5... At least if you don't use that method, keep this document handy. There's a lot of interesting tricks in it.

DynamoBen
- 8th October 2007, 17:11
Perfect, thanks I will file this this all my "good to have" docs. Hardest part is remembering that they are there. ;)