PDA

View Full Version : show on LCD decimal numbers



savnik
- 30th March 2007, 19:37
It's possible to show on LCD decimal numbers;
value = SQR 10 ' give 3,16
i use this:
Lcdout $fe,1, DEC (value DIG 2), "." ,DEC (value DIG 1) ,DEC (value DIG 0)
but not show correct.

skimask
- 30th March 2007, 20:19
It's possible to show on LCD decimal numbers;
value = SQR 10 ' give 3,16
i use this:
Lcdout $fe,1, DEC (value DIG 2), "." ,DEC (value DIG 1) ,DEC (value DIG 0)
but not show correct.

Let me guess....you're expecting 3.16 right?
Do a search in the PBP manual for floating point math and tell me what you come up with (hint: we've already been through this in January, see post #8 of the "16f877 with LM335 problem" thread ).

Pic_User
- 30th March 2007, 21:00
Hi savnik,

This is a very common problem.
A similar question is asked here.
Be sure to see Darrel's great explanation:
http://www.picbasic.co.uk/forum/showthread.php?t=5545

-Adam-

savnik
- 31st March 2007, 09:08
i have two variables:
x var word
y var word
and x < y.

How to show on lcd the result of x/y , or the value = SQR x/y

mackrackit
- 31st March 2007, 13:30
This has worked for me. Play with it.


RESULT VAR WORD

LCDOUT $FE,1,DEC RESULT/100,".",DEC2 RESULT//100


Note DEC2 and // after the dummy “.”

The DEC2 gives the last two digits and // gives the remainder or MOD of a number.

I use this to monitor battery voltage to the hundredths place.

skimask
- 31st March 2007, 15:59
i have two variables:
x var word
y var word
and x < y.

How to show on lcd the result of x/y , or the value = SQR x/y

Right...I understand that. I'm still trying to make you understand.
Again, I ask you to do a search in the PBP manual for floating point math and tell me what you come up with (same hint: we've already been through this in January, see post #8 of the "16f877 with LM335 problem" thread ).

savnik
- 31st March 2007, 19:28
Right...I understand that. I'm still trying to make you understand.
Again, I ask you to do a search in the PBP manual for floating point math and tell me what you come up with (same hint: we've already been through this in January, see post #8 of the "16f877 with LM335 problem" thread ).
I have read the manual for floating point very well and i have see post #8 of the "16f877 with LM335 problem" thread.
i use this:



' forwardpower = 400
' reflectedpower = 20
B0 = forwardpower/reflectedpower ' = 400/20 = 20
B1 = 10000/B0 ' = 10000*1/20 = 500
B2 = SQR B1 ' = 22,360679
B3 = (10000+B2*100)/(100-B2) ' = (10000+22*100)/(100-22) = 12200/78 = 156,4
Lcdout $fe,$90, "SWR : ",DEC (B3 DIG 2),".", DEC (B3 DIG 1),DEC (B3 DIG 0)

skimask
- 31st March 2007, 19:56
I have read the manual for floating point very well and i have see post #8 of the "16f877 with LM335 problem" thread.

So what's the problem? What did you find about floating point in the manual?

savnik
- 31st March 2007, 20:36
So what's the problem? What did you find about floating point in the manual?
now i don't have problem.
I spent many hours , how to solve my problem.
with floating point i solve my problem