large numbers
Moderator: Benj
large numbers
Hi,
I'm trying to make a display for the score on my pinball machine, see picture.
The general idea is that there is a score, that will be displayed on 6 or 8 7segmentleds.
To do so, I made a program that breaks a number into single digits, that wil be displayed after each other,
from the last number to the first. There is also a pulse for a 4022 to adress the individual displays.
In Flowcode I simulated the 4022 with 2 leds, and the segments by 7 leds set as an 7 segment.
long story, but here is the problem, when i simulate my program in flowcode it works fine with any number
from 1 to 999999, however when I upload it to my Picboard, it wil only show as an integer, upto 32677 or so.
It probably has to do with the stringfunctions, maybe someone knows a different way to separate every single digit?
thanks in advance,
Lex
I'm trying to make a display for the score on my pinball machine, see picture.
The general idea is that there is a score, that will be displayed on 6 or 8 7segmentleds.
To do so, I made a program that breaks a number into single digits, that wil be displayed after each other,
from the last number to the first. There is also a pulse for a 4022 to adress the individual displays.
In Flowcode I simulated the 4022 with 2 leds, and the segments by 7 leds set as an 7 segment.
long story, but here is the problem, when i simulate my program in flowcode it works fine with any number
from 1 to 999999, however when I upload it to my Picboard, it wil only show as an integer, upto 32677 or so.
It probably has to do with the stringfunctions, maybe someone knows a different way to separate every single digit?
thanks in advance,
Lex
- Attachments
-
- display_small.jpg (168.22 KiB) Viewed 6099 times
-
Sean
- Valued Contributor

- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: large numbers
Hello Lex,
32767 is the maximum positive value an integer variable can hold.
Would it be possible to split the score over two integers; one storing the lower 4 digits, and the other storing the higher 2 or 4 digits.
If the score increments are never larger than 9999, they can be added to the lower value. Each time the lower value exceeds 9999, subtract 10000 from it and increment the higher value.
It should be possible to extract all 6 or 8 digits for the display with a slight modification to your existing program - to scan both result integers in sequence.
32767 is the maximum positive value an integer variable can hold.
Would it be possible to split the score over two integers; one storing the lower 4 digits, and the other storing the higher 2 or 4 digits.
If the score increments are never larger than 9999, they can be added to the lower value. Each time the lower value exceeds 9999, subtract 10000 from it and increment the higher value.
It should be possible to extract all 6 or 8 digits for the display with a slight modification to your existing program - to scan both result integers in sequence.
Re: large numbers
Hi Sean,
thanks for your help, i will try it somewhere this week, and I'm sure it will work.
Part of the question was why does it work in the Flowcode simulation, and not in the actual Pic?
Wouldt it be better/easyer to test it in the FlowKit in-circuit debug system? ( I'm not a very
heavy user, and just started to use Flowcode, had a small course at Elector a month or so ago)
Is this a must have, or will it be to complcated for my purposes.
I will let you know if I succeeded, really like your products, they give me a nice headstart in my quest to build a pinball.
thanks for your help, i will try it somewhere this week, and I'm sure it will work.
Part of the question was why does it work in the Flowcode simulation, and not in the actual Pic?
Wouldt it be better/easyer to test it in the FlowKit in-circuit debug system? ( I'm not a very
heavy user, and just started to use Flowcode, had a small course at Elector a month or so ago)
Is this a must have, or will it be to complcated for my purposes.
I will let you know if I succeeded, really like your products, they give me a nice headstart in my quest to build a pinball.
-
Sean
- Valued Contributor

- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: large numbers
Flowcode simulation does not fully model the target device, but provides an overview of the way a program and its components will operate. In this case it appears that simulation and the target device have used different sized variables.
Simulation is still useful, but some more advanced programs do highlight differences in operation that need to be considered during development.
Flowkit removes the simulation modelling problems by running the program on the target device and reporting the results.
Simulation is still useful, but some more advanced programs do highlight differences in operation that need to be considered during development.
Flowkit removes the simulation modelling problems by running the program on the target device and reporting the results.
Re: large numbers
Hi Sean,
I tried to cut the large number in two pieces, and rebuild it in the programm, but it still doesn't work.
did it even twice, once with the use of stringmanipulations, and a second one with only math.
can't find what I'm doing wrong here, both versions work in my simulation, but react different in real.
Is it because I use the stringmanipulations wrong, or in the other case bad use of the calculations?
Hope that you ore someone can give me a hint,
I tried to cut the large number in two pieces, and rebuild it in the programm, but it still doesn't work.
did it even twice, once with the use of stringmanipulations, and a second one with only math.
can't find what I'm doing wrong here, both versions work in my simulation, but react different in real.
Is it because I use the stringmanipulations wrong, or in the other case bad use of the calculations?
Hope that you ore someone can give me a hint,
- Attachments
-
- display_4.fcf
- (59.42 KiB) Downloaded 273 times
-
- display_3.fcf
- (61.56 KiB) Downloaded 262 times
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: large numbers
Hello pinball
I have altered your program, to display any amount of numbers that your hardware will allow.
All you do is set a variable to 1 in order for your display to increase score.
E.G.
So the way it could work, is if ball causes port B0 to trigger, then that can assign Place_Value_New[3] = 1. So each time B0 is triggered, then 1000 will be added to score.
Like wise if B1 is triggered,then that can assign Place_Value_New[4] = 1. So each time B1 is triggered 10000 will be added to score.
To add 1 units set Place_Value_New[0] = 1
To add 10 set Place_Value_New[1] = 1
To add 100 set Place_Value_New[2] = 1
To add 1000 set Place_Value_New[3] = 1
To add 10000 set Place_Value_New[4] = 1
To add 100000 set Place_Value_New[5] = 1
Etc
Not had time to place display over range trap routine. Beside you may not like the way this routine works.
Hopefully This will work with your hardware.
This routine works like the pinball displays i remember anyway
Since it adds 100s , 10000s to display, and don't just count in 1s.
I have altered your program, to display any amount of numbers that your hardware will allow.
All you do is set a variable to 1 in order for your display to increase score.
E.G.
So the way it could work, is if ball causes port B0 to trigger, then that can assign Place_Value_New[3] = 1. So each time B0 is triggered, then 1000 will be added to score.
Like wise if B1 is triggered,then that can assign Place_Value_New[4] = 1. So each time B1 is triggered 10000 will be added to score.
To add 1 units set Place_Value_New[0] = 1
To add 10 set Place_Value_New[1] = 1
To add 100 set Place_Value_New[2] = 1
To add 1000 set Place_Value_New[3] = 1
To add 10000 set Place_Value_New[4] = 1
To add 100000 set Place_Value_New[5] = 1
Etc
Not had time to place display over range trap routine. Beside you may not like the way this routine works.
Hopefully This will work with your hardware.
This routine works like the pinball displays i remember anyway
Since it adds 100s , 10000s to display, and don't just count in 1s.
- Attachments
-
- display_4A.fcf
- (63.48 KiB) Downloaded 266 times
Martin
Re: large numbers
Hi Medelec,
thanks for your support, it is indeed another approach, and because I'm fairly new to this I'll have to puzzle
a little while on it. I already tested it on my hardware, and it didn't work, but I surewill look into it this week
I made another version myself, which already worked better. Its counting up numbers generated by the timerinterupt.
but has still some unaspected twists.
I suspect that it has to do with the way I used the timerfunction/macro.Have to dig deeper in that.
I want to try to use Can for communication between the several units of my system, so ther wil be
a Pic controlling the switches, a pic steering the displays, a pic controlling the sound etc.
you probably hear more from me on the forum,
Lex
thanks for your support, it is indeed another approach, and because I'm fairly new to this I'll have to puzzle
a little while on it. I already tested it on my hardware, and it didn't work, but I surewill look into it this week
I made another version myself, which already worked better. Its counting up numbers generated by the timerinterupt.
but has still some unaspected twists.
I suspect that it has to do with the way I used the timerfunction/macro.Have to dig deeper in that.
I want to try to use Can for communication between the several units of my system, so ther wil be
a Pic controlling the switches, a pic steering the displays, a pic controlling the sound etc.
you probably hear more from me on the forum,
Lex
- Attachments
-
- display_5.fcf
- (63.35 KiB) Downloaded 263 times
Re: large numbers
Hi Medelec,
couldn't wait and looked further into your file, and changed it a little cause my hardware has only 6 digits at the moment, but then its
working fine. I didn't know arrays could be used this way so I learned about it too, and of course, the use of the macro,
I did it the other way around, and with an interupt, I can imagine that this is better.
Thanks again it was really helpfull
Lex
couldn't wait and looked further into your file, and changed it a little cause my hardware has only 6 digits at the moment, but then its
working fine. I didn't know arrays could be used this way so I learned about it too, and of course, the use of the macro,
I did it the other way around, and with an interupt, I can imagine that this is better.
Thanks again it was really helpfull
Lex
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: large numbers
Thank you for letting me know. Glad its working. It should work for any amount of LED blocks. i added extra LED's to prove that point (maybe that was a bad idea on my part). But like you say, needs adapting for the amount you have.
So I have also adapted it for 6 LED blocks.
I have set the example for 699921 then I set Place_Value_New[2] = 1 = 100
so the calculation will be 699921 + 100 = 700021
And that is what you should get on your LED displays.
Hope it helps.
Let me know if you need further assistance to get your project fully working.
So I have also adapted it for 6 LED blocks.
I have set the example for 699921 then I set Place_Value_New[2] = 1 = 100
so the calculation will be 699921 + 100 = 700021
And that is what you should get on your LED displays.
Hope it helps.
Let me know if you need further assistance to get your project fully working.
- Attachments
-
- display_4B.fcf
- (62.57 KiB) Downloaded 265 times
Martin
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: large numbers
Just a thought. What about using float, convert float to string, then use Mid$ function to o/p one char at a time?
You used float with display_5, but you are using it different to how I would of used it.
I will put something together later today or this evening, and see how it pans out.
You used float with display_5, but you are using it different to how I would of used it.
I will put something together later today or this evening, and see how it pans out.
Martin
Re: large numbers
Hi Medelec,
that was my first thought too, (see my first attached file above) and it works fine in the flowcode software simulation,
but when I putted it in the hardware it somewhere see's the string as an integer, and will not go higher than 32677 or so.
Of course I'm curious if your solution is different as mine.....
that was my first thought too, (see my first attached file above) and it works fine in the flowcode software simulation,
but when I putted it in the hardware it somewhere see's the string as an integer, and will not go higher than 32677 or so.
Of course I'm curious if your solution is different as mine.....