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.

PIC 16F84a to measure resistance for switch positions

Status
Not open for further replies.

5neaker

New Member
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
 
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??
 
5neaker said:
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 said:
5neaker said:
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 said:
could you send me any example external ADC work with the F84.

I ofthen use a MCP3221 from microchip
**broken link removed**

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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top