Heres a quote from Brads Project page:
The game is called “Santa’s Scramble” and it is effectively just The Great Race but renamed to suit the season
Moderators: Chuckt, Garth, bitfogav
The game is called “Santa’s Scramble” and it is effectively just The Great Race but renamed to suit the season
but Brad! The great race use red dot as well?brad wrote:That's right bitfogav!
Sorry for a late reply to an old post...io. wrote:Thanks a lot, I think I have understood the theory. I'm gonna do some reading about the subjectbrad wrote:What you need is a way to expand your output ports.
The best way to do this (in my experience) is to get some 74373 chips.
They are 8-bit data latches with tri-state outputs.
What you can do with these is get three of them. connect the eight inputs of each one to PORTB of your microcontroller (so they all have exactly the same inputs)
Then connect the eight outputs of each chip to your eight red cathodes, your eight green cathodes and then your eight anodes. (one chip for each section)
Then, connect the latch enable pin of each chip to one of the pins on PORTA. So you could connect the latch enable of the red 74373 to PORTA pin 0, then green latch enable to PORTA pin 1 and then the anode latch enable to PORTA pin 2.
Then lastly, the 74373 chips have an output enable pin (because they have tri-state outputs) so you need to connect all three output enable pins of the three chips together, and then to PORTA pin 3.
So, to draw an image you need to send out three bytes of data (one for the red cathodes, one for green and one for the anodes. First send the red byte to PORTB, then enable the red 74373 latch by making PORTA pin 0 a logic 1, then 0 again. Then send the green byte to PORTB and then enable the latch by sending a logic 1 to PORTA pin 1, then make it a zero again. lastly - send out your anode data to PORTB and then send a logic 1 to PORTA pin 2 to enable the anode latch, then make it a logic 0 again.
Now we have three chips, each with their required data. We then make PORTA pin 3 (the output enable connection) a logic 0 (we need it to be a 0 because it has an inverted input at the 74373 for this connection)
This will allow all the data present in the 74373 chips to go out and be displayed on the LED matrix.
Have a look at the 8x8 game system page for full details and a schematic of how I made it all work.
I'm about to buy some Motorola MC74F374N, they seem to do the same as 373.
Code: Select all
;******************************************************************
; 8x8 Game System "Invaders" draw routines for 374/574 hardware *
;******************************************************************
ship
btfsc stop_repeat,1 ; |B0
call button_time ; |B0
call joystick ; check joystick |B0
movlw 0 ; |B0
call latch ; GRN = 0 (off) |B0
movf ship_data,W ; |B0
call latch ; COL = ship_data |B0
movlw b'00000001' ; |B0
call latch ; RED = 00000001 (bottom row) |B0
goto display ; |B0
;******************************************************************
;
draw_UFO
btfss do_UFO,0 ; ??? |B0
return ; |B0
movlw 0 ; |B0
call latch ; GRN = 0 (off) |B0
movf UFO,W ; |B0
call latch ; COL = UFO |B0
movlw b'10000000' ; |B0
call latch ; RED = 10000000 (top row) |B0
call display ; |B0
decfsz UFO_speed,F ; move ufo? yes, skip, else |B0
return ; branch (done) |B0
movlw d'30' ; |B0
movwf UFO_speed ; reset 'ufo move' timer |B0
rrf UFO,W ; rotate UFO left |B0
rrf UFO,F ; pseudo 'rrncf' (uses carry) |B0
skpnc ; full cycle? no, skip, else |B0
bcf do_UFO,0 ; flag a full UFO cycle |B0
return ; branch (done) |B0
;******************************************************************
;
shields
movlw b'00000010' ; |B0
call latch ; GRN = 00000010 (shields row) |B0
movf shield,W ; |B0
call latch ; COL = shield |B0
movlw 0 ; |B0
call latch ; RED = 0 (off) |B0
goto display ; |B0
;******************************************************************
; draw alien rows: top = red, middle = green, bottom = yellow
;
draw_aliens
movlw 0 ; |B0
call latch ; GRN = 0 (off) |B0
movf top_alien_dat,W ; |B0
call latch ; COL = top_alien_dat |B0
movf top_alien_row,W ; |B0
call latch ; RED = top_alien_row |B0
call display ; |B0
movf mid_alien_row,W ; |B0
call latch ; GRN = mid_alien_row |B0
movf mid_alien_dat,W ; |B0
call latch ; COL = mid_alien_dat |B0
movlw 0 ; |B0
call latch ; RED = 0 (off) |B0
call display ; |B0
movf bot_alien_row,W ; |B0
call latch ; GRN = bot_alien_row |B0
movf bot_alien_dat,W ; |B0
call latch ; COL = bot_alien_dat |B0
movf bot_alien_row,W ; |B0
call latch ; RED = bot_alien_row |B0
goto display ; |B0
Code: Select all
;******************************************************************
; 8x8 Game System 74HC374/574 Hardware Support Subroutines *
;******************************************************************
latch
movwf PORTB ; place WREG data onto data bus |B0
bsf PORTA,0 ; CLK = 1 (latch cascaded data) |B0
bcf PORTA,0 ; CLK = 0 " |B0
return ; |B0
display
bcf PORTA,1 ; /OE = 0 (display on) |B0
call delay ; display 'on' time |B0
bsf PORTA,1 ; /OE = 1 (display off) |B0
return ; |B0
Cool. What displays, if you don't mind me asking?brad wrote:You're certainly on to a good thing there Mike - I have noticed that this is the way that the LED displays that I buy have been running the show.
That's not all. If you check out the footprint for the 74HC574 you'll think you went to PCB layout heaven (lol)...And you are correct - it saves a whole heap of I/O pins and streamlines your code
Ah yes, that's because they want you to buy their driver boards - I could not find any info of how these displays work but after some trial and error I finally got them going with just a simple 18f25k20 microcontrollerMike M wrote:Hey Brad, thanks for the links, but I didn't see any schematics that show the mux' method...
Users browsing this forum: No registered users and 4 guests