Reading FSRs without ADC

Anobium

Senior Member
I am trying to use the approach shown at the bottom of this web page http://www.ladyada.net/learn/sensors/fsr.html to read the value of the FSR.

When I calibrate using a 10K Analog pot I get 4 values shown in the terminal of 0,1,2 and 3. These values are representative of the value of the pot. However, i would have expected more values to be returned.

Is the cause of the limited return values (0,1,2 and 3) the Picaxe clock speed? So, if I change the Picaxe to a faster option I would get more granular return values?

Any thoughts (relating to this subject please....).

Thank you.

Anobium





My layout is attached and the code shown below.

Code:
' 1uf CAP with 10K resistor
' 08m

setfreq m8
symbol timer = w1
main:
	dirs = %00000010
	low 1
	' Charge CAP
	pause 5
	timer = 0
	dirs = %00000000

	do while pin1 is off 
		timer = timer + 1
		if timer = 1028 then 
			sertxd ("*")
			goto fin
		end if 
'	debug
	loop
	fin:
	sertxd (#timer,13,10)
	
goto main
 

Attachments

hippy

Technical Support
Staff member
Any thoughts (relating to this subject please....)
I'd say forget about doing it the way you are and use one of the other resistive divider methods instead, then it's a simple case of using READADC.

The timed charge-discharge method is best suited to micros which don't have ADC when there's no other way to do it.
 

Anobium

Senior Member
I will use READADC but is the clock speed the cause? I am genuinely interested to understand the results I obtained.
 

hippy

Technical Support
Staff member
Yes, probably clock speed and fast rate of of discharge. That time can be roughly calculated as T=RC so, T= 1x104 x 1x10-7 = 1x10-3 = 1ms, and it's going to be less than that. So things to increase the count -

Larger capacitor
Faster PICAXE speed
Remove extraneous code from the counting loop
Use "Do ... Loop While/Until" rather than "Do While/Until ... Loop"

And for best results use an internal timer/ counter running at high speed..
 

inglewoodpete

Senior Member
You're only charging the capacitor for 5 mS. Do you have 'scope to see how much of a charge it gets in that time? Is the charge current peak within the safe limits of the PICAXE?
 

Anobium

Senior Member
You're only charging the capacitor for 5 mS. Do you have 'scope to see how much of a charge it gets in that time? Is the charge current peak within the safe limits of the PICAXE?
I will get my scope out and look at the charging rates when I get a moment this week.


I did not show the 220ohm current limiting resistor that I have between this circuit and the Picaxe - an error in the diagram. This is the circuit Psuedo ADC.jpg
 

hippy

Technical Support
Staff member
This thread may also be of interest ...

http://www.picaxeforum.co.uk/showthread.php?11991-Capacitance-meter

My code for doing the charge-discharge timing is in post #6 and uses an internal timer. The technique is to discharge so the reading is low on a digital input pin, charge until it goes high, then switch to discharging and measure the time until low again. That automatically gives the initial timing and fairly consistent repeatable measurements. I used one control pin ( charge, discharge, floating/disconnected ) and another to read the input,
 
Top