Have you ever had one of those evenings where everything falls to pieces? Having used AtoD without issue for quite a while, my 12F683 is laughing at me....and now I'm not sure what I know & what I don't know wrt AtoDing!
Previously, in my newbie ignorance (bliss?), when wanting to use more than one AtoD channel, I was simply doing this (on a 16f690)...
Code:
ADCIN 1, intensity
pause 2 '
ADCIN 3, Signal_In
never had a problem - my AtoD (Seemingly) worked!
Ok, now I've moved to a smaller (simpler?!) PIC - a 12f683. It's kicking my backside - two nights wasted on the seemingly very simple task of getting two AtoD channels to work correctly.
Firstly, can I get a really basic question out of the way? (you have to promise not to laugh!)
when moving between AtoD channels, should I be setting the ADCON register *every* time? (the PICBasic compiler suggests so, so I guess the answer is yes!)
ie, should I actually be doing this...
Code:
ADCON0 = %10000111 ' select AN1
pause 50 'wait a bit
ADCIN 1, intensity ' 'ok, let's Ato D.
pause 50 'wait a bit
ADCON0 = %10001111 'now move on to a different AtoD channel - AN3
pause 50 ' let things settle
ADCIN 3,Signal_In
in other word, using the ADCCON0 register to move between the different Analogue Channels?
If so, then how the hell was I getting away with it on my 16f690?
ok, now to my (latest) immediate problem - if I apply a variable DC level to say AN1 (just for testing to observe the results), moving the test voltage level up/down also affects the AN3 AtoD reading (& vice versa) - eh?
Now I know you have to wait sufficient time to let things settle when moving between channels, but I'm already pausing a good while before AtoD'ing the next channel - what's going on?
Bookmarks