-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Look at the datasheet for ADCON2. I feel like the setting you have for ADCON1 is really ment for ADCON2. ADCON1 only has 2 valid bits. Not the 2 you have set.
BTW, tb0=ntc>>8 will shift it 8 places. you would only need to shift 6 times. Yes this will work, but better to just set the registers up for what you want, then no un-needed code![]()
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Since ntc could be 0 or 1023 maximum, the condition if tb0>=16170 then is always false so tbo will be always zero and tb1 will be never setted with your required calculation tb1=tb0-16170.Code:From your code: ADCIN 1,ntc tb0=ntc if tb0>=16170 then tb1=tb0-16170 ELSE tb0=0 ENDIF
Cheers
Al.
Last edited by aratti; - 15th January 2011 at 17:19.
All progress began with an idea
Sorry ...
But my Easy Pic5 outputs " ITS : ...00.00°C " with all the processor settings I gave you in previous code, but 10 bits ADC ... ( Whistle and Bells ... )
I also asked for printing ntc Value ...
comprised between 0 and 1023 ...
try this :
so ... take your own conclusions !!!
ntc VAR WORD
tb0 VAR WORD
tb1 VAR WORD
tb2 VAR WORD
TRISA=%11111111
PAUSE 700
LCDOUT $fe,1
lp:
ADCIN 1,ntc
tb0 = ntc
if tb0 >= 16170 then
tb1 = tb0-16170
ELSE
tb1 = 0
ENDIF
tb1 = tb1*100
tb2 = Div32 634
tb0 = tb2/100
tb1 = tb2//100
LCDOUT $FE,2,DEC4 ntc
Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC2 tb1,"°C"
goto lp
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 " !!!
*****************************************
One more thing ...
The compiler doesn't like " ° " ( "Maj" + "=" ) character ...
better use
where 223 ( sometimes 178 ) is supposed to be the ASCII code of " ° " ...Code:Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC2 tb1, 223, "C"
That said ... ADC value NEVER is > 1023 ...
from your firsts explanations ( post #1) ... I get That : ( 16F877A on EasyPic5 )
Gives me a 0 - 100°C scale for adc = 67 to 1023 ...Code:DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE LCD_DREG PORTB ' Set LCD Data port DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus .7 DEFINE LCD_RSREG PORTB ' Set LCD Register Select port DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit DEFINE LCD_EREG PORTB ' Set LCD Enable port DEFINE LCD_EBIT 5 ' Set LCD Enable bit i.e, PORTE.4 DEFINE LCD_BITS 4 ' Set LCD bus size ot 4 bit Upper Nibble (4 or 8 bits) DEFINE LCD_LINES 2 ' Set number of lines on LCD to 4 Lines TRISA = %11111111 TRISB = 0 TRISC = 0 CMCON = 7 ADCON0 = %11000001 ADCON1 = %10000100 ntc VAR WORD tb0 VAR WORD tb1 VAR WORD tb2 VAR WORD PAUSE 700 LCDOUT $fe,1 lp: ADCIN 1,ntc tb0 = ntc * 33 /92 tb1 = tb0*721 tb2 = Div32 255 tb2 = tb2 - 64 tb0 = tb2/10 tb1 = tb2//10 PAUSE 200 LCDOUT $FE,2,DEC4 ntc Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC1 tb1,178,"C" goto lp
so, i suppose it to be " not so bad , but to confirm "
Alain
Last edited by Acetronics2; - 15th January 2011 at 20:08.
************************************************** ***********************
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 " !!!
*****************************************
Epilog ...
for general knowledge ... a look at Microchip AN 942 may be valuable ...
Ok, my problem is largely solved
I think my PIC is a special case.
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 " !!!
*****************************************
Bookmarks