Posted by N.Winterbottom: Tue. Apr 12, 2022 - 08:34 AM
1
2
3
4
5
Total votes: 0
xXThiagox3dDXx wrote:
I tried that code but it seems to have some errors, have another example?
Oh dear. This is worrying.
Although the code in that linked example leaves room for improvement (no segment definitions and mixed Capitalised / lowercase variable names) it's fine as a demo.
However; you really should have been able to fix that trivial error. You dismiss the code far too quickly in search of another example.
Running the AtMega328 at 16MHz, what is common on the small nano and mini Arduino board ($6 at AliExpress), just set the fuses to not divide clock/8. You can run TimerCounter1 in compare mode (interrupt when reaching 62500), at full clock, the interrupt will happens 256 times per second. In the interrupt routine just decrement a counter from $00 and see it if reaches $00 again, means exactly 1 second. When this happens, just verify which button is pressed and increment the seconds counter for that button. If the seconds reach 60, zero it and increase minutes. Send the counters numbers to the display. Use a Max7219 to make it easier to light the 7 segments display. Reset the counters to zero on power on. If you know assembly language, all of this can be done and tested in 30 minutes.
Posted by Brian Fairchild: Tue. Apr 19, 2022 - 08:12 AM
1
2
3
4
5
Total votes: 0
You seem to be missing some important steps in your design process.
You have made the classic mistake of diving in and writing code without giving any thought to actually designing the code. Where are your flowcharts or similar? Where are your snippets (small pieces) of test code?
It's a good job I don't teach as I'd fail anyone who only presented working code.
#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."
I don't know Bascom but it might be an idea to see if the editor has a way to show line numbers. However in:
It is pretty evident that the line in red must be line 167 which is the line to which all four listed errors refer. So just red what it is telling you about that line:
"wrong data type"
"unknown variable"
"variable not dimensioned"
(ignore the last about "NEXT expected" - that is just a consequence of the first three errors).
Those errors are all talking about "Digit8". It's maybe not surprising as it's the only thing really mentioned on line 167 apart from standard BASIC keywords like "FOR" and "TO".
Again I don't know Bascom but it did not take me long to find:
Before assigning a variable, you must tell the compiler about it with the DIM statement.
Dim b1 AsBit, I asInteger, k asByte, s AsString* 10
This is not unlike the C programming language too; before a variable can be used it must be declared in some way so that the language knows what type it is, how much storage to set aside for it and how how to treat it in subsequent operations. Adding "+ 1" to a "byte" or "integer" is going to be quite different to performing "+ 1" in a string for example!
So clearly
Sub Buff_out(byval Disno As Byte)
For Digit8 = 1 To 8
Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno)
Next
End Sub
needs to be:
Sub Buff_out(byval Disno As Byte)
Dim Digit8 As Byte
For Digit8 = 1 To 8
Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno)
Next
End Sub
However, even before that is added perhaps alarm bells should have been ringing as there are clues here that this is NOT very well written code. A good programmer will use indentation to show the flow of execution. The fact that all the lines are left aligned suggests someone is sloppy and not putting much effort into the code so I would be suspicious of the code anyway. It probably should look more like:
Sub Buff_out(byval Disno As Byte)
Dim Digit8 As Byte
For Digit8 = 1 To 8
Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno)
Next
End Sub
By the way, earlier in the code you will see an example:
Sub No_op(byval T As Byte)
Local C As Byte
Local H As Word
H = 0
For C = 1 To T
Shiftout Ser_data , Ser_clk , H , 1 , 16 , 10
Next C
End Sub
What this shows you is that there is an alternative to "Dim" which is "Local". Again, you would need to read more of that manual I just linked to but I imagine (a bit like local variables in C) that using "Local" instead of "Dim" just makes a more efficient (possibly!), more isolated/localised variable and is probably preferable to "Dim" which is more likely used for "global" variables. So the sub routine might be better as:
Sub Buff_out(byval Disno As Byte)
Local Digit8 As Byte
For Digit8 = 1 To 8
Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno)
Next
End Sub
The fact that someone posted that code to a message board without having actually compiled/tested it (or they would have seen the same error you did) is, again, not a great sign.
One more little detail: If you're actually trying to build a chess clock, spend some money and get good and durable pushbuttons. If you use the cheapest electronic junk buttons, your chess players will want to strangle you.
One more little detail: If you're actually trying to build a chess clock, spend some money and get good and durable pushbuttons. If you use the cheapest electronic junk buttons, your chess players will want to strangle you.
Get good buttons. S.
I agree. Arcade game buttons were designed to take abuse day in day out.
Posted by xXThiagox3dDXx: Wed. Apr 20, 2022 - 06:49 AM(Reply to #58)
1
2
3
4
5
Total votes: 0
hey actually before doing some flowcharts and doing things like that i just wanted to ensure miself that i can show numbers in 2 screens, so i can actually see if it possible to do. just that
Posted by xXThiagox3dDXx: Wed. Apr 20, 2022 - 06:52 AM(Reply to #58)
1
2
3
4
5
Total votes: 0
our teacher ask us every monday what can promise to him and he ussualy give a instruction, for this week the idea is to show 4 numbers in each screen using the max7219
One more little detail: If you're actually trying to build a chess clock, spend some money and get good and durable pushbuttons. If you use the cheapest electronic junk buttons, your chess players will want to strangle you.
Get good buttons. S.
I agree. Arcade game buttons were designed to take abuse day in day out.
Or perhaps use those huge red emergency stop buttons. They also have to be able to take a pounding because of their function, and would be easy to hit.
Wayne
East London
South Africa
No, I am not an Electronics Engineer, just a 54 year old hobbyist/enthusiast
Yes, I am using Proteus to learn more about circuit design and electronics
No, I do not own a licensed copy of Proteus, I am evaluating it legitimately
No, I do not believe in software or intellectual property piracy or theft
Posted by N.Winterbottom: Thu. Apr 21, 2022 - 10:38 AM
1
2
3
4
5
Total votes: 0
grohote wrote:
a swing position is visible.
The picture (the smaller of the two images) of a Luxury Chess Clock I posted back in #34 has a giant rocker switch. Very visible as to whose turn it is.
Posted by aphawk: Thu. Apr 21, 2022 - 10:13 PM(Reply to #65)
1
2
3
4
5
Total votes: 0
I put the program reduced to only show the 4 digits in your other post about ATMEGA328 and MAX7219. See the two examples I put in the program.
Is very ease now, you only need to put the 4 numbers in the array Digitos(), and call a subroutine. I don't believe that you don't have success modifying my small code....
My friend, Bascom is very easy to use and understand, you only must dedicate a small time to use it.
I have programs in comercial products that almost completes the 32K of Program Area of Atmega328, mixed with a lot of Assembly code, all works very well for some years.
Make a good decision to you : study more and practice more !
Posted by xXThiagox3dDXx: Thu. Apr 28, 2022 - 03:50 AM
1
2
3
4
5
Total votes: 0
acct we already make the multiplexing and make the two screens work, the code is here
$crystal = 8000000
$regfile = "m328Pdef.dat"
$hwstack = 40
$swstack = 32
$framesize = 52
Dim Digitos(8) As Byte
Dim Numero As Word
Dim I As Byte
Const Reg_decode_mode = &B1111100111111111
Const Reg_scan_limit = &B1111101111111111
Const Reg_intensity = &B1111101011111111
Const Reg_shutdown = &B1111110011111111
Config Portc.0 = Output
Config Portc.1 = Output
Config Portc.2 = Output
Max_data Alias Portc.0
Max_load Alias Portc.1
Max_clock Alias Portc.2
Max_load = 1
Numero = Reg_shutdown
Gosub Sai_max
Numero = Reg_decode_mode
Gosub Sai_max
Numero = Reg_intensity
Gosub Sai_max
Numero = Reg_scan_limit
Gosub Sai_max
Do
Digitos(8) = 1
Digitos(7) = 1
Digitos(6) = 0
Digitos(5) = 0
Digitos(4) = 1
Digitos(3) = 8
Digitos(2) = 9
Digitos(1) = 9
Gosub Mostra
Wait 2
Digitos(8) = 1
Digitos(7) = 0
Digitos(6) = 0
Digitos(5) = 0
Digitos(4) = 0
Digitos(3) = 0
Digitos(2) = 0
Digitos(1) = 0
Gosub Mostra
Wait 2
Loop
Mostra:
Numero = 0
For I = 8 To 1 Step -1
Numero = Digitos(i)
Select Case I
Case 1
Numero = Numero Or &B1111100000000000
Case 2
Numero = Numero Or &B1111011100000000
Case 3
Numero = Numero Or &B1111011000000000
Case 4
Numero = Numero Or &B1111010100000000
Case 5
Numero = Numero Or &B1111010000000000
Case 6
Numero = Numero Or &B1111001100000000
Case 7
Numero = Numero Or &B1111001000000000
Case 8
Numero = Numero Or &B1111000100000000
End Select
Gosub Sai_max
Next I
Return
Sai_max:
Max_data = 0
Max_clock = 0
Max_load = 0
Shiftout Max_data , Max_clock , Numero , 1
Max_load = 1
Return
End
now we are doing a counter from 0 to 9999 and one from 9999 to 0000, to ha testing in the screens, we have a working code for the 2 screens, sugest on how to do the code
No one here knows your code so we can only guess at what those fixed numbers like:
B1111011100000000
might be used for? A comment explaining what's going on will be helpful for people like us to understand what your program is doing.
Now you may not think this matters but when you (or your code maintainer!) come back to this in 18 months some help to understand what was in the author's mind at the time it was written will be VERY helpful!
Posted by xXThiagox3dDXx: Sun. May 1, 2022 - 03:47 AM(Reply to #74)
1
2
3
4
5
Total votes: 0
hello, basically that code puts the screens to work through the max 7219, the parts that put b111000 etc, are the configuration of the max, these are made up of 16 digits and based on what you put in some specific digits indicated in the datasheet, you can configure the lighting, the number of digits to read, etc. the pdf that explains the work is in spanish, but anyonbe can translate whit some search in google
Posted by xXThiagox3dDXx: Sun. May 1, 2022 - 07:00 AM
1
2
3
4
5
Total votes: 0
hello, query, I want to implement a counter from 0 to 9999 in my program, the problem is that the screen is separated by digits, that is digit 1 = 0 digit 2 = 0 digit 3 = 0 digit 4 = 0 I mean I can't just put a variable that replaces the digit and add one to it, I have to increase each number up to nine, return it to 0 and so on to count up to 9999, I came up with a mean bad idea that nothing else allows me to count up to 10 by which then starts to count wrong, any idea how to do it?
acct we already make the multiplexing and make the two screens work, the code is here...
now we are doing a counter from 0 to 9999 and one from 9999 to 0000, to ha testing in the screens, we have a working code for the 2 screens, sugest on how to do the code
that post say you have working code ?
xXThiagox3dDXx wrote:
hello, query, I want to implement a counter from 0 to 9999 in my program, the problem is that the screen is separated by digits, that is digit 1 = 0 digit 2 = 0 digit 3 = 0 digit 4 = 0 I mean I can't just put a variable that replaces the digit and add one to it, I have to increase each number up to nine, return it to 0 and so on to count up to 9999, I came up with a mean bad idea that nothing else allows me to count up to 10 by which then starts to count wrong, any idea how to do it?
but then this post suggest you have problems ?
Usually for clocks as counters, the simplest is to allocate a BYTE sized variable per digit, and to manage the increment and decrement with overflows in SW.
The overflow varies, depending on which digit it is.
Along the lines of
If you display HH:MM lets call that Hh:Mm to give each a unique letter.
m increments 0..9 and when = 10, replace with 0 and increment M.
When M increments to 6, replace it with 0 and increment h (thus highest could is 59 -> 00)
When h increments = 10, replace with 0 and increment H. (24 hr clock)
When H,h is 2,4 replace with 0,0 (thus highest is 23:59) for a 24 hour clock.
Posted by xXThiagox3dDXx: Mon. May 2, 2022 - 05:36 AM
1
2
3
4
5
Total votes: 0
hey we already maked the 2 counters, ill show the code working, the coments are in spanish sorry.. you can translate them whit google
$crystal = 8000000
$regfile = "m328Pdef.dat"
$hwstack = 40
$swstack = 32
$framesize = 52
Dim Digitos(8) As Byte 'Se dimensiona variable array con 8 elementos tipo byte
Dim Numero As Word
Dim I As Byte
Dim D1 As Byte
Dim D2 As Byte
Dim D3 As Byte
Dim D4 As Byte
Dim D5 As Byte
Dim D6 As Byte
Dim D7 As Byte
Dim D8 As Byte 'dimension variable byte para el valor de cada dígito
D1 = 0
D2 = 0
D3 = 0
D4 = 0
D5 = 9
D6 = 9
D7 = 9
D8 = 9
Const Reg_decode_mode = &B1111100111111111
Const Reg_scan_limit = &B1111101111111111
Const Reg_intensity = &B1111101011111111
Const Reg_shutdown = &B1111110011111111
Config Portc.0 = Output 'Configuración puerto C como salida
Config Portc.1 = Output
Config Portc.2 = Output
Max_data Alias Portc.0
Max_load Alias Portc.1
Max_clock Alias Portc.2
Max_load = 1
Numero = Reg_shutdown
Gosub Sai_max
Numero = Reg_decode_mode
Gosub Sai_max
Numero = Reg_intensity
Gosub Sai_max
Numero = Reg_scan_limit
Gosub Sai_max
Do
Waitms 100
If D1 < 9 And D5 <= 9 Then 'Comienza conteo 0000 - 9999 y 9999 - 0000
Incr D1
Decr D5
Elseif D1 = 9 And D2 < 9 And D5 = 0 And D6 <= 9 Then
Waitms 100
D1 = 0
D5 = 9
Incr D2
Decr D6
Elseif D2 = 9 And D3 < 9 And D6 = 0 And D7 <= 9 Then
Waitms 100
d1 = 0
d2 = 0
d5 = 9
d6 = 9
incr d3
decr d7
Elseif D3 = 9 And D4 < 9 And D7 = 0 And D8 <= 9 Then
Waitms 100
D1 = 0
D2 = 0
D3 = 0
D5 = 9
D6 = 9
D7 = 9
Incr D4
Decr D8
Elseif D5 > 0 Then
Decr D5
endif 'Finaliza conteo 0000 - 9999 y 9999 - 0000
Digitos(8) = d8
Digitos(7) = d7
Digitos(6) = d6
Digitos(5) = d5
Digitos(4) = d4
Digitos(3) = d3
Digitos(2) = d2
Digitos(1) = d1
Gosub Mostrar
Wait 1
Loop
Mostrar:
Numero = 0
For I = 8 To 1 Step -1
Numero = Digitos(i)
Select Case I
Case 1
Numero = Numero Or &B1111100000000000
Case 2
Numero = Numero Or &B1111011100000000
Case 3
Numero = Numero Or &B1111011000000000
Case 4
Numero = Numero Or &B1111010100000000
Case 5
Numero = Numero Or &B1111010000000000
Case 6
Numero = Numero Or &B1111001100000000
Case 7
Numero = Numero Or &B1111001000000000
Case 8
Numero = Numero Or &B1111000100000000
End Select
Gosub Sai_max
Next I
Return
Sai_max:
Max_data = 0
Max_clock = 0
Max_load = 0
Shiftout Max_data , Max_clock , Numero , 1
Max_load = 1
Return
End
Posted by xXThiagox3dDXx: Tue. May 3, 2022 - 06:03 AM(Reply to #80)
1
2
3
4
5
Total votes: 0
now we are thinking how to do two buttons, when you press one one clock will start and the other will stop, and the other do the same
example, the two counters are stoped, when i push the button of the rigth the counter in the left will start, then when i push the left button the left counter stops and then the rigth counter starts, any ideas
$crystal = 8000000
$regfile = "m328Pdef.dat"
$hwstack = 40
$swstack = 32
$framesize = 52
Dim Digitos(8) As Byte 'A variable array with 8 byte type elements is dimensioned
Dim Numero As Word
Dim I As Byte
Dim D1 As Byte
Dim D2 As Byte
Dim D3 As Byte
Dim D4 As Byte
Dim D5 As Byte
Dim D6 As Byte
Dim D7 As Byte
Dim D8 As Byte 'dimension variable byte for the value of each digit
D1 = 0
D2 = 0
D3 = 0
D4 = 0
D5 = 9
D6 = 9
D7 = 9
D8 = 9
Const Reg_decode_mode = &B1111100111111111
Const Reg_scan_limit = &B1111101111111111
Const Reg_intensity = &B1111101011111111
Const Reg_shutdown = &B1111110011111111
Config Portc.0 = Output 'Configuration port C as output
Config Portc.1 = Output
Config Portc.2 = Output
Max_data Alias Portc.0
Max_load Alias Portc.1
Max_clock Alias Portc.2
Max_load = 1
Numero = Reg_shutdown
Gosub Sai_max
Numero = Reg_decode_mode
Gosub Sai_max
Numero = Reg_intensity
Gosub Sai_max
Numero = Reg_scan_limit
Gosub Sai_max
Do
Waitms 100
If D1 < 9 And D5 <= 9 Then 'Start counting 0000 - 9999 and 9999 - 0000
Incr D1
Decr D5
Elseif D1 = 9 And D2 < 9 And D5 = 0 And D6 <= 9 Then
Waitms 100
D1 = 0
D5 = 9
Incr D2
Decr D6
Elseif D2 = 9 And D3 < 9 And D6 = 0 And D7 <= 9 Then
Waitms 100
D1 = 0
D2 = 0
D5 = 9
D6 = 9
Incr D3
Decr D7
Elseif D3 = 9 And D4 < 9 And D7 = 0 And D8 <= 9 Then
Waitms 100
D1 = 0
D2 = 0
D3 = 0
D5 = 9
D6 = 9
D7 = 9
Incr D4
Decr D8
Elseif D5 > 0 Then
Decr D5
End If 'End count 0000 - 9999 and 9999 - 0000
Digitos(8) = D8
Digitos(7) = D7
Digitos(6) = D6
Digitos(5) = D5
Digitos(4) = D4
Digitos(3) = D3
Digitos(2) = D2
Digitos(1) = D1
Gosub Mostrar
Wait 1
Loop
Mostrar:
Numero = 0
For I = 8 To 1 Step -1
Numero = Digitos(i)
Select Case I
Case 1
Numero = Numero Or &B1111100000000000
Case 2
Numero = Numero Or &B1111011100000000
Case 3
Numero = Numero Or &B1111011000000000
Case 4
Numero = Numero Or &B1111010100000000
Case 5
Numero = Numero Or &B1111010000000000
Case 6
Numero = Numero Or &B1111001100000000
Case 7
Numero = Numero Or &B1111001000000000
Case 8
Numero = Numero Or &B1111000100000000
End Select
Gosub Sai_max
Next I
Return
Sai_max:
Max_data = 0
Max_clock = 0
Max_load = 0
Shiftout Max_data , Max_clock , Numero , 1
Max_load = 1
Return
End
now the coments are in english so you can understand it, the part select case and everything whit b000001111 etc, just ingor it is for the max7219 work
Posted by aphawk: Wed. May 4, 2022 - 02:36 AM(Reply to #82)
1
2
3
4
5
Total votes: 0
My suggestion :
You have two powerful interrupts : INT0 and INT1, attach a button on each pin to ground, and use interrupts to detect the press, and set/reset flags to be read in the main program.
Bascom have all high level instructions to make this easy.
now we are thinking how to do two buttons, when you press one one clock will start and the other will stop, and the other do the same
example, the two counters are stoped, when i push the button of the rigth the counter in the left will start, then when i push the left button the left counter stops and then the rigth counter starts, any ideas
Google Set/Reset flip flop or latch, and duplicate the operation in software. If you need Stop(preset)/DownL/DownR, you will need 2 boolean variables.
With just 2 alternating states, you do not need to do complex debounce, but you may want to think about other operations like Pause and reset time or set time - what does your tutor say about those functions ?
Posted by xXThiagox3dDXx: Wed. May 4, 2022 - 07:02 AM(Reply to #83)
1
2
3
4
5
Total votes: 0
exactly what do you mean, I mean I declare 2 pin variables for the buttons, example config pinb.o = input So I have to put interrupts? I googled INT0 and INT1 and the bascom page came out but I didn't understand very well how they work, and what are the set reset flags?
You have two powerful interrupts : INT0 and INT1, attach a button on each pin to ground, and use interrupts to detect the press, and set/reset flags to be read in the main program.
Usual advice is NOT to attach buttons to external (INT0/INT1) interrupts as button contacts bounce and you will get multiple interrupts in a short burst for single make/break.
Two solutions - if you are going to use INT0/INT1 then employ a few external (RC) components on the buttons to do debounce in hardware OR just poll the state of the buttons in a a timer interrupt - only consider the button settled into a fixed state when it has been seen in the same state for several consecutive interrupts.
(even if you don't use interrupts you will have to be thinking about bounce!)
There's a product out there (well, was, it has been superseded) that contained no less than 30,000 lines of my finest AVR assembler code, and not a single interrupt handler. I made the decision very early on that because an awful lot of the interfaces were time-sensitive, that there wouldn't be any interrupts, ever.
I'm not entirely sure that was the correct decision. Still, it did lend to a great deal of predictability - if not simplicity. S.
Ross McKenzie, Melbourne Australia
- Log in or register to post comments
TopOh dear. This is worrying.
Although the code in that linked example leaves room for improvement (no segment definitions and mixed Capitalised / lowercase variable names) it's fine as a demo.
However; you really should have been able to fix that trivial error. You dismiss the code far too quickly in search of another example.
- Log in or register to post comments
TopShouldn't that NEXT statement below the error line be:
NEXT Digit8
Jim
FF = PI > S.E.T
- Log in or register to post comments
Topim new, im putting my best in this sorry if i couldnt see where the problem is, i will review the code again and look if i can solve it
- Log in or register to post comments
TopRunning the AtMega328 at 16MHz, what is common on the small nano and mini Arduino board ($6 at AliExpress), just set the fuses to not divide clock/8. You can run TimerCounter1 in compare mode (interrupt when reaching 62500), at full clock, the interrupt will happens 256 times per second. In the interrupt routine just decrement a counter from $00 and see it if reaches $00 again, means exactly 1 second. When this happens, just verify which button is pressed and increment the seconds counter for that button. If the seconds reach 60, zero it and increase minutes. Send the counters numbers to the display. Use a Max7219 to make it easier to light the 7 segments display. Reset the counters to zero on power on. If you know assembly language, all of this can be done and tested in 30 minutes.
Wagner Lipnharski
Orlando Florida USA
- Log in or register to post comments
TopThe main post was edited to show the most current of the project, and to make it easier and easier to access information
- Log in or register to post comments
TopYou seem to be missing some important steps in your design process.
You have made the classic mistake of diving in and writing code without giving any thought to actually designing the code. Where are your flowcharts or similar? Where are your snippets (small pieces) of test code?
It's a good job I don't teach as I'd fail anyone who only presented working code.
#1 Hardware Problem? https://www.avrfreaks.net/forum/...
#2 Hardware Problem? Read AVR042.
#3 All grounds are not created equal
#4 Have you proved your chip is running at xxMHz?
#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."
- Log in or register to post comments
TopI don't know Bascom but it might be an idea to see if the editor has a way to show line numbers. However in:
It is pretty evident that the line in red must be line 167 which is the line to which all four listed errors refer. So just red what it is telling you about that line:
"wrong data type"
"unknown variable"
"variable not dimensioned"
(ignore the last about "NEXT expected" - that is just a consequence of the first three errors).
Those errors are all talking about "Digit8". It's maybe not surprising as it's the only thing really mentioned on line 167 apart from standard BASIC keywords like "FOR" and "TO".
Again I don't know Bascom but it did not take me long to find:
https://avrhelp.mcselec.com/lang...
On that page you will read:
This is not unlike the C programming language too; before a variable can be used it must be declared in some way so that the language knows what type it is, how much storage to set aside for it and how how to treat it in subsequent operations. Adding "+ 1" to a "byte" or "integer" is going to be quite different to performing "+ 1" in a string for example!
So clearly
needs to be:
Sub Buff_out(byval Disno As Byte) Dim Digit8 As Byte For Digit8 = 1 To 8 Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno) Next End Sub
However, even before that is added perhaps alarm bells should have been ringing as there are clues here that this is NOT very well written code. A good programmer will use indentation to show the flow of execution. The fact that all the lines are left aligned suggests someone is sloppy and not putting much effort into the code so I would be suspicious of the code anyway. It probably should look more like:
By the way, earlier in the code you will see an example:
What this shows you is that there is an alternative to "Dim" which is "Local". Again, you would need to read more of that manual I just linked to but I imagine (a bit like local variables in C) that using "Local" instead of "Dim" just makes a more efficient (possibly!), more isolated/localised variable and is probably preferable to "Dim" which is more likely used for "global" variables. So the sub routine might be better as:
Sub Buff_out(byval Disno As Byte) Local Digit8 As Byte For Digit8 = 1 To 8 Call Displ_write(digit8 , Seg_buff(disno , Digit8) , Disno) Next End Sub
The fact that someone posted that code to a message board without having actually compiled/tested it (or they would have seen the same error you did) is, again, not a great sign.
- Log in or register to post comments
TopOne more little detail: If you're actually trying to build a chess clock, spend some money and get good and durable pushbuttons. If you use the cheapest electronic junk buttons, your chess players will want to strangle you.
Get good buttons. S.
- Log in or register to post comments
TopRoss McKenzie, Melbourne Australia
- Log in or register to post comments
Tophey actually before doing some flowcharts and doing things like that i just wanted to ensure miself that i can show numbers in 2 screens, so i can actually see if it possible to do. just that
- Log in or register to post comments
Topthat is actually a good idea im not pretty sure how many time a player push a button but if they are cheap they probably are gonna break easy
- Log in or register to post comments
Topour teacher ask us every monday what can promise to him and he ussualy give a instruction, for this week the idea is to show 4 numbers in each screen using the max7219
- Log in or register to post comments
Tophey man your pdf been really usefull, but i dont quite understand how the tabelas work for the max 7219 and how i program it you can explain me that?
- Log in or register to post comments
TopNo, you do not need 16M on device powered by an accu. You need not 16M or 8M xtall at all.
But, you need 32kHz crystal, see in my #4. It will be connected instead of this 16M crystal, and then you will get 1s source for timer.
If MAX displays are used, a system frequency can be 4M or perhaps 1M (I have timers with blue MAX and this frequency). Definitely not 16M.
- Log in or register to post comments
TopOr perhaps use those huge red emergency stop buttons. They also have to be able to take a pounding because of their function, and would be easy to hit.
Wayne
East London
South Africa
- Log in or register to post comments
Top...a wooden swing, two small magnets and two reed-relays. Will last forever, and btw. a swing position is visible.
- Log in or register to post comments
TopThe picture (the smaller of the two images) of a Luxury Chess Clock I posted back in #34 has a giant rocker switch. Very visible as to whose turn it is.
- Log in or register to post comments
TopThat are the micro you use for multiplexing? Are another one that can be usefull?
mobdro
vidmate
- Log in or register to post comments
TopIt is a heritage from analogue clock times, such switch is still welcome today.
- Log in or register to post comments
TopI put the program reduced to only show the 4 digits in your other post about ATMEGA328 and MAX7219. See the two examples I put in the program.
Is very ease now, you only need to put the 4 numbers in the array Digitos(), and call a subroutine. I don't believe that you don't have success modifying my small code....
My friend, Bascom is very easy to use and understand, you only must dedicate a small time to use it.
I have programs in comercial products that almost completes the 32K of Program Area of Atmega328, mixed with a lot of Assembly code, all works very well for some years.
Make a good decision to you : study more and practice more !
Paulo
- Log in or register to post comments
Topacct we already make the multiplexing and make the two screens work, the code is here
now we are doing a counter from 0 to 9999 and one from 9999 to 0000, to ha testing in the screens, we have a working code for the 2 screens, sugest on how to do the code
Attachment(s):
- Log in or register to post comments
TopWhat you don't have is any comments !!
No one here knows your code so we can only guess at what those fixed numbers like:
might be used for? A comment explaining what's going on will be helpful for people like us to understand what your program is doing.
Now you may not think this matters but when you (or your code maintainer!) come back to this in 18 months some help to understand what was in the author's mind at the time it was written will be VERY helpful!
- Log in or register to post comments
TopHi,
The basic code was described in my tutorial about Multiplexing, to help people with little knowledge about Led displays and matrices.
In the text, I explained the use of the values sent to Max7219.
Sorry about my fault in make better documentation directly in code.
Paulo
- Log in or register to post comments
TopGood to see that you are making progress !
Congratulations !
Paulo
- Log in or register to post comments
Tophello, basically that code puts the screens to work through the max 7219, the parts that put b111000 etc, are the configuration of the max, these are made up of 16 digits and based on what you put in some specific digits indicated in the datasheet, you can configure the lighting, the number of digits to read, etc. the pdf that explains the work is in spanish, but anyonbe can translate whit some search in google
Attachment(s):
- Log in or register to post comments
Tophello, query, I want to implement a counter from 0 to 9999 in my program, the problem is that the screen is separated by digits, that is digit 1 = 0 digit 2 = 0 digit 3 = 0 digit 4 = 0 I mean I can't just put a variable that replaces the digit and add one to it, I have to increase each number up to nine, return it to 0 and so on to count up to 9999, I came up with a mean bad idea that nothing else allows me to count up to 10 by which then starts to count wrong, any idea how to do it?
- Log in or register to post comments
Topthat post say you have working code ?
but then this post suggest you have problems ?
Usually for clocks as counters, the simplest is to allocate a BYTE sized variable per digit, and to manage the increment and decrement with overflows in SW.
The overflow varies, depending on which digit it is.
Along the lines of
If you display HH:MM lets call that Hh:Mm to give each a unique letter.
m increments 0..9 and when = 10, replace with 0 and increment M.
When M increments to 6, replace it with 0 and increment h (thus highest could is 59 -> 00)
When h increments = 10, replace with 0 and increment H. (24 hr clock)
When H,h is 2,4 replace with 0,0 (thus highest is 23:59) for a 24 hour clock.
You then directly display HhMm on the LEDs
- Log in or register to post comments
Tophey we already maked the 2 counters, ill show the code working, the coments are in spanish sorry.. you can translate them whit google
- Log in or register to post comments
TopSee if this might help you.
Happy Trails,
Mike
JaxCoder.com
- Log in or register to post comments
Topnow we are thinking how to do two buttons, when you press one one clock will start and the other will stop, and the other do the same
example, the two counters are stoped, when i push the button of the rigth the counter in the left will start, then when i push the left button the left counter stops and then the rigth counter starts, any ideas
now the coments are in english so you can understand it, the part select case and everything whit b000001111 etc, just ingor it is for the max7219 work
- Log in or register to post comments
TopMy suggestion :
You have two powerful interrupts : INT0 and INT1, attach a button on each pin to ground, and use interrupts to detect the press, and set/reset flags to be read in the main program.
Bascom have all high level instructions to make this easy.
Paulo
- Log in or register to post comments
TopGoogle Set/Reset flip flop or latch, and duplicate the operation in software. If you need Stop(preset)/DownL/DownR, you will need 2 boolean variables.
With just 2 alternating states, you do not need to do complex debounce, but you may want to think about other operations like Pause and reset time or set time - what does your tutor say about those functions ?
- Log in or register to post comments
Topexactly what do you mean, I mean I declare 2 pin variables for the buttons, example config pinb.o = input So I have to put interrupts? I googled INT0 and INT1 and the bascom page came out but I didn't understand very well how they work, and what are the set reset flags?
- Log in or register to post comments
TopTwo solutions - if you are going to use INT0/INT1 then employ a few external (RC) components on the buttons to do debounce in hardware OR just poll the state of the buttons in a a timer interrupt - only consider the button settled into a fixed state when it has been seen in the same state for several consecutive interrupts.
(even if you don't use interrupts you will have to be thinking about bounce!)
- Log in or register to post comments
TopStart with a state diagram. You should control which button is pressed first, the cases of the second button is pressed during first one is active...
Go on, and forget the interrupt, check the button state each 5-10 ms.
- Log in or register to post comments
TopWe talked about Rocker Switches previously. Have you decided on latching or non-latching button/switch. A DPST toggle switch may work nicely.
Either way, you DON'T want interrupts.
- Log in or register to post comments
TopThere's a product out there (well, was, it has been superseded) that contained no less than 30,000 lines of my finest AVR assembler code, and not a single interrupt handler. I made the decision very early on that because an awful lot of the interfaces were time-sensitive, that there wouldn't be any interrupts, ever.
I'm not entirely sure that was the correct decision. Still, it did lend to a great deal of predictability - if not simplicity. S.
- Log in or register to post comments
TopPages