Thank you.Originally Posted by Darrel Taylor
At 0 volt show value: 0 and at 5 volt show value:3
How i can at 0 volt show value: 0 and at 5 volt show value: 50 or 100 or something greater from 3;
Is easy to show the level as bargaph on LCD;
Thank you.Originally Posted by Darrel Taylor
At 0 volt show value: 0 and at 5 volt show value:3
How i can at 0 volt show value: 0 and at 5 volt show value: 50 or 100 or something greater from 3;
Is easy to show the level as bargaph on LCD;
Post the schematic.
Let us see your ADC reading part also.
---------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
For 8 bit, you should Left justify the results.At 0 volt show value: 0 and at 5 volt show value:3
ADCON1.7 = 0
<br>
DT
i have thisOriginally Posted by Darrel Taylor
and modify the result:Code:' Define ADCIN parameters DEFINE ADC_BITS 8 'Set number of bits in result DEFINE ADC_CLOCK 3 'Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 'Set sampling time in uS CMCON = 7 'PortA = digital I/O ANSEL = %00010000 'Will set RA4 as analog and all others as digital ADCON0 = %11100001 'Configure and turn on A/D Module ADCON1 = %00000010 'Set PORTA analog and RIGHT justify result
adval = adval*2/100
and at 0 volt show value: 0 and at 5 volt show value:5
For 8-bit results, the largest number will be 255 at +5V.
255 * 2 = 510
510 / 100 = 5 (integer)
So let's assume you were trying to convert the A/D reading to a Voltage number.
<pre>255 * 5 / 255 = 5 ; Single digit<br>255 * 50 / 255 = 50 ; 1 decimal place (5.0)<br>255 * 500 / 255 = 500 ; 2 decimals (5.00)</pre>Those could also be done with the */ (Mid word) multiplication.<pre>255 */ 5 = 5<br>255 */ 50 = 50<br>255 */ 500 = 500</pre>Be sure to use WORD variables for the calculation.
Then to display it ...<pre>LCDOUT DEC value,"V" ; Single digit<br>LCDOUT DEC value/10,".",DEC value // 10, "V" ; 1 decimal place<br>LCDOUT DEC value/100,".",DEC value // 100, "V" ; 2 decimals</pre>
If you go with 2 decimals, you may want to use 10-bit values from the A/D for better accuracy.
In which case you would Right Justify, and the math changes to...<pre>1023 * 5 / 1023 = 5 ; Single digit<br>1023 * 50 / 1023 = 50 ; 1 decimal place<br>1023 * 500 / 1023 = 500 ; 2 decimals</pre>But you'll need to use DIV32 for those.
DT
ADCIN 4, adval 'Read channel 4 to adval
adval1 = adval*2/100
adval2 = adval*4//10
Lcdout "POWER: ", DEC2 adval1, ".", DEC1 adval2," WATT "
I have use this code and show ok
I was going to ask how would you see say 2.30V, but Darrel already touched that point.
Now I wonder where did this "Watt" come from?
Lcdout "POWER: ", DEC2 adval1, ".", DEC1 adval2," WATT "
---------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
I want to use 10-bit values.Originally Posted by Darrel Taylor
But i can use the DIV32 command to show the result on LCD.
Now for 8 bit i have this code:
Code:ADCIN 0, adval ' Read channel 0 to adval value = adval*50/255 ' 1 decimal place (5.0) LCDOUT $FE,1,"VOLT : ",DEC value/10, ".",DEC value//10, " V"
Last edited by savnik; - 15th December 2006 at 09:42.
i use this:
ADCIN 0, adval ' Read channel 0 to adval
dummy = adval * 5 * 100 ' Multiply to load internal registers with 32-bit value
value = Div32 1023 ' Divide 32-bit value by word and store in word
Lcdout $fe,1, "VOLT : ", DEC value/10,".", DEC value//10, " V"
Bookmarks