Do the pull-ups remain functional when readadc is used?

radiogareth

Senior Member
As above, if I enable the internal pull-up resistor on an 08M2 pin C.4, then connect an LDR from C.4 to ground and use the readadc c.4,b0 command, can I save myself a resistor? Clearly perhaps not the ideal value to use (100K-ish for the internal pull-ups AFAIK) but adequate for basic light related sensing??

TIA
 

AllyCat

Senior Member
Hi,


AFAIK they're nominally about 30 kohms, but with a significant production range and probably will vary with chip temperature, so not really suitable for "precision" measurements. But I believe that they do remain connected to the pin, so your idea should work in principle.

However, the answer really is to breadboard it (and then tell us ;) ) because we have the vagueness of some parts of the base PIC data sheet, and the PICaxe operating system itself, to contend with.

EDIT: The base PIC data sheet (section 30.4, D070 "characterised but not tested") actually defines the Weak Pullup as a current, but it does appear to be moderately proportional to the supply voltage (and nominally 28 - 30 kohms). However, the Min and Max values suggest that the resistance value might be anywhere between 16 kohms and 200 kohms !

Cheers, Alan.
 
Last edited:

rq3

Senior Member
As above, if I enable the internal pull-up resistor on an 08M2 pin C.4, then connect an LDR from C.4 to ground and use the readadc c.4,b0 command, can I save myself a resistor? Clearly perhaps not the ideal value to use (100K-ish for the internal pull-ups AFAIK) but adequate for basic light related sensing??

TIA
The "weak pull-up" resistor value range is huge. According to the Microchip data sheet for the base device used on the 20M2, the weak pull-up is disabled only if the pin is configured as an output. Whether this applies to the Rev-Ed Picaxe devices I do not know.
In any case, the actual value of the pull-up (for the 20M2 anyway), is between 16.5Kohm and 200Kohm, based on the Microchip specs for pull-up current at particular operating voltages.
Nor do they specifiy how that resistance might change over temperature or varying supply voltage. I certainly would not rely on the weak pull-up as a "precision" resistor as part of a voltage divider! It's function is to make sure that a digital input is high, unless pulled low externally.
 

Rick100

Senior Member
I didn't find the answer in the data sheet so I googled it found this discussion on the Microchip forum.
http://www.microchip.com/forums/m693289-print.aspx

I decided to try it myself. I connected the LDR between pin C.4 and ground. With a LDR that measures 300k when covered and 300 ohms under a light, the 8 bit adc counts were 244 when covered and 11 when lit. Without the pullup enabled the count was always 0. This would suggest the pullups are still connected. Here's the code I used.

Code:
#picaxe 08m2

pullup on
top:
readadc c.4,b1
sertxd("adc = ",#b1,13,10)
pause 500
goto top
Good luck,
Rick
 

radiogareth

Senior Member
Looks good, its not for any degree of precision, but if its 'repeatable' on the same chip that would be great. I'll try it tomorrow and use freezer spray / soldering iron to investigate the thermal stability and plug in some of my stock of 08M2 to see if it differs much between processors.
 

radiogareth

Senior Member
Just tested 3 and got identical readings from each one (admittedly all from the same tube and therefore possibly batch), even with freezer spray the readings barely changed 1 Bit. Good span of values too with budget mini-LDR from Rapid Electronics. (40-200 easily achieved in classroom lighting/covered with hand). So probably one less component for 'Little Jimmy' to mis-place.
Mind you, trying to explain to said little Jimmy exactly what 'software configurable pull-up resitors' are will remain a challenge ;-)
 
Top