Log in

View Full Version : scanning BCD switches



dsicon
- 7th June 2008, 16:04
hi all
I am looking for ideas for the most elegant way to read 3 BCD switches

by elegant i mean less parts, less PIC pins

currently i use the following 7 pin scheme (which works fine):
the 1 2 4 8 pins of the 3 switches are diode combined to 4 PIC pins
the 3 common legs of the switches are driven by 3 more pic pins
if the port does not have pullups you need those too

the part i dislike the most is the high part count of the 12 diodes
ds

skimask
- 7th June 2008, 22:23
Could put all 12 pins of the BCDs on 2 8-bit parallel in/serial out type latches (can't think of a decent part number off the top of my head).
Trigger the load pin to grab the logic levels of all the pins, then shift in the 12 bits manually into a word, split the word up into the individual components and go.

OR...could use a 2nd PIC. Connect the 4 bit outputs of each BCD switch to whatever pins you want on the 2nd PIC. Use a 13th pin on the 2nd PIC as a trigger from the 1st PIC and have the 2nd PIC send out a couple bytes serially to the 1st PIC, which is waiting for it. 2 lines used on the 1st PIC, trigger and serial in. Don't even need to use the serial module, just use SERIN/SERIN2/DEBUGIN/whatever.
Parts count: 1 extra PIC (18 pins, simple firmware), add a 4Mhz resonator (if you use serial, you'd want a real oscillator, not the internal one for accuracy), pullups for the BCD switch lines (which you probably already have). That should be about it.

Darrel Taylor
- 7th June 2008, 22:52
Hi D.

You might try something like Tip#5 or #7 in this from microchip.

Tips ‘n Tricks
http://ww1.microchip.com/downloads/en/DeviceDoc/40040b.pdf
<br>

mister_e
- 7th June 2008, 22:59
1 I/O expander such as MCP23016 + 3 resistors should do.

Tons of way to multiplex stuff on low pin count PIC, and then.. this bring this ol', but still good Microchip app note AN234.
http://ww1.microchip.com/downloads/en/AppNotes/00234a.pdf

and
http://techtrain.microchip.com/masters2005/(kgmnvafutocq2355egt11231)/downloads/classes/40040b.pdf

<hr>
OK Darrel ;)

ADC is one of my favorite choice...

dsicon
- 7th June 2008, 23:20
thanks all
i like the single pin ADC approach, seems like the least stuff
i am already doing pushbuttons this way

too bad there are no res values in the MC app note #7, guess that would spoil the fun

but on 3 bcd sws there would be 1000 combinations, strikes me as too touchy for a 10 bit AD, or am i missing something ?
ds

Darrel Taylor
- 8th June 2008, 00:25
but on 3 bcd sws there would be 1000 combinations
But I'm sure you only need 512 of them. :)

Yeah, I think reading all 3 BCD switches on 1 A/D might be a stretch.
But with each digit on different pins, 3 pins would be better than 7.
Then there's only 16 voltage possibilities per pin (10 used). Piece of cake for A/D.
<br>

amgen
- 8th June 2008, 15:44
ds,
Do your switch readings need to be checked often, rearly, only once ?

don
amgen

dsicon
- 8th June 2008, 17:57
ds,
Do your switch readings need to be checked often, rearly, only once ?

don
amgen
they will either be polled at the top of the main loop or in response to a button push, haven't started the program yet

it looks like i will be using the 7 pin diode matrix approach after all since it seems to offer the best set of tradeoffs given other considerations in the design, i just really don't like stuffing the 12 diodes due to insertion cost
oh well