Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : LED matrix with CMM, am I going to break the latter?
Page 3 of 3 | |||||
Author | Message | ||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1590 |
All these suggestions are very well and will help to keep the magic smoke inside the Maximite chip but I don't think there can be a universal interface because inputs an outputs can be anywhere. That is they can be adjacent pins and that can make it difficult to use a uni-directional buffer without patching. I remember there was disagreement on which pins should be used for joysticks etc. Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Thanks Mick, that is exactly what I was thinking of. Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Tom. The reason you have so many people helping is because we Australians like to feel superior to poms so we take every opportunity. Sadly, in about a month after this steep learning curve, you will be feeling superior to us. Peter I wouldn't worry about that. Have you see the lying, right-wing populist wankers that we've just elected into what can laughably be called a government? That's revealed pom superiority as the crock of sh*t it always was :-( ... or at least has been since the Victorians ... and then we were just successful, but still not terribly nice. Edited 2020-02-10 18:38 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 639 |
Tom. I was thinking microprocessors not politics. After you have played with this for a few weeks you will be quite at home. Peter |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
I was thinking microprocessors not politics. After you have played with this for a few weeks you will be quite at home. Peter Thanks Peter, and to everyone else who's responded. The matrix is soldered ... and a right rat's nest it is ... so listen out for the boom and the sweet smell of magic smoke ;-) Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Just in case anyone is interested. By putting 1K resistors on the columns/anodes I have successfully (and without any magic smoke) driven my LED panel bareback on the Colour Maximite. The LED's are a little dim and flickery, but it's perfectly serviceable, see video: https://www.youtube.com/watch?v=iwy1vCu-SLg It's still my intention to play about with the various options of transistors, the ICs recommended above and ultimately probably a MAX7219 to increase the brightness and in the latter case reduce the number of I/O pins. But first I'm going to wire up an NES controller and a buzzer to it. Then all I need it a time machine to take me back to the 1970s and I can rake it in from the electronics entertainment market ;-) Edited 2020-02-25 06:40 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Warpspeed Guru Joined: 09/08/2007 Location: AustraliaPosts: 4406 |
Do you remember when RS232 chips were plugged into sockets because people kept blowing them up? What I propose is 3 x 74LVC244 in DIP sockets and 19? 330 ohm resistors all with suitable connectors to be decided. It means the outputs and inputs are on different pins but would that matter? It comes down to how many people are worried about damaging their MM? Peter I use IC sockets for absolutely everything wherever possible. When an experimental board eventually gets rebuilt or trashed, all the ICs can be unplugged and reused. I never solder in any integrated circuits. Much prefer big old through hole components and sockets to surface mount, especially when trying to diagnose and repair faults. A two dollar Chinese PCB then becomes a throw away item if all the ICs and some of the larger parts can be easily removed and reused in the next attempt. Cheers, Tony. |
||||
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 639 |
Tom. You are now hooked. The rest of your life will be a disaster . Tony. My idea for a MAXI MITE prophylactic seems to have fallen on deaf ears. I don't always use sockets because a good socket costs about as much as a cheap IC but I did buy a reasonable desoldering tool and I don't make mistakes anyway Peter |
||||
Warpspeed Guru Joined: 09/08/2007 Location: AustraliaPosts: 4406 |
I believe some kind of protective buffering for an MM is an excellent idea, if regularly playing around with breadboards and prototypes. Far too easy to blow something up and have the destruction travel back and kill something really expensive. Have to agree about the cost of good sockets, but if you buy bulk Chinese its not too bad. Being able to reuse the same chips over and over again in different projects means I can always have a good supply on hand to build just about anything I want at very short notice, without having to order in a whole bunch of new stuff every time. Its really frustrating having to go out in the car for an hour to buy a single two dollar part because I blew up the last one of that type a month ago and forgot to reorder. Just went out to the shed and had a look. I was surprised to find there are about 240 different types of digital and analog ICs here, and typically five to ten of each type. Its a lot, but I have been slowly expanding the range and quantity for about fifty years. Cheers, Tony. |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1590 |
Impressive demo! You have nailed the matrixing, not to mention the scrolling text and the snake game. I'd like to see the code. Maybe you could try the game of Life? It looks like you have resistors in both the columns and the rows. You could do away with one or the other now you know it works, depending on how you are handling the matrixing. Either the row or the column is only supplying one LED - that's where the resistor should be the other will be supplying 0 to 8 LEDs - that's where you could remove the resistor. Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Thanks Bill, The additional resistors on the breadboard are some 470 ohms in series with the 330 ohms built onto the matrix board for a total of 800 ohms (the ~1K) on each column/anode. I'm happy to share the code but give me a week to do some tweaks and cleanup. I also need to make sure I comply with the licensing for the "tom thumb" font it uses. How would you like the code shared? Github or something else? Regards, Tom Edited 2020-02-25 19:57 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1590 |
Sorry Tom, Your arrangement with the resistors is evident when I have another look at the video. And the values are well chosen to keep the current drawn within safe limits (and the smoke in). I was just thinking of you posting the code here in the forum but that's entirely up to you. Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
No worries. Thanks for the double-check Bill Will do, like I say I want to do some tweaking and cleaning and I need to check the licensing requirements of the 3rd party font. Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3831 |
Here's the code, hopefully better late than never: The attached .tar.gz file includes the required font file (CC0 licensed). snake-cmm.zip Dim matrix(7) row = 7 ' The font contains 128 - 21 = 107 glyphs, each taking 3 bytes = 321 bytes ' Each float element of the array is 4 bytes => 81 * 4 = 324 bytes Dim font4x6(80) Dim snake(63) demo = 0 diff = 1 UP = -8 : RIGHT = 1 : DOWN = 8 : LEFT = -1: SELECT = 10 : START = 20 Mode 2, 3 Cls Print "SNAKE - Tom Williams 2020" Print "Cursor keys to move" Print "S to START" Print "D to SELECT difficulty" load_font() matrix_init() SetTick 1, matrix_draw On Key on_key main_loop() End Sub main_loop() Do matrix_clear() game_intro() game_init() game_loop() die() Loop End Sub Sub game_intro() Local s$ s$ = "SNAKE-Press START or SELECT to increase difficulty-Tom Williams 2020" Do If cmd = SELECT Then diff = 1 + diff Mod 4 scroll_text(Str$(diff)) Else scroll_text(s$) If cmd = 0 Then demo = 1 : cmd = START EndIf Loop Until cmd <> 0 And cmd <> SELECT End Sub Sub game_init() Local i For i = 0 To 63: snake(i) = 0 : Next i snake(0) = 35 head = 0 tail = 0 dir = UP pill = 0 score = 0 cmd = 0 matrix_set(snake(head), 1) place_pill() End Sub Sub game_loop() Local p Do Pause (5 - diff) * 50 If cmd <> 0 And cmd < 10 Then dir = cmd : cmd = 0 If demo Then demo_ai() If will_die() Then Exit Sub p = snake(head) + dir head = (head + 1) Mod 64 snake(head) = p matrix_set(p, 1) If p <> pill Then matrix_set(snake(tail), 0) tail = (tail + 1) Mod 64 Else score = score + 1 pill = -5 EndIf If pill = -1 Then place_pill() If pill < -1 Then pill = pill + 1 Loop End Sub Sub demo_ai() Local c, p, r p = snake(head) c = p Mod 8 r = p \ 8 If r = pill \ 8 Then If pill < p Then dir = LEFT If pill > p Then dir = RIGHT ElseIf c = pill Mod 8 Then If pill < p Then dir = UP If pill > p Then dir = DOWN ElseIf pill < p Then dir = UP Else dir = down EndIf If will_die() Then If (r > 3) Then dir = UP Else dir = DOWN If will_die() Then If (c > 3) Then dir = LEFT Else dir = RIGHT If will_die() Then If (r > 3) Then dir = DOWN Else dir = UP If will_die() Then If (c > 3) Then dir = RIGHT Else dir = LEFT End Sub Function will_die() Local p p = snake(head) If dir = UP And p < 8 Then will_die = 1 ElseIf dir = DOWN And p > 55 Then will_die = 1 ElseIf dir = LEFT And p Mod 8 = 0 Then will_die = 1 ElseIf dir = RIGHT And p Mod 8 = 7 Then will_die = 1 ElseIf matrix_get(p + dir) And (p + dir) <> pill Then will_die = 1 EndIf End Function Sub die() Local i, j For i = 1 To 4 matrix_fill() Pause 300 matrix_clear() Pause 300 Next i scroll_text("GAME OVER Score:" + Str$(score)) End Sub Sub place_pill() pill = Int(Rnd() * 64) If matrix_get(pill) = 0 Then matrix_set(pill, 1) Else pill = -1 EndIf End Sub Sub on_key() Local k k = KeyDown If k = &h64 Then cmd = SELECT ElseIf k = &h73 Then cmd = START ElseIf k = &h80 Then cmd = UP ElseIf k = &h81 Then cmd = DOWN ElseIf k = &h82 Then cmd = LEFT ElseIf k = &h83 Then cmd = RIGHT EndIf End Sub Sub matrix_init() Local i For i = 1 To 8 : SetPin i, dout : Next i For i = 11 To 18 : SetPin i, dout : Next i matrix_clear() End Sub Sub matrix_clear() Local i For i = 0 To 7 : matrix(i) = 0 : Next i End Sub Sub matrix_fill() Local i For i = 0 To 7 : matrix(i) = &hFF : Next i End Sub Function matrix_get(p) matrix_get = (matrix(p \ 8) And 2^(p Mod 8)) > 0 End Function Sub matrix_set(p, x) matrix(p \ 8) = matrix(p \ 8) And (&hFF Xor 2^(p Mod 8)) Or x * 2^(p Mod 8) End Sub Sub matrix_left() Local i For i = 0 To 7 : matrix(i) = matrix(i) \ 2 And &hFF : Next i End Sub ' Pins 1-8 source the columns. ' Pins 11-18 sink the rows. Sub matrix_draw() row = (row + 1) Mod 8 Port(1, 8, 11, 8) = &hFF00 Port(1, 8, 11, 8) = matrix(row) Or &hFF00 - 2 ^ (row + 8) End Sub Sub load_font() Local end, height, i, j, s$, start, x, width Open "tt4x6.fnt" For Input As #1 Input #1, height, width, start, end If height <> 6 Then Error If width <> 4 Then Error If start <> 20 Then Error If end <> 126 Then Error For i = 0 To (end - start) ' Iterate over glyphs For j = 0 To 5 Step 2 ' Iterate over rows, 2 at a time x = 0 Line Input #1, s$ If Len(s$) <> width Then Error If Peek(Var s$, 1) > 32 Then x = x Or &b00000001 If Peek(Var s$, 2) > 32 Then x = x Or &b00000010 If Peek(Var s$, 3) > 32 Then x = x Or &b00000100 If Peek(Var s$, 4) > 32 Then x = x Or &b00001000 Line Input #1, s$ If Len(s$) <> width Then Error If Peek(Var s$, 1) > 32 Then x = x Or &b00010000 If Peek(Var s$, 2) > 32 Then x = x Or &b00100000 If Peek(Var s$, 3) > 32 Then x = x Or &b01000000 If Peek(Var s$, 4) > 32 Then x = x Or &b10000000 Poke Var font4x6(0), i * 3 + j \ 2, x Next j Next i Close #1 End Sub Sub scroll_text(s$) Local c, ch, i cmd = 0 For i = 1 To Len(s$) ch = Peek(Var s$, i) For c = 0 To 3 ' Poor man's proportional spacing. If c = 0 And ch = 105 Then c = 1 If c = 2 And ch = 105 Then c = 3 If c = 1 And ch = 32 Then c = 4 blit_font(Peek(Var s$, i), c) Pause 150 matrix_left() Next c If cmd <> 0 Then i = Len(s$) Next i For i = 1 To 7 : Pause 100 : matrix_left() : Next i End Sub ' Copies column 'c' of glyph 'a' to the last column of the matrix. Sub blit_font(a, c) Local x, i, p, s p = 7 s = (a - 20) * 3 For i = s To s + 2 x = Peek(Var font4x6(0), i) p = p + 8 matrix_set(p, (x And 2^c) > 0) p = p + 8 matrix_set(p, (x And 2^(c + 4)) > 0) Next i End Sub Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Page 3 of 3 |
Print this page |