How would you convert it, even if longs were available? The only way I can think of requires division by numbers greater than 16 bits, and multple-byte subtracts.
How would you convert it, even if longs were available? The only way I can think of requires division by numbers greater than 16 bits, and multple-byte subtracts.
It all depends on speed I think. How fast does this display function have to be?
One way would be to have 2 word size variables (High_Val and Low_Val) and 10 byte variables (No_1 to No_10)
Look at the DIG function in the manual
Example:
High_Val=51234
Low_Val=65535
No_1= High_Val DIG 4 'this makes No_1 to 5
No_2= High_Val DIG 3 'this makes No_2 to 1
No_3= High_Val DIG 2 'this makes No_3 to 2
No_4= High_Val DIG 1 'this makes No_4 to 3
No_5= High_Val DIG 0 'this makes No_5 to 4
No_6= Low_Val DIG 4 'this makes No_6 to 6
No_7= Low_Val DIG 3 'this makes No_7 to 5
No_8= Low_Val DIG 2 'this makes No_8 to 5
No_9= Low_Val DIG 1 'this makes No_9 to 3
No_10= Low_Val DIG 0 'this makes No_10 to 5
Then you just LCD out the numbers you need.
This code (not tested) should add up (overflow number x 65535) and timer counter and distribute the result into the array in position 0 the number (digit) to be displayed.Code:' Variables '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ W var Word [8] ' words array Tcount var Word ' timer count Ocount var word ' OverFlow timer count A0 var byte ' general purpose variable '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ W[0] = (Ocount * 5) + Tcount dig 4 W[1] = (Ocount * 3) + Tcount dig 3 + W[0] dig 1 W[2] = (Ocount * 5) + Tcount Dig 2 + W[0] dig 2 + W[1] dig 1 W[3] = (Ocount * 5) + Tcount Dig 1 + W[0] dig 3 + W[1] dig 2 + w[2] dig 1 W[4] = (Ocount * 6) + Tcount Dig 0 + W[1] dig 3 + W[2] dig 2 + W[3] dig 1 W[5] = W[2] dig 3 + W[3] dig 2 + W[4] dig 1 W[5] = W[3] dig 3 + W[4] dig 2 + W[5] dig 1 W[6] = W[4] dig 3 + W[5] dig 2 + W[6] dig 1 W[7] = W[5] dig 3 + W[6] dig 2 For A0 = 7 to 0 step -1 'Display W[A0] Dig 0 Next A0
Just run a for/next cycle with W[x] Dig 0 and you should display your number on your 8 digits display.
If you need the ascii value then you have to add 48 to every single digit in the for/next loop.
Al.
Last edited by aratti; - 9th July 2009 at 10:03.
All progress began with an idea
Thanks all!
Aratti, I ended up using your algorithm, but I fixed a few errors to make it work. Here's the code I ended up with:
W[0] = (Ocount * 6) + Tcount dig 0
W[1] = (Ocount * 3) + Tcount dig 1 + W[0] dig 1
W[2] = (Ocount * 5) + Tcount Dig 2 + W[0] dig 2 + W[1] dig 1
W[3] = (Ocount * 5) + Tcount Dig 3 + W[0] dig 3 + W[1] dig 2 + w[2] dig 1
W[4] = (Ocount * 6) + Tcount Dig 4 + W[1] dig 3 + W[2] dig 2 + W[3] dig 1
W[5] = W[2] dig 3 + W[3] dig 2 + W[4] dig 1
W[6] = W[3] dig 3 + W[4] dig 2 + W[5] dig 1
W[7] = W[4] dig 3 + W[5] dig 2 + W[6] dig 1
Thanks again
Joe
I was sure some adjustment was going to be necessary since I didn't tested it.
Al.
Last edited by aratti; - 9th July 2009 at 14:18.
All progress began with an idea
Bookmarks