Your ANSEL setting is wrong... RB7 is AN6 and must be set to 1 in ANSEL bit 6.
Seems you revert bit order or something like that.
ANSEL=%76543210
Your ANSEL setting is wrong... RB7 is AN6 and must be set to 1 in ANSEL bit 6.
Seems you revert bit order or something like that.
ANSEL=%76543210
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Mister_E,
thaks for your suggestion.
I tried several ansel settings
from
ANSEL=%01000000
to
ANSEL=%10000000
to
ANSEL=%01000110
and a dozen similar versions.
when I switch on the LCD shows for half a second "Value:03" and then
"Value:00"
Yes..its because of internal bit during startup.
Switched an Lcdout $FE,1,"Hello"
Pause 500
into just to show the PIC works and goes through the loop.
I could switch input to any RB exept RB03 which is used for the LCD.
Input voltage is now 0-2,5V .just for checking purposes.
Do I need a reference voltage?
Hi Mügel
the obvious thing here ...
- is you select Channel 7 ( ADCIN 7 ),
- Choose channel 1 and 2 for the ADC ,
- choose channel 4 as default Analog channel,
- right justify the result ( Ok, here , why not ? ) ,
- use a 16 bits variable for the result,
- and , at last use an 8 bits conversion ...
Might I add your comment tells "read channel 0" for an " ADCIN 7 " ...
is that clear enough for you ???
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hello Ace,
I changed (tried to) the channel but not the comment .
Puzzling together the analog thing is difficult for me as its the first time.
Did that with a 12F675 worked great.
You were second in the following "code saving contest": http://www.picbasic.co.uk/forum/show...ghlight=12F675
Now I try to save one simple 12F675 and Iīm in trouble again.
No, What you told below isnīt clear enough for me although it shows the typical "Newbie defines rubbish"
in this thread:http://www.picbasic.co.uk/forum/show...ht=16f88+adcon
Melanie tells us that the adcon thingy affects only Porta.
But the data sheet page 114 tells us (you, not me) how to set the adcon0 register bit to select channel 6 = RB7.
So, thats REALLY irritating to me.
so I hope thats clear enough for you.
I know Iīm juggling bits like shooting in the dark but its always the same:
search a code that works for me and then modifiing.
All codes used RA ports as analog input. Canīt use that.
Mhhhh,
I do not understand you : you ask for code ready to paste !!!
No, no, no ...
Forget the ' 675
Just take your '88 datasheet ADC section ...
READ it carefully,
beginning by the ANSEL config
WHAT do you have to write to select Channel 6 ( RB 7 ) ???
Now ADCON 0 Config
WHAT do you have to write to select RC clock ?, Channel 6 ?, AD OFF ( ADCIN will turn it ON in time )
Now, ADCON 1 Config
WHAT do you have to write to select Right justif. ?, Voltage refs ???
THAT's all you have to do ... but that must suit your harware config !!!
You don't see here ANY ref to other existing devices ... so, forget that " cut ( ? ) and paste" horrible habit.
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi Ace,
I donīt need a complete code.
I soldered RB4-7 parallel so it doesnīt matter which of those is my analog input.
0-2,5V to analog input , showing value on LCD...ready. I know how to set the lcd, how to set some osc defines (and manipulate the xxxx.inc files) the only thing I donīt know is how to tell my 16F88 which input to use as analog in. And I donīt know why I need to set 3 registers for this, or even more.
It doesnīt matter if the variable dimension is this way or that, will get that clear after some try and error and maybe a little thinking.
But this ansel adcon thingy makes my head fuzzy.
when experimenting with serial transmission I often had only one baud rate that worked and didnīt know why.
Iīm now below even this state because I canīt get my analog in to work without my 12F675.
Ya...that'll help...
Probably because the datasheet for that particular PIC tells you what you need to set and where to set it and how to set it to do what you need to do. PBP is good, but sometimes it's not the 'Do-All, End-All', Holy Grail, for everything.the only thing I donīt know is how to tell my 16F88 which input to use as analog in. And I donīt know why I need to set 3 registers for this, or even more.
Seems to be an ongoing problem.Iīm now below even this state because I canīt get my analog in to work without my 12F675.
Different problems in different areas, most seemingly related to problems with reading/understanding (mostly initially reading) the datasheets for the particular PIC you are using.
PIC#1 (be it whichever type) is very similar to PIC#2 (whichever type)...
But by no means are they always equal...sometimes they're not even close.
The 'F628A that you were using is close to the 'F88, but the 'F88 is much newer, with more options in some areas, and, for most practical purposes, the 'F88 isn't even close to the 12F675. They're different families. Basic bare-bones code written for one, will most likely execute on the other without a problem. But once you get into the internal modules of the PICs, register locations change, register names change, register functions change, even bit positions can change.
Go to Microchip.com, download the latest datasheets for the PICs you are using, and skim thru them.
Bookmark the pages with registers and functions you are interested in and READ them, comprehend them, play with them.
Bookmarks