controlling a lamp/LED matrix

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

sptcarl
Flowcode V4 User
Posts: 34
Joined: Thu Feb 18, 2010 10:53 am
Has thanked: 3 times
Contact:

controlling a lamp/LED matrix

Postby sptcarl » Thu Feb 18, 2010 12:17 pm

I've been playing around with Flowcode for a year or so now, and have sucessfully created a few basic but fully working programs which are in everyaday use.
For my latest project I wish to be able to control 64 lamps (or LEDS), which will light individualy or in a group depending on a vairable read into a PIC.
I'm planning on using a multiplexing method to drive a matrix of 8 by 8 lamps. I've done this in the past using EPROMS, decade and binary counters, but now feel it's time to upgrade to a PIC. (PIC16F877A)
I just cannot get my head around where to start with this. I keep thinking that I need to modify the 4 x led display macro, but surely there must be an easier way than this.
Any help, pointers and suggestions will be gratefully received.

Thanks,
Carl.

User avatar
Benj
Matrix Staff
Posts: 14329
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4415 times
Been thanked: 4131 times
Contact:

Re: controlling a lamp/LED matrix

Postby Benj » Thu Feb 18, 2010 2:04 pm

Hello Carl

This is a good schematic for creating a 8 x 8 array of 64 LEDs. You can control the entire thing using an 8-bit port and 2 additional clock lines.

http://www.m108.com/document-pool/forum ... 2schem.gif

I have created this circuit and it works great. I have not created a Flowcode component but I think it would be very simple to create macros that automatically output from an array of 8 bytes based on a timer interrupt interval etc. Then all you have to do is update the array and the display automatically refreshes itself.

sptcarl
Flowcode V4 User
Posts: 34
Joined: Thu Feb 18, 2010 10:53 am
Has thanked: 3 times
Contact:

Re: controlling a lamp/LED matrix

Postby sptcarl » Sun Feb 21, 2010 9:22 pm

thanks for that Ben, I never thought of using latches to reduce the number of output pins, my idea was just to have a port for rows and a port for columns, or drive the rows from an external clock and counter with 3 binary bits back into the PIC to sync the data.
Unfortunately though, my mind is still blank and I cannot get my head around where to start with the flowcode side of things!

User avatar
Benj
Matrix Staff
Posts: 14329
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4415 times
Been thanked: 4131 times
Contact:

Re: controlling a lamp/LED matrix

Postby Benj » Mon Feb 22, 2010 3:13 pm

Hello

I would start with the data array. Eg a string or array of 8 bytes.

Once you have this then you can create a program to output the data to the LEDs eg a row at a time.

Once you have that then you can move the output function to an interrupt or call repeatedly in your program.

To then draw onto the display you simply update the values in the data array and the display automatically refreshes itself.

Eg you can have functions to draw a line or a character etc to the data array and this will in turn be updated by your interrupt function.

sptcarl
Flowcode V4 User
Posts: 34
Joined: Thu Feb 18, 2010 10:53 am
Has thanked: 3 times
Contact:

Re: controlling a lamp/LED matrix

Postby sptcarl » Wed Feb 24, 2010 3:10 pm

Thanks for your time Ben.

I think I'm getting it now, I'm fairly confident with the interrupt routine that refreshes the outputs as per the circuit diagram in Bens post above.

I'm not too sure about the data array though, it's not something that I've used before, and I'm not even totally convinced that it's what I need here. I could see this working if a certain pattern of lights was called for depending on a few inputs, but thats not what I want...

The device that this PIC will eventually connect to, outputs a binary count (0-60), and depending on the count number, the corresponding lamp number will iluminate.

I have attached my project as it stands so far. As you can see I have used a load of descision boxes (eventually there would be 60), this is the only way I can imagine it working, but surely there must be a better, more simplified way?

Thanks again,
Carl.
Attachments
matrix.fcf
(18.97 KiB) Downloaded 462 times

User avatar
Benj
Matrix Staff
Posts: 14329
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4415 times
Been thanked: 4131 times
Contact:

Re: controlling a lamp/LED matrix

Postby Benj » Thu Feb 25, 2010 10:00 am

Hello Carl

I have had a little play with the file and this should now work correctly without needing to have the 60 decision icons.
Attachments
matrix.fcf
(15 KiB) Downloaded 447 times

User avatar
Benj
Matrix Staff
Posts: 14329
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4415 times
Been thanked: 4131 times
Contact:

Re: controlling a lamp/LED matrix

Postby Benj » Thu Feb 25, 2010 10:06 am

Looking at the properties of your timer interrupt it is probably worth reducing the prescaler to maybe 1:32 or 1:64. 1:1 will be too fast and will probably lead to problems as you have delays in your interrupt.

You will also need to switch the timer clock source to Internal Clock (CLKO) to allow this to work on the hardware.

To get around the delays in your interrupt (if they become a problem) you could double the count value and if the count is even i.e.

even = count MOD 2

then output the column and if the count is odd then output the row.

sptcarl
Flowcode V4 User
Posts: 34
Joined: Thu Feb 18, 2010 10:53 am
Has thanked: 3 times
Contact:

Re: controlling a lamp/LED matrix

Postby sptcarl » Thu Feb 25, 2010 10:45 pm

Thanks again Ben,
I will have to sit and study your alterations now and work out whats going on. I would have never been able to come up with anything like that!

I had forgotten about the prescaler value, I set it as that to make watching the simulation easier.

Well I guess I need to work on the hardware now, I shall return when it is working (or not!)

Carl.