Percentage calculation...
Archiver
Posts: 46,084
Can anyone help me here ?
My application stores fluid delivery data, and I want to be able to view the
percentage of memory usage in our external Eeprom. The maximum number of
fluid delivery records is 1500 in the memory. If we have had 167 deliveries,
I would like to be able to see the memory use (in percent) on our lc
display.
Is there an easy way to do this ? (the percentage math). I have been trying
to nut it out for a while and cant seem to get a decent result. I know that
the principle is 100/1500*deliveries, but the stamp cant do this being
integer.
I think I was staring out the window during maths classes as a kid, and now
I'm paying for it !!
Cheers,
Chris
My application stores fluid delivery data, and I want to be able to view the
percentage of memory usage in our external Eeprom. The maximum number of
fluid delivery records is 1500 in the memory. If we have had 167 deliveries,
I would like to be able to see the memory use (in percent) on our lc
display.
Is there an easy way to do this ? (the percentage math). I have been trying
to nut it out for a while and cant seem to get a decent result. I know that
the principle is 100/1500*deliveries, but the stamp cant do this being
integer.
I think I was staring out the window during maths classes as a kid, and now
I'm paying for it !!
Cheers,
Chris
Comments
Chris-
How about deliveries/15? That will give you 0% for 0-14, 1% for
15-29,...,99% for 1485-1499, 100% for 1500. If that's all the
precision needed, it's quick and short.
Also, IMHO, looking out windows at eucalyptus trees is a valid excuse
for most any later difficulty.
Regards,
Steve
On 8 Aug 03 at 7:43, Chris Anderson wrote:
> Can anyone help me here ?
>
> My application stores fluid delivery data, and I want to be able to
> view the percentage of memory usage in our external Eeprom. The
> maximum number of fluid delivery records is 1500 in the memory. If
> we have had 167 deliveries, I would like to be able to see the
> memory use (in percent) on our lc display.
items in your equation. After playing a bit, I was able to reduce the
percentage (in whole units) to:
percent = deliveries / 15
If you want fractional (tenths) resolution...
percent = deliveries * 10 / 15
And if you're using a serial LCD, you can send it with this:
SEROUT pin, baud, [noparse][[/noparse]DEC (percent / 10), ".", DEC1 percent]
Finally, if you want whole units, but would like to round up, here's
how:
percent = deliveries * 10 / 15 + 5 / 10
Remember, the Stamp evaluates math left-to-right (unless you adjust with
parenthesis). In this version, version is calculated in tenths, then 5
is added to round up, the the result divided by 10 to get back to the
whole number value.
I hope this helps.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Chris Anderson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=vW6LSjDLgSpslO9AEBXAbfNq9yPZHEDdrSlFrvEoZ-Yf8hv4DM_pYhBoRQsfUSEsqcQKT0XZ8xAi]fuel@b...[/url
Sent: Thursday, August 07, 2003 6:43 PM
To: Stamp Group
Subject: [noparse][[/noparse]basicstamps] Percentage calculation...
Can anyone help me here ?
My application stores fluid delivery data, and I want to be able to view
the percentage of memory usage in our external Eeprom. The maximum
number of fluid delivery records is 1500 in the memory. If we have had
167 deliveries, I would like to be able to see the memory use (in
percent) on our lc display.
Is there an easy way to do this ? (the percentage math). I have been
trying to nut it out for a while and cant seem to get a decent result. I
know that the principle is 100/1500*deliveries, but the stamp cant do
this being integer.
I think I was staring out the window during maths classes as a kid, and
now I'm paying for it !!
Cheers,
Chris
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
hard to do", which would make me feel better about having trouble with it.
But you have given such a simple answer, which is exactly what I needed.
Thank you very much for the prompt reply.
Cheers,
Chris
Original Message
From: "S Parkis" <parkiss@e...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, August 08, 2003 8:04 AM
Subject: Re: [noparse][[/noparse]basicstamps] Percentage calculation...
> Chris-
> Chris-
>
> How about deliveries/15? That will give you 0% for 0-14, 1% for
> 15-29,...,99% for 1485-1499, 100% for 1500. If that's all the
> precision needed, it's quick and short.
>
> Also, IMHO, looking out windows at eucalyptus trees is a valid excuse
> for most any later difficulty.
>
> Regards,
>
> Steve
>
> On 8 Aug 03 at 7:43, Chris Anderson wrote:
>
> > Can anyone help me here ?
> >
> > My application stores fluid delivery data, and I want to be able to
> > view the percentage of memory usage in our external Eeprom. The
> > maximum number of fluid delivery records is 1500 in the memory. If
> > we have had 167 deliveries, I would like to be able to see the
> > memory use (in percent) on our lc display.
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
I use heaps of serout's to lcd in my code. I have never thought of doing the
math in the same line as the serout code. i think I am going to reduce my
code by a lot now that I have seen your answer.
Thanks also for the percentage stuff, it is much appreciated.
Cheers,
Chris
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, August 08, 2003 9:22 AM
Subject: RE: [noparse][[/noparse]basicstamps] Percentage calculation...
> You're on the right track, you just need to modify the order of the
> items in your equation. After playing a bit, I was able to reduce the
> percentage (in whole units) to:
>
> percent = deliveries / 15
>
> If you want fractional (tenths) resolution...
>
> percent = deliveries * 10 / 15
>
> And if you're using a serial LCD, you can send it with this:
>
> SEROUT pin, baud, [noparse][[/noparse]DEC (percent / 10), ".", DEC1 percent]
>
> Finally, if you want whole units, but would like to round up, here's
> how:
>
> percent = deliveries * 10 / 15 + 5 / 10
>
> Remember, the Stamp evaluates math left-to-right (unless you adjust with
> parenthesis). In this version, version is calculated in tenths, then 5
> is added to round up, the the result divided by 10 to get back to the
> whole number value.
>
> I hope this helps.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: Chris Anderson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Y3iM02qNqPW1b8IKvdBpcQBMxGYK0azt2JaNutTfCUf0zumUncQe7HT2y39wBpbhhvPk1vOu6cxjc9E]fuel@b...[/url
> Sent: Thursday, August 07, 2003 6:43 PM
> To: Stamp Group
> Subject: [noparse][[/noparse]basicstamps] Percentage calculation...
>
>
> Can anyone help me here ?
>
> My application stores fluid delivery data, and I want to be able to view
> the percentage of memory usage in our external Eeprom. The maximum
> number of fluid delivery records is 1500 in the memory. If we have had
> 167 deliveries, I would like to be able to see the memory use (in
> percent) on our lc display.
>
> Is there an easy way to do this ? (the percentage math). I have been
> trying to nut it out for a while and cant seem to get a decent result. I
> know that the principle is 100/1500*deliveries, but the stamp cant do
> this being integer.
>
> I think I was staring out the window during maths classes as a kid, and
> now I'm paying for it !!
>
> Cheers,
> Chris
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p....
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
divide by the 10 or 100 to get you back down to reality<G>.
Original Message
From: S Parkis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ndSu8aRn84jBQ1XfEkW8O3YAtzrax421nwjaCSTkvHPkyydl9Ab8hLoaDvOF15WYgjtSINZ3HvbuhDk]parkiss@e...[/url
Sent: Thursday, August 07, 2003 8:05 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Percentage calculation...
Chris-
Chris-
How about deliveries/15? That will give you 0% for 0-14, 1% for
15-29,...,99% for 1485-1499, 100% for 1500. If that's all the
precision needed, it's quick and short.
Also, IMHO, looking out windows at eucalyptus trees is a valid excuse
for most any later difficulty.
Regards,
Steve
On 8 Aug 03 at 7:43, Chris Anderson wrote:
> Can anyone help me here ?
>
> My application stores fluid delivery data, and I want to be able to
> view the percentage of memory usage in our external Eeprom. The
> maximum number of fluid delivery records is 1500 in the memory. If we
> have had 167 deliveries, I would like to be able to see the memory use
> (in percent) on our lc display.
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
65535.
Cheers,
Chris
Original Message
From: "Grover Richardson" <grover.richardson@g...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, August 08, 2003 9:25 PM
Subject: RE: [noparse][[/noparse]basicstamps] Percentage calculation...
> Take a vlaue. Multiply it by 10 or 100. Then do the percentage. Then
> divide by the 10 or 100 to get you back down to reality<G>.
>
>
Original Message
> From: S Parkis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=BQSsLW8c3hUGIWJmVxlnAoqzJFfj0oWlatCzdNZFu8wepkV4r-MVKg4fQ4H00RtnfY_0CPLaTXAM3y30_g]parkiss@e...[/url
> Sent: Thursday, August 07, 2003 8:05 PM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Percentage calculation...
>
>
> Chris-
> Chris-
>
> How about deliveries/15? That will give you 0% for 0-14, 1% for
> 15-29,...,99% for 1485-1499, 100% for 1500. If that's all the
> precision needed, it's quick and short.
>
> Also, IMHO, looking out windows at eucalyptus trees is a valid excuse
> for most any later difficulty.
>
> Regards,
>
> Steve
>
> On 8 Aug 03 at 7:43, Chris Anderson wrote:
>
> > Can anyone help me here ?
> >
> > My application stores fluid delivery data, and I want to be able to
> > view the percentage of memory usage in our external Eeprom. The
> > maximum number of fluid delivery records is 1500 in the memory. If we
> > have had 167 deliveries, I would like to be able to see the memory use
>
> > (in percent) on our lc display.
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
fix it. I'll monitor more<G>.
Woof
Original Message
From: Chris Anderson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=49igBZAgrZszdsDJeKCrM7XscD4TYZ2afQbSATzpssrFJ-AAtWxKHAy0GbQjLsvL7wv-7JInRgDFg4KQdA]fuel@b...[/url
Sent: Sunday, August 10, 2003 7:18 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Percentage calculation...
Thanks, but that doesnt work if your starting value * 10 or 100 is over
65535.
Cheers,
Chris
Original Message
From: "Grover Richardson" <grover.richardson@g...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, August 08, 2003 9:25 PM
Subject: RE: [noparse][[/noparse]basicstamps] Percentage calculation...
> Take a vlaue. Multiply it by 10 or 100. Then do the percentage.
> Then divide by the 10 or 100 to get you back down to reality<G>.
>
>
Original Message
> From: S Parkis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=1HUNnyAjmZoSgKMRW_72SKAWIiDi8x3WCqmQK1pVQTYprMn1DEjtiekTM6RRCsQG85HPa2tpB98zHTUmZ6I7]parkiss@e...[/url
> Sent: Thursday, August 07, 2003 8:05 PM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Percentage calculation...
>
>
> Chris-
> Chris-
>
> How about deliveries/15? That will give you 0% for 0-14, 1% for
> 15-29,...,99% for 1485-1499, 100% for 1500. If that's all the
> precision needed, it's quick and short.
>
> Also, IMHO, looking out windows at eucalyptus trees is a valid excuse
> for most any later difficulty.
>
> Regards,
>
> Steve
>
> On 8 Aug 03 at 7:43, Chris Anderson wrote:
>
> > Can anyone help me here ?
> >
> > My application stores fluid delivery data, and I want to be able to
> > view the percentage of memory usage in our external Eeprom. The
> > maximum number of fluid delivery records is 1500 in the memory. If
> > we have had 167 deliveries, I would like to be able to see the
> > memory use
>
> > (in percent) on our lc display.
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/