18X outputs (output6,7)as ADC inputs?

kranenborg

Senior Member
#1
Hello,

Thanks to Hippy's investiations we now know that the 18X is more flexible than officially documented as it is possible (amongst others) to change its output pins into input pins. The PIC16F88 datasheet suggests that output6 & 7 when turned to inputs may actually be configured as ADC inputs, on the condition that the ADC control registers can be poked succesfully and are not overwritten by the PICAXE firmware.

Has anybody tried to do this? The reason I ask is that I would like to use a LED as both a light emitting device as well as a light-level sensor using the ADC sensor (by reverse charging and then measuring the charge decrease over a 10ms time interval, see wilf_nv's contributions on this matter; he only uses logical levels, but I want to read the analog level)

As an addition to the ADC question, has anyone tried whether the weak pullups can be enabled when the output pins are defined as inputs as well?

Of course I should have checked it myself, but I dont have the means right now

Regards,
Jurjen
 
Last edited:
#2
i doubt the interpreter will interfere too much as most of the setting up of all the modules is probably done upon startup,

they would have forseen that people would want to be able to do stuff like this which is why they put in peek and poke
 

hippy

Technical Support
Staff member
#3
Yes, output pins 6 and 7 work as ADC on the 18X. One needs to protect the 'input' when the pins are outputs but once setup, poke the SFR's, initiate an ADC 'GO' then read the result.

I haven't tried weak pull-ups but cannot see any reason it wouldn't work. Interrupt On Change works ( no interrupt, but change can set the flag ), as does INT(RB0) which allows narrow pulses to be detected.

The 18X is definitely my favourite PICAXE.
 
#5
Yes, this has been suggested/started/never-finished/forgotten about several times including fairly recently.

A nice 'Data Sheet' entry would be nice showing SFR addresses etc and function would be nice - including brief examples.

Maybe if someone wrote a nice neat .pdf document and asked Rev-Ed REALLY nicely they may include it.

I'll volunteer hippy to write it, but get BeanieBots to edit it , to prevent a War and Peace sized document :)
 

kranenborg

Senior Member
#6
#7
Thanks Jurgen. I'd forgotten where it went. Good stuff.

But this is the point isn't it; my addled brain forgot where it is and Newbies /Oldbies wouldn't even look as they wouldn't know where to look (or couldn't be bovvered).

It would be nice as a PICAXE Manual addition/supplement. A proper permanent reference with examples in addition to descriptions. Always there and always in your face and not a thread that disappears into the gentle filaments of time...

Are you left-handed by the way?
 

hippy

Technical Support
Staff member
#8
At some point I really should add all those short demo programs for using SFR and hardware trickery to the 'Finished Projects' section so they are not lost when the aliens take me away for a probing. I'll think about the best way of doing that.
 
Top