Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to display '-' & '+' range number on LCD?

Status
Not open for further replies.

meera83

New Member
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..

thanks....
 
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.
 
movlw '-'
then call the display routine.
You can see the hexadecimal value of the symbol; -, +, =... from the disassembler listing.
 
Nigel Goodwin said:
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..

thanks..
 
bananasiong said:
movlw '-'
then call the display routine.
You can see the hexadecimal value of the symbol; -, +, =... from the disassembler listing.

you mean put '-' manually, right??

it is a ADC continuous input, so how the program know when it need '-' and sometime didn't??
 
meera83 said:
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?

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??

Yes, it's just maths - but -2.5/+2.5 would make more sense, as you only have a 5V range.

where can i check for the maths section on the PICList for examples?i use assembly language..

Under source code/maths.
 
Nigel Goodwin said:
Yes, and not just PIC's, almost every ADC works like that.



Yes, it's just maths - but -2.5/+2.5 would make more sense, as you only have a 5V range.



Under source code/maths.


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.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top