picaxe08 readadc

geoff07

Senior Member
Small question, but I have failed to find the answer: What is the range of values readable on an 08 (yes, not an 08M etc.) by readadc? I was expecting the range to be 0-255 but that doesn't seem to be the case. The pin is looking at the junction of a 10k pulldown and a photo transistor/BC547 darlington pair on the high side. The supply is 3v. Even allowing for Vce(sat) of 250mV for the BC547 I expected to get way more than I am getting.
 

AllyCat

Senior Member
Hi,

The "output" transistor in a Darlington configuration can never reach "saturation" because it "steals" the base current from its driver transistor when the Vce is about 600 mV. And in a high-side location the emitter will be at 2 x Vbe (e.g. 1.2v) below the input voltage, which presumably is no higher than the supply rail ? So at best, I wouldn't expect to see much more than half the supply rail, with a maximum ADC value of perhaps 150.

What values are you measuring and can you validate the actual pin voltages with a multimeter?

Cheers, Alan.
 

hippy

Technical Support
Staff member
I recall the PICAXE-08 has a reduced range of readings for analogue input because it doesn't have any ADC on-chip; I believe the analogue is read by using a comparator and various reference values to compare with.

The analogue reading is 'low resolution', which I recall is 4-bit, scaled up to give an 8-bit value by multiplying by 10, which gives a 150 maximum, which is arrived at before the analogue input is at the power supply level.

08-ADC.jpg
Click to enlarge
 

geoff07

Senior Member
Interesting, thanks for the response. The sfh3310 phototransistor in use has a Vce(sat) of 100mV, so I was expecting maybe a drop of 700mV on the pair. which should give me 2.3v out of 3.0 on the pin in saturation. That would be close to 200 on the adc. In fact I'm getting 160, but repeatedly exactly 160 on several instances of the hardware. Which is why I was checking if the old chips had some limited adc mechanism. I shall have to get the meter out.
 

hippy

Technical Support
Staff member
In fact I'm getting 160, but repeatedly exactly 160 on several instances of the hardware
That could be right, and my recollection of what output steps, what maximum value is returned, and at what input voltage, could well be wrong. 160 does indeed ring a bell.

I would connect a pot up and see what range it has. I recall about two-thirds of the way round and it hit its maximum reading on an 08 but it's been a long time since I've used one.
 

geoff07

Senior Member
Thanks hippy, that must be it, though it is 160 that I'm getting. I will check again, though I have to use debug which is very clunky. Sadly, sertxd isn't there on these ancient chips. Fitting code into 128 bytes is good discipline.
 

hippy

Technical Support
Staff member
You might not have to use real hardware; running under Simulation in PE6 should do the job -
Code:
#Picaxe 08
b1 = -1
Do
  Do
    ReadAdc 1, b0
  Loop Until b0 <> b1
  SerOut 2, N2400, ( #b0, CR, LF )
  b1 = b0
Loop
In the bottom left chip diagram, when running the simulation, right-click on Pin 1, adjust the 'virtual pot' and that will show the ADC reading for the virtual pot. And you are you are right; it does max out at 160.
 

premelec

Senior Member
The good old days of 128 bytes and max ADC 160 .... I still have some of those great chips and don't recall finding this limitation - I like the M2s better!
 
Top