i m using PIC16F877, assembly language to display ADC value on LCD..
before that, i already success to get the display value from 0.00-16.00..
but now i want to display the value from -5.00 until 5.00..
so how should i do in order to get the range??
i had try to display a range of 0.00-2.00..
after that, i add instruction of "sublw 0x64"..
when i play around with ADC, the result show
(first value)1.00...0.98..0.50...0.00..2.54...2.00...1.53(last value)
it start with 1 and decrease until 0.00, after 0.00, it directly jump to 2.54 and decrease again..
how should i do if i want the result decrease to 0.00 and then increase to the value i want..
how to make it display '-' before value 0.00 and '+' after value 0.00..
The ADC (as with pretty well all ADC's) only reads positive voltages, so you need to first bias the input to half way - so for zero volts in you get 512 out. Then anything above that is positive, and anything below it negative.
It's up to you how you handle negative numbers, I suggest you check the maths section on the PICList for examples.
The ADC (as with pretty well all ADC's) only reads positive voltages, so you need to first bias the input to half way - so for zero volts in you get 512 out. Then anything above that is positive, and anything below it negative.
It's up to you how you handle negative numbers, I suggest you check the maths section on the PICList for examples.
i not so understand with your explaination, is it you mean that the ADC and PIC can only accept + voltage but not +/- voltage as analogue input?
then if i choose to use 0-5V as analogue input voltage, but the number display on LCD i rescale to range number that i want(-5.00-5.00), is it possible??
where can i check for the maths section on the PICList for examples?i use assembly language..
Yes, and not just PIC's, almost every ADC works like that.
then if i choose to use 0-5V as analogue input voltage, but the number display on LCD i rescale to range number that i want(-5.00-5.00), is it possible??
how should i do with the source code in order to make the range decrease to zero and then increase again...
when i put in an instruction 'sub' at NumL, it just can decrease to zero..after zero value, it direct to highest value and decrease again but not increase from zero to highest value..
Subtract 512 (0x200) for your 16 bit result.
If bit 15=0 then display the number as it is positive.
If bit 15 = 1 then xor the number with 0xffff and add 1. Now display "-" and the number.
You will, of course, have to do the above using 16 bit maths.