Last edited by Acetronics2; - 15th January 2011 at 15:01.
************************************************** ***********************
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 " !!!
*****************************************
-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!
It's weird. I got a 16-bit result. Why? Code :
Code:define OSC 20 DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 10 DEFINE LCD_DREG PORTC DEFINE LCD_RSREG PORTC DEFINE LCD_EREG PORTC DEFINE LCD_EBIT 5 DEFINE LCD_COMMANDUS 10000'Command delay time in us DEFINE LCD_DATAUS 1000 'Data delay time in us ntc VAR WORD TRISA=%11111111 ADCON1=%10000010 PAUSE 4000 lp: ADCIN 1,ntc PAUSE 100 Lcdout $fe,$c0,#ntc goto lpAnd what are the differences between Tb0 and Tb0? I didn't understand your answer.you do not display Tb0 ( as the ADC result ) , but Tb0
Last edited by pxidr84; - 15th January 2011 at 15:36.
Never trust a sim.
Try it in real life and come back.
Dave
Always wear safety glasses while programming.
see any difference between Tb0 value @ line 1 and Tb0 Value @ line 5 ???ADCIN 1,tb0
tb1=tb0-16170
tb1=tb1*tb3
tb2=Div32 634
tb0=tb2/100
tb1=tb2//100
really no ?
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 " !!!
*****************************************
In real life with the same code:
My updated code :
I was surprised because the previous code worked good.Code:define OSC 20 DEFINE ADC_BITS 10 DEFINE ADC_SAMPLEUS 10 DEFINE LCD_DREG PORTC DEFINE LCD_RSREG PORTC DEFINE LCD_EREG PORTC DEFINE LCD_EBIT 5 ntc VAR WORD tb0 VAR WORD tb1 VAR WORD tb2 VAR WORD TRISA=%11111111 ADCON1=%10000010 PAUSE 4000 lp: ADCIN 1,ntc tb0=ntc if tb0>=16170 then tb1=tb0-16170 ELSE tb0=0 ENDIF tb1=tb1*100 tb2=Div32 634 tb0=tb2/100 tb1=tb2//100 PAUSE 100 Lcdout $fe,$c0,"ITS: ",DEC (tb0 DIG 1),DEC (tb0 DIG 0),".",DEC (tb1 DIG 1),"°C" goto lp
-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 " !!!
*****************************************
Bookmarks