Page 1 of 1

Comparing values

Posted: Sat Jun 08, 2013 9:36 am
by Tony Brown
Hi All

I am trying to compare two values and display a 'dot' on a LCD as the values become closer to being the same, one of the numbers is fixed (set as a delay) whilst the other number is the count down. The dots would be like a percentage ie, at 10% of the delay being reached one dot would be on and at 100% all dots would be on.

Anyone have any ideas.

Thanks in advance :-)

Re: Comparing values

Posted: Sat Jun 08, 2013 10:18 am
by medelec35
Hi Tony,
I have moved post to V5 section since your a V5 registered user.

What number range have you got in mind?
E.g delay could be from 1 to 1000 ms for example

Or is range just a byte so delay could be from 1 to 255 ms?

Re: Comparing values

Posted: Sat Jun 08, 2013 11:52 am
by medelec35
I have attached a flowchart that will automatically calculate percentage from two numbers, Then will display as full stops across the bottom row depending on percentage results.
Not using floats, to keep ROM usage down.
The 90 choosen is just a random fixed number. That can be changed to your fixed number but only in the byte range until bytes are changed to integers if higher range is required.
Percentage shown on the top row of LCD is not count + 1, its the results from actual percentage calculations.
Flowchart can be modified so dots don't briefly flash when incrementing. I can sort that if required.
This way makes it a bit easier to follow.

I did count up and not count down, but it could be changed to count down.

Martin

Re: Comparing values

Posted: Sat Jun 08, 2013 9:00 pm
by Tony Brown
Hi Martin

Thanks for fast response, basically it's similar to the timer delay that you sorted for me with the time lapse project, so you select the time delay ie hours, minutes and seconds, as the delay is getting to 0 it is giving a dot for the percentage of time elapsed as an indicator for how much time is left.

Hope you can understand my question.

I tried converting the time delay to seconds and was going to try and work out the percentage from that but am not sure how to continue so your help is most appreciated.

Tony

Re: Comparing values

Posted: Sat Jun 08, 2013 9:17 pm
by medelec35
Hi Tony,
No problem,
You want 0 seconds left = 100% and the start of the timing period to be 0%?
So i'm editing correct flowchart, If you post the flowchart in question, I will edit it for you.

Martin

Re: Comparing values

Posted: Sat Jun 08, 2013 10:00 pm
by Tony Brown
Hi Martin

Yeah start at 0% and end at 100%.

It's really useful having this forum and people like you on it, im learning so much.

Thankyou

:-)

Re: Comparing values

Posted: Sun Jun 09, 2013 9:55 pm
by medelec35
No probs.

If you're using full stops, are they to replace count down time, or pics taken, or you going to use a LCD with more lines?

Re: Comparing values

Posted: Mon Jun 10, 2013 10:13 am
by Tony Brown
Yes im just making a timer that does not show the count down but uses full stops as an indicator of the amount of time passed.
I also do not need the trigger as it is just a count down timer.

Thanks

Tony

Re: Comparing values

Posted: Mon Jun 10, 2013 11:44 pm
by medelec35
Hi Tony.
I have altered flowchart so hours, mins and secs can be set. then when time is counting down, dot indicates from 0 to 100% time elapsed.
I will post it, but I don't know what you want to happen once time has elapsed?

Martin

Re: Comparing values

Posted: Tue Jun 11, 2013 6:33 pm
by Tony Brown
Hi Martin

Thanks for that, that will really help me.

I will be using it for something I want to make for work, it is going to be used to switch a device off and I thought the dots would make it abit different.

Thanks again for that :-)

Tony

Re: Comparing values

Posted: Sat Jun 15, 2013 12:52 pm
by medelec35
Hi Tony,
Just a thought.
If time period if fairly long, just seeing up to 16 dots will take some time to appear.

How about using custom characters?
As you may already know each char consists of 5 ×8 dot character fonts.
So you could either get one row at a time to be displayed, eg:
Different idea.png
(10.83 KiB) Downloaded 4324 times
You can see four steps (percentage calculations) has elapsed and not even one Char has been completed.
Of course if time set was a lot less e.g a few seconds then all 16 chrs will be filled in with all 8 rows completed.

You may remember I posted information on creating custom chars here:
http://www.matrixmultimedia.com/mmforum ... tom#p45599