PDA

View Full Version : Measuring Resistance



jhorsburgh
- 25th August 2008, 07:13
Hello All,
I am trying to measure resistance quite accuratly, i did some research and found that the POT Command can be used to measure resistance but i can't seem to get the resolution i need. Wheni output the data the difference between 10k(output value of 16), 20k(output value of 17) and an open circuit(output value of 20) is to small.

Does anyone know how to improve my code or have any better ideas?

<code>
INCLUDE "modedefs.bas"

@ DEVICE PIC12f629, XT_OSC
@ DEVICE PIC12f629, WDT_OFF
@ DEVICE PIC12f629, PWRT_ON
@ DEVICE PIC12f629, MCLR_OFF
@ DEVICE PIC12f629, BOD_ON
@ DEVICE PIC12f629, CPD_OFF

Define OSC 4
CMCON = 7

RXPIN Var GPIO.1 'Input PIN
TXPIN VAR GPIO.2 'Output PIN
SCALE CON 255 'Scale Value
B0 VAR BYTE 'Pin Value

rx:
POT RXpin,scale,B0
serout txpin,n2400,["Value= ",#b0,10,13]
Pause 2000
goto rx

end
</code>

Regards,
Jeremy

mackrackit
- 25th August 2008, 08:08
I do not think you will be happy with the POT command.

You may want to look into using an ADC. Use one with a 10 bit resolution. This will give 1024 steps on full scale.
Take a known voltage, run it through a voltage divider with one of the resistors being fixed.
With a little calculating the unknown resistance cane be found.

If you need ideas go here
http://www.rentron.com/pic.htm
Examples for using the ADC on a few different chips, and methods.

jhorsburgh
- 25th August 2008, 09:05
Thanks Dave, i will take a look.
Jeremy

Picstar
- 24th September 2008, 06:56
Could you use?:
BO VAR WORD

mackrackit
- 24th September 2008, 09:29
Could you use?:
BO VAR WORD
You could...