CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Question on DIP Switch Combinations

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Sean7326



Joined: 28 Nov 2003
Posts: 1

View user's profile Send private message

Question on DIP Switch Combinations
PostPosted: Sun Nov 30, 2003 10:56 pm     Reply with quote

Can someone please check my logic with this - I have a 12 position DIP switch that has on, off, and float - marked +, -, and 0. I am interfacing that to 12 pins on a PIC to provide different options.

Would I be correct that 3 possible positions, times 12 switches, would equal 3^12 or 531,441 possible options?
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Mon Dec 01, 2003 2:36 am     Reply with quote

Hello,

I think that is correct, but how do you determine 3 states on a digital I/O pin? Confused
Sorry, I hope I understand your question correctly.

73 Sven
Ttelmah
Guest







Re: Question on DIP Switch Combinations
PostPosted: Mon Dec 01, 2003 4:07 am     Reply with quote

Sean7326 wrote:
Can someone please check my logic with this - I have a 12 position DIP switch that has on, off, and float - marked +, -, and 0. I am interfacing that to 12 pins on a PIC to provide different options.

Would I be correct that 3 possible positions, times 12 switches, would equal 3^12 or 531,441 possible options?

Yes.
To detect the third state though, requires some circuitry, if it is to be done safely. One solution, is to have a small capacitor in series with a small resistor between ground, and the wiper of each switch, and a larger resistor between the wiper and the PIC's input pin. You can then drive the pin as an output 'high', switch to using it as an input, and read the result. If you see '1', then the switch is either in the 'open' position, or set to 1. Repeat by driving low, and you can then know where the switch is positioned. The small resistor in series with the capacitor, is to reduce te current experienced by the switch when discharging the capacitor. The resistor between the wiper and the PIC input, is to limit the current when testing, and trying to drive the PIC 'high', when the switch is set 'low' (and vice versa)..
Other methods are to use a few of the switches together with resistors for form a voltage divider tree, and sense the voltage with an A/D input. With this you could reduce the number of inputs used, but don't try to decode too many combinations with one 'tree', or the limits of voltage reference accuracy, and A/D converter accuracy, will 'sneak out' to hit you.

Best Wishes
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Mon Dec 01, 2003 5:35 am     Reply with quote

Hey Ttelmah,

Wooh, I'm enthusiastic about that fine idea.
Please more... Smile

73 Sven
Remko



Joined: 24 Sep 2003
Posts: 14

View user's profile Send private message

PostPosted: Mon Dec 01, 2003 5:57 am     Reply with quote

Mail Microchip and ask for the little Tips 'n Tricks book, it is a give-a-way book. This trick and more are explained.

Greetingz

RFM
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Mon Dec 01, 2003 9:23 am     Reply with quote

Hello Remko,

thank you for that information Very Happy

73 Sven
burnsy



Joined: 18 Oct 2003
Posts: 35
Location: Brisbane, Australia

View user's profile Send private message Send e-mail Visit poster's website

4 dipswitches per analog pin
PostPosted: Sat Dec 06, 2003 11:04 pm     Reply with quote

I've been connecting 4 dipswitches on an0 for ages using a simple voltage divider like sean said.

On the processor side of the dipswitch common the dipswitch pins to a 10k pullup and connect it to an0. On the other side of the dipswitch, connect a 10k, 5k1, 2k4 and 1k2 resistor to each of the pins and common them to gnd.

It even works with normal switches, but make sure you use 1-2% resisitors to reduce errors.

If anyone wants the code, email me at jason@jtekelectronics.com.au

cheers,

Jason
_________________
This is the last code change until its ready....
KerryW
Guest







Another way to do that
PostPosted: Sun Dec 07, 2003 8:40 am     Reply with quote

Ground the common pin of each switch. Run the N.O. and N.C. sides of each switch to the inputs of a 74LS244 (or 74HC245, or whatever) Use 3 to do the 24 inputs. Use pull-ups on the 74LS244 inputs. Run 3 outputs to the enable lines of the 74LS244s. Tie all 3 output 0s together to 1 input pin, all outputs 1 to another input pin, etc.

This would use 3 20 pin ICs, 3 9 pin sips, 8 input lines and 3 output lines. If this method interestes you, I can whip up a quick schematic for you if you need it.
Bruno
Guest







PostPosted: Sat Mar 18, 2006 2:52 am     Reply with quote

Does someone knows if Mr. Jason is still on the same e-mail.
Im asking this becuse i have e-mail to him, but i didnt get the replay.

If someone has some infos or maybe link to the code, please be so kind and pass it to this forum.

Thank you !
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group