Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Using Analog input as Binary

Status
Not open for further replies.

SPDCHK

Member
Sorry if this thread is a repeat. I do remember seeing something of the sort, either on this forum, or another, but...

I am busy using a PIC 12F675 (8 Pin DIP). The problem is that I require more I/O than is available on the Chip. I recall briefly seeing an article/post on either this or another forum, where an analog input channel was used to create two or more digital signals form it, something like the comparator function available in most PIC's but with multiple set-points if you will.

I don't want to use the comparator way, because that uses two pins.

I have "tried" to search this forum, but as most of us know, this is not Google, and the use of key word such as "AND" etc. does not yield the desired results. (More than 500 returns, and none are relevant)

This is not homework, or some post graduate project. Simply a hobbyist wanting to learn something new.

Thank you.
 
I don't want to use the comparator way, because that uses two pins.
I think if you set CM2:CM0 = 100 then you'll only need one pin..... But if you don't want to use the comparator then you can use the ADC. All you need is a pullup resistor on the ADC pin and then a series of resistors off the same pin with different values connected via switches to ground. Different ADC readings will indicate different switches being active. If you choose your resistors correctly, you'll be able to detect multiple switches at the same time.
 
The real sollution to your problem is use a bigger PIC, considering the prices upgrading to a PIC with a higher pin count is your best bet.
 
Another way to put 2 push buttons on 1 input is,
Connect a 200k resistor from the pin to ground.
Connect a push button (1) and a 1K resistor in series from the pin to 5V.
Connect a push button (2) and a 1K resistor in series from the pin to GND.

To read it,
Turn off the internal pullup - if the input reads 1 then push button 1 is pressed.
Turn on the internal pullup - if the input reads 0 then push button 2 is pressed.

Mike.
Edit, I should add that this is for a digital input - not ADC.
 
Last edited:
Pommie said:
Another way to put 2 push buttons on 1 input is,
Connect a 200k resistor from the pin to ground.
Connect a push button (1) and a 1K resistor in series from the pin to 5V.
Connect a push button (2) and a 1K resistor in series from the pin to GND.

To read it,
Turn off the internal pullup - if the input reads 1 then push button 1 is pressed.
Turn on the internal pullup - if the input reads 0 then push button 2 is pressed.

Mike.
Edit, I should add that this is for a digital input - not ADC.

That doesn't matter. Just as long as I can get one more I/O point out of the current 6 I/O package.

Thanks for the reply. I'll try it.
 
Sceadwian said:
The real sollution to your problem is use a bigger PIC, considering the prices upgrading to a PIC with a higher pin count is your best bet.
True, but you know how people are? I have a surplus supply of the 12F675 chip, so I thought I might as well try and use it :D. Who knows? It might just work?
 
kchriste said:
Different ADC readings will indicate different switches being active. If you choose your resistors correctly, you'll be able to detect multiple switches at the same time.
If you set the resistors up in an R-2R configuration, you should easily be able to recognize at least 8 bits (or 256 combinations) ...
JB
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top