'========================================
'Testing Resistance of Internal Pullups
'=========================================
#Picaxe 20M2
#No_Data
Setfreq M4
Pause 100
'=====================================
'Supply voltage must be >= 4.2 volts
'Place a 10K resistor from I/0 pin to ground
'Connect I/0 pin under test to C.7
'====================================
'===============================================
'Change value below to match your supply voltage
symbol supply = 5000 '// In millivolts
'================================================
symbol adc_val = w1
symbol millivolts = w2
symbol current = w3
symbol resistance = w4
symbol supply2 = w5
Pullup %0111111111111111
pause 1000
fvrsetup fvr4096
adcconfig %011
supply2 = supply * 10 'Scale for calculations
do
readadc10 c.7,adc_val 'Voltage drop across 10K resistor
millivolts = adc_val * 4 'Scale to millivolts
current = millivolts / 10 'Current
resistance = supply2 / current 'Total resistance
resistance = resistance - 100 'Subtract 10k resistor
bintoascii resistance,b12,b12,b13,b14,b15
sertxd ("Current = ",#current," Microamps",cr,lf)
sertxd ("Internal Pullup Resistance ", b12,b13,b14,".",b15,"K",cr,lf)
sertxd (cr,lf)
pause 2000
loop