how to print a decimal value in lcd
how to print a decimal value in lcd
hello sir,
what function should i use to print a decimal value
for eg a=7
b=2
c=a/b and in lcd when i use print number(c) command i want the lcd display to show 3.5 but float is not supported pls help
regards
ragesh
what function should i use to print a decimal value
for eg a=7
b=2
c=a/b and in lcd when i use print number(c) command i want the lcd display to show 3.5 but float is not supported pls help
regards
ragesh
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: how to print a decimal value in lcd
Hi ragesh,
I have moved topic so we can keep Tips section for posting tips, and not starting topic with a question question.
As for the Decimal point, take a look here:
http://www.matrixmultimedia.com/mmforum ... 326#p20298
There are two replies that should be able to help you.
With your example, I would 1st multiply a by 10 so you have got 70/2
Reason for that is with pic maths if not using float it will disreguard any remainders since bytes and intergers are whole numbers only.
so 7/2 = 3
not 3.5
Martin
I have moved topic so we can keep Tips section for posting tips, and not starting topic with a question question.
As for the Decimal point, take a look here:
http://www.matrixmultimedia.com/mmforum ... 326#p20298
There are two replies that should be able to help you.
With your example, I would 1st multiply a by 10 so you have got 70/2
Reason for that is with pic maths if not using float it will disreguard any remainders since bytes and intergers are whole numbers only.
so 7/2 = 3
not 3.5
Martin
Martin
Re: how to print a decimal value in lcd
hello sir,
as i am using flowcode for AVR can u please guide to a topic that deals my question with AVR
thank you!!
as i am using flowcode for AVR can u please guide to a topic that deals my question with AVR
thank you!!
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: how to print a decimal value in lcd
You will be able to use import function from File/ Import to import pic versions of Flowcode.
Or do you mean you want this thread moved to Flowcode V4?
What version of AVR do you have (Help, About Flowcode menu)?
If the version is too early then you will not be able to import successfully.
Or do you mean you want this thread moved to Flowcode V4?
What version of AVR do you have (Help, About Flowcode menu)?
If the version is too early then you will not be able to import successfully.
Martin
Re: how to print a decimal value in lcd
sir,
i use flowcode v4..i have imported it..but i want to display a mathematical calculation in decimals not an ADC value..
say 7/2..i want 3.5 to be displayed in my LCD display
i use flowcode v4..i have imported it..but i want to display a mathematical calculation in decimals not an ADC value..
say 7/2..i want 3.5 to be displayed in my LCD display
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: how to print a decimal value in lcd
Instead of adc, your using your own variables.
That flowchart was to show you a method of how it can be done, then you just create your own flowchart once you have learned the principles.
For that method you need to learn how Left$ and Right$ work.
Then as stated in my previous post
So 70/2=35
Convert to string then use Left$ and Right$ to separate the two digits.
Alternatively you can use the Mod function to separate the digits.
e.g
If your still stuck then I can post a flowchart to demonstrate both methods.
See if you can have a go first and post a flowchart, as that is a good learning method.
Martin
That flowchart was to show you a method of how it can be done, then you just create your own flowchart once you have learned the principles.
For that method you need to learn how Left$ and Right$ work.
Then as stated in my previous post
medelec35 wrote:
With your example, I would 1st multiply a by 10 so you have got 70/2
Reason for that is with pic maths if not using float it will disreguard any remainders since bytes and intergers are whole numbers only.
so 7/2 = 3
not 3.5
So 70/2=35
Convert to string then use Left$ and Right$ to separate the two digits.
Alternatively you can use the Mod function to separate the digits.
e.g
Code: Select all
Digit_0 = Voltage MOD 10
Digit_1 = Voltage / 10 MOD 10
See if you can have a go first and post a flowchart, as that is a good learning method.
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: how to print a decimal value in lcd
Hi rags,
I have altered flowchart from link I had posted, to display the result with a decimal point.
It may not be perfect, but it should do what you’re after. Martin
I have altered flowchart from link I had posted, to display the result with a decimal point.
It may not be perfect, but it should do what you’re after. Martin
- Attachments
-
- a div b v1.png
- (75.89 KiB) Downloaded 4189 times
Martin
Re: how to print a decimal value in lcd
hello sir ,
thanks for your response , thanks a lot!
i tried and have come up with a better and very easy solution.
what i did was..
a=7
b=2
c=7/2
all variables are FLOAT,
initialze string variable str. then use string manuplation[ str=floattostring(c)] ; now in lcd print string--> str and the its accuracy is upto six decimals!
thank you,
reagrds
ragesh
thanks for your response , thanks a lot!
i tried and have come up with a better and very easy solution.
what i did was..
a=7
b=2
c=7/2
all variables are FLOAT,
initialze string variable str. then use string manuplation[ str=floattostring(c)] ; now in lcd print string--> str and the its accuracy is upto six decimals!
thank you,
reagrds
ragesh
Re: how to print a decimal value in lcd
sorry small typing mistake in previous post
it is c=a/b
and its NOT
c=7/2
it is c=a/b
and its NOT
c=7/2
Re: how to print a decimal value in lcd
i have attched a sample file.
i have used at,ega32 MCU
i have used at,ega32 MCU
- Attachments
-
- print_adecimal.fcf_avr
- (5.5 KiB) Downloaded 453 times