Tutorial 7 - All the info you need is right here!

Post here to discuss the PIC microcontroller tutorials.

Moderators: Chuckt, Garth, bitfogav

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Tutorial 7 - All the info you need is right here!

Post by bitfogav » Thu May 17, 2012 4:21 am

Yes Basically, I think the only difference is that the Great Race uses the Green Leds and the Santa's Scramble uses the Red Leds. This is achieved by just swapping the matrix connections from the 7442 pins, from Green leds to Red leds.

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

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm

Re: Tutorial 7 - All the info you need is right here!

Post by brad » Sat May 19, 2012 1:37 pm

That's right bitfogav!

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am

Re: Tutorial 7 - All the info you need is right here!

Post by nodoubtman » Tue May 22, 2012 11:49 pm

brad wrote:That's right bitfogav!
but Brad! The great race use red dot as well?
the schematic of brad smile is the same as great race?

thanks!
marC:)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Tutorial 7 - All the info you need is right here!

Post by bitfogav » Wed May 23, 2012 4:35 am

The Great Race actually has the bottom Row of RED leds connected to the Microcontroller pin, you dont need to connect this on the Santa's Scramble..

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Tutorial 7 - All the info you need is right here!

Post by Mike M » Fri Jan 04, 2013 9:17 pm

io. wrote:
brad 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.
Thanks a lot, I think I have understood the theory. I'm gonna do some reading about the subject :)

I'm about to buy some Motorola MC74F374N, they seem to do the same as 373.
Sorry for a late reply to an old post...

I'm not sure the Motorola MC74F374N is a good choice as the output current specs' seem a bit low, however, there may be advantages using a 74HC374 over a 74HC373. Both parts have the same output current specs and the same pinout but the '374 is an edge triggered D flip-flop. This means that while you can use the '374 in a circuit the same way Brad uses the '373 in his 8x8 Game System, you can also cascade multiple '374 ICs by driving all the CLK and /OE pins together and by connecting the outputs of leading ICs to the inputs of following ICs. The modified 8x8 Game System schematic below shows three 74HC374 ICs in cascade configuration. Now the neat part about this configuration, besides freeing up four I/O pins, is that writing 24 bits of output data to the '374 cascade simply involves clocking three bytes onto the bus. As each byte is written onto the bus it ripples down the cascade. In this case, you must send the Green byte first, followed by the Column byte, followed by the Red byte. I believe the process is simpler and faster than the one described by Brad for the '373 and should result in smaller more efficient code. For example, the code snippets below from the "Invaders" program, which have been modified for the 74HC374 cascade, are nearly 40% smaller than the original code they replace.

Food for thought. Cheerful regards, Mike

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
Attachments
8x8_game_system_schematic (small).png
8x8_game_system_schematic (small).png (150.66 KiB) Viewed 10319 times
Last edited by Mike M on Sat Jan 05, 2013 3:18 am, edited 1 time in total.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm

Re: Tutorial 7 - All the info you need is right here!

Post by brad » Fri Jan 04, 2013 9:43 pm

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. And you are correct - it saves a whole heap of I/O pins and streamlines your code :)

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Tutorial 7 - All the info you need is right here!

Post by Mike M » Sat Jan 05, 2013 3:38 am

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.
Cool. What displays, if you don't mind me asking?
And you are correct - it saves a whole heap of I/O pins and streamlines your code :)
That's not all. If you check out the footprint for the 74HC574 you'll think you went to PCB layout heaven (lol)...

Hey, I noticed that no one posted code for your homework assignments. Would you mind if I gave it a try? I'm certainly not an "expert" but I do have several years experience (assembler, BASIC, and C) and maybe someone would enjoy looking at and comparing examples. To be honest, I can't imagine where to begin your HW#2 assignment, but like any good puzzle, I'm sure it would be fun (lol).

BTW, I think this tutorial is fantastic and incredibly well done. I wish I could express myself as well as you. Do you think there would be any interest in supplementing the tutorial with a discussion about current limiting resistors, the 7442 "fanout" and how it effects brightness when lighting multiple LEDs in any particular column, and using transistor or MOSFET column drivers, or, is that beyond the scope of this tutorial?

Happy new year and cheerful regards, Mike

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm

Re: Tutorial 7 - All the info you need is right here!

Post by brad » Sat Jan 05, 2013 9:24 pm

I have been using a number of different displays that I bought from aliexpress.com -

check these out :)

http://www.aliexpress.com/item/P10-full ... 0749.html
and

http://www.aliexpress.com/item/Free-Shi ... 87040.html

It looks as though the tutorial has had thousands of hits - but no homework submissions, I guess people just don't like homework :)

As for the additional info - especially about using a bjt or fet, I think that's a great idea and it shows people how you can go through the various stages of circuit design to improve on performance and weed out hardware errors.

Happy New Year!

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Tutorial 7 - All the info you need is right here!

Post by Mike M » Sun Jan 06, 2013 3:15 am

Hey Brad, thanks for the links, but I didn't see any schematics that show the mux' method...

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm

Re: Tutorial 7 - All the info you need is right here!

Post by brad » Sun Jan 06, 2013 6:57 pm

Mike M wrote:Hey Brad, thanks for the links, but I didn't see any schematics that show the mux' method...
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 microcontroller :)

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests