Hairy Animal
Member
I've searched the forum (in excess of 500 hits for ADC*) and can't find an obvious answer to my problem which is that I'm getting some very strange results (consistently low) when reading the ADC value from a buffered potentiometer:
The code is as simple as I can make it to just test what values I'm getting from the system where a lever is controlling the pot, but not giving its full range, so typically on a +5V supply the range of input voltages is from 0.66V to 3.33V. The op-amp is a low power single supply device with rail-rail input and output, though neither gets near the supplies.
What's happening is that I'm not getting anything like the values I'd expect for a given pot position and hence voltage in. For instance, if I position the lever to get as near to 2.50V (50% x supply) as I can, I'd obviously expect a value of about 126/127 to be read back. What I'm actually getting varies from 17 to 86, but never as high as 126. Both the supply voltage and output from the buffer to the 08M2 are monitored with (cheap) DVMs. The 08M2 is a new device straight from the tube of spares I have, but I haven't tried swapping it yet.
This is the code:
It occurred to me, before I put the PAUSE command in, that I might be trying to read the ADC too quickly (despite the DEBUG), so I put in the PAUSE and indeed did get different values, but the value read via debug varies with delay value, e.g.
delay 50, read 17;
delay 500, read 42;
delay 5000, read 84.
So far as I can see from another thread, the ADC conversion takes less than 100µs, so it doesn't sound as though that's what the problem is. I've also tried swapping the position of the PAUSE & DEBUG commands around and that doesn't change anything either.
Any help/suggestions would be gratefully received please?
P.S. for the record, this is continued work on the throttle I described originally in http://www.picaxeforum.co.uk/showthread.php?27782-DAC-o-p-capacitor-query for which I had so many really helpful suggestions. Slow progress but getting there!
The code is as simple as I can make it to just test what values I'm getting from the system where a lever is controlling the pot, but not giving its full range, so typically on a +5V supply the range of input voltages is from 0.66V to 3.33V. The op-amp is a low power single supply device with rail-rail input and output, though neither gets near the supplies.
What's happening is that I'm not getting anything like the values I'd expect for a given pot position and hence voltage in. For instance, if I position the lever to get as near to 2.50V (50% x supply) as I can, I'd obviously expect a value of about 126/127 to be read back. What I'm actually getting varies from 17 to 86, but never as high as 126. Both the supply voltage and output from the buffer to the 08M2 are monitored with (cheap) DVMs. The 08M2 is a new device straight from the tube of spares I have, but I haven't tried swapping it yet.
This is the code:
Code:
; Vers. 01, test for joystick in values.
; Last updated 13/11/2017
;
#picaxe 08M2
;
init: ;
;
symbol raw_jystk = b2 ; byte variable for joystick input
;
INPUT C.4
;
; C.4 is an analogue voltage from the joystick indicating
; its position between full reverse (?V) and full forward (?V).
;
ADCCONFIG %00000000
;
; ---------------------------------------------------------------------
;
main:
;
READADC C.4, raw_jystk ; Read the value from the joystick pot.
PAUSE 500
DEBUG
;
GOTO main
;
end
delay 50, read 17;
delay 500, read 42;
delay 5000, read 84.
So far as I can see from another thread, the ADC conversion takes less than 100µs, so it doesn't sound as though that's what the problem is. I've also tried swapping the position of the PAUSE & DEBUG commands around and that doesn't change anything either.
Any help/suggestions would be gratefully received please?
P.S. for the record, this is continued work on the throttle I described originally in http://www.picaxeforum.co.uk/showthread.php?27782-DAC-o-p-capacitor-query for which I had so many really helpful suggestions. Slow progress but getting there!
Last edited: