Developing API for LED matrix with arbitrary pin mapping

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
shubhamgandhi
Posts: 17
Joined: 12 Mar 2012 02:23

Developing API for LED matrix with arbitrary pin mapping

#1 Post by shubhamgandhi » 18 Jun 2012 22:33

I made an LED matrix of size 18x7 controlled by a pic16f887. Columns are positive, rows are negative and pin mappings are as follows:
18 rows in this order: PORTB7-0, PORTD7-4, PORTC7-4, PORTD3-2
7 columns in this order: PORTA0-5, PORTE0
This was the most convenient set up since I did it on on a perf board.

I want to develop an API in MikroC where I want it to display letters/characters (I will try to implement marquee scrolling once I get this working).

Please help me get started! Any pointers/tips/hints are appreciated.
Thanks

jtemples
Posts: 258
Joined: 22 Jan 2012 05:46

Re: Developing API for LED matrix with arbitrary pin mapping

#2 Post by jtemples » 18 Jun 2012 23:15

Some quick suggestions:

1) make sure that you have done enough analysis to prove out to your satisfaction that your design can actually work;
2) make sure that those pins can sink/source current as designed;
3) make sure that those pins can be output;
...

After that, think about how you want to organize your data. Having taken a class in Data Structure would be helpful.

I would first write a routine that can display a column / row, and then go from there to write a routine that can display an image (row x column).

Good luck.

shubhamgandhi
Posts: 17
Joined: 12 Mar 2012 02:23

Re: Developing API for LED matrix with arbitrary pin mapping

#3 Post by shubhamgandhi » 18 Jun 2012 23:30

Thanks for the tips.

I think I have a pretty good design, I have done some research and analysis. The 18 column pins can supply enough current, and the 7 row pins toggle BJTs that sink the current from the columns.

Code-wise, I wrote simple routines to turn on each light and/or all the lights in multiplexed fashion. I just need help understanding at a system level how I can move to the next step of making letters appear.

The following is the schematic:
Image

Thanks

jtemples
Posts: 258
Joined: 22 Jan 2012 05:46

Re: Developing API for LED matrix with arbitrary pin mapping

#4 Post by jtemples » 18 Jun 2012 23:57

Here is what I would do:

1) I would save the spi/i2c pins: so that you retain the flexibility of turning the whole design into a spi/i2c slave and have the master send to the slave display data / commands. or the rx/tx pins for that matter.
2) I would start to write a routine to display 8-bit data: this allows you the flexibility to drive the 18-bit data serially - so you can move the design to a smaller chip with fewer io pins. This approach also has the advantage of having the possibility of putting all 8-bit data on an 8-pin port, speeding up the display.
3) I would consider putting the whole thing in a timer isr, with user specified display interval. so the whole design is "automated", once you have the display buffer filled. You can then process other tasks in the main loop.

The whole logic in the isr is fairly simple:

1) clear the flag; and load the offset if you aren't using an autoreloader;
2) turn off the 8-bit port;
3) advance the 18-bit counter to the next row/column; do a boundary check here;
4) load display data into the 8-bit port;
5) done.

You should have no problem implementing it.

jtemples
Posts: 258
Joined: 22 Jan 2012 05:46

Re: Developing API for LED matrix with arbitrary pin mapping

#5 Post by jtemples » 19 Jun 2012 22:21

I implemented one on 16F684. Total rom space taken is about 100bytes, with the overhead.

Not bad.

Post Reply

Return to “mikroC PRO for PIC General”