Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 22nd November 2003, 07:06 PM   (permalink)
Default PIC 16F84a to measure resistance for switch positions

Hi

I’m new to the wonderful world of PIC.

I want to build a circuit to detect which position a switch has been pushed. The switch has only one signal wire and a ground to measure the different positions.

The switch contains various smd resistor ladders. I need PIC 16F84A to looks at the various resistor ladders to know which direction the switch has been pushed.

I’ve measured the resistance for each of the position,

Left – 679 ohm
Right – 1536 ohm
Up – 471 ohm – this is the one I’m interested in
Down – 220 ohm

When the position is found I would like it to light up an LED indicator

I did try to measure the voltage using 5V supply, in all the position I get a reading of 5V. I need to measure the resistance


Any help would be appreciated greatly, code, circuit diagram etc

Thanks in advance
Ray
5neaker is offline   Reply With Quote
Old 22nd November 2003, 11:27 PM   (permalink)
Default

This requires, *i think*, the command "Read ADC". This is an analog input for the PIC. As far as i know of this is the only command that can read analog inputs.

Off topic: Did any one see the world cup final between Australia and England??
__________________
www.winpicprog.co.uk - Great PIC language tutorials.
pike is offline   Reply With Quote
Old 23rd November 2003, 12:02 AM   (permalink)
Exo
Default Re: PIC 16F84a to measure resistance for switch positions

Quote:
Originally Posted by 5neaker
Hi

I’m new to the wonderful world of PIC.

I want to build a circuit to detect which position a switch has been pushed. The switch has only one signal wire and a ground to measure the different positions.

The switch contains various smd resistor ladders. I need PIC 16F84A to looks at the various resistor ladders to know which direction the switch has been pushed.

I’ve measured the resistance for each of the position,

Left – 679 ohm
Right – 1536 ohm
Up – 471 ohm – this is the one I’m interested in
Down – 220 ohm

When the position is found I would like it to light up an LED indicator

I did try to measure the voltage using 5V supply, in all the position I get a reading of 5V. I need to measure the resistance


Any help would be appreciated greatly, code, circuit diagram etc

Thanks in advance
Ray
Yes, you'll need a PIC with a ADC, or an external ADC to work with your F84. The reason you measure 5V in all positions is because you're not getting any current trough those resistors. There will only be a voltage drop over a resistor when you make current go trough it.

add a 1K resistor between your switches output and GND. Now measure on the switch. Voltage will now change along with the resistance of the switch.
Exo is offline   Reply With Quote
Old 23rd November 2003, 04:15 PM   (permalink)
Default Re: PIC 16F84a to measure resistance for switch positions

Quote:
Originally Posted by Exo
Quote:
Originally Posted by 5neaker
Hi

I’m new to the wonderful world of PIC.

I want to build a circuit to detect which position a switch has been pushed. The switch has only one signal wire and a ground to measure the different positions.

The switch contains various smd resistor ladders. I need PIC 16F84A to looks at the various resistor ladders to know which direction the switch has been pushed.

I’ve measured the resistance for each of the position,

Left – 679 <a href="#">ohm</a>
Right – 1536 <a href="#">ohm</a>
Up – 471 <a href="#">ohm</a> – this is the one I’m interested in
Down – 220 <a href="#">ohm</a>

When the position is found I would like it to light up an LED indicator

I did try to measure the voltage using 5V supply, in all the position I get a reading of 5V. I need to measure the resistance


Any help would be appreciated greatly, code, circuit diagram etc

Thanks in advance
Ray
Yes, you'll need a PIC with a ADC, or an external ADC to work with your F84. The reason you measure 5V in all positions is because you're not getting any current trough those resistors. There will only be a voltage drop over a resistor when you make current go trough it.

add a 1K resistor between your switches output and GND. Now measure on the switch. Voltage will now change along with the resistance of the switch.

Thanks Exo, could you send me any example external ADC work with the F84.
5neaker is offline   Reply With Quote
Old 23rd November 2003, 04:17 PM   (permalink)
Default

Quote:
Did any one see the world cup final between Australia and England??
Thanks for your reply Pike, no I never I heard tho, unlkucky for you guys
5neaker is offline   Reply With Quote
Old 23rd November 2003, 05:07 PM   (permalink)
Exo
Default Re: PIC 16F84a to measure resistance for switch positions

Quote:
Originally Posted by 5neaker
could you send me any example external ADC work with the F84.
I ofthen use a MCP3221 from microchip
http://www.microchip.com/1010/pline/...3221/index.htm

12 Bit A/D in a small SOT23 package. It uses I2C protocol wich only requires 2 wires between the converter and the pic

I2C code can be found on many places on the net, including nigel's site
www.winpicprog.co.uk
Exo is offline   Reply With Quote
Old 25th November 2003, 05:31 PM   (permalink)
Default

You can do A/D in code with a 16F84A.

Here is where I read about it:

http://www.audiomulch.com/midipic/

And here is the code:

http://www.dontronics.com/psbpix/pot.html
Deagol_the_Dead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 09:36 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.