Limpkin's blog - Tag - Matlab
<div>An electronics geek blog, dedicated to sharing and open source. Check out my stores: <a href="https://lectronz.com/stores/stephanelec" hreflang="en" title="Lectronz store">EU</a> / <a href="https://www.tindie.com/stores/stephanelec" hreflang="en" title="tindie store">EU & US</a>.</div>
2024-03-27T19:19:38+00:00
Mathieu
urn:md5:51de6a3d917257edeff5a252fe925b02
Dotclear
RGB led matrices with animated gifs
urn:md5:4660fe52b82b554fb61f7fd5898e52f1
2011-05-12T07:51:00+01:00
2024-03-08T21:07:25+00:00
limpkin
My Projects
avr
fpslic
led matrix
Matlab
matlab program
rgb
usb
<p>Hey guys, I just came back from a trip to China! Not only was it an occasion to visit this vast country but also a good opportunity to go to the numerous <strong>electronics markets</strong> in the cities of Xi'an and Beijing. Yes, even on holidays I'm still into electronics ;-) .<br>
So here are the few interesting things I brought back, and especially what I did with them...<br><br>
<img src="https://www.limpkin.fr/public/RGB_Matrix/.rgb_led_matrix_m.jpg" alt="RGB led matrix" class="media-center" title="RGB led matrix, mai 2011"></p> <p>For people following my blog, no surprises there, led matrices! I was actually surprised to not find any other things that I'd like. The reason for this is that most interesting components (for example the screen of my <a href="https://www.limpkin.fr/index.php?post/2011/01/11/The-Engine-Control-Unit-monitor-project">ECU monitor project</a>) are made by companies that are voluntarly not present in this kind of markets. You'll thus only find common components and of course a lot of leds! Prices are obviously much cheaper than in Europe ;-) . <br></p>
<p><a href="https://www.limpkin.fr/public/RGB_Matrix/IMG_4148.JPG" title="Led matrices from china"><img src="https://www.limpkin.fr/public/RGB_Matrix/.IMG_4148_m.jpg" alt="Led matrices from china" class="media-center" title="Led matrices from china, mai 2011"></a><br>
The matrices I bought were actually quite hard to find (especially the one on the left). From left to right, you'll thus see a <strong>64 * 32 RGB led matrix with a 4mm pitch</strong> (around 160 dollars) and a <strong>32 * 16 RGB led matrix with a 6mm pitch composed of SMD leds</strong> (around 40). If you compare their prices to the individual 8 * 8 elements you can find on <a href="http://www.sparkfun.com/products/683" hreflang="en" title="Sparkfun">Sparkfun</a>, well I would have been stupid by not buying them :-D .<br>
Two different types of led matrices for two very different types of uses: the one made of the 32 <strong>8*8 individual matrices</strong> put together is made for <strong>indoor</strong> use (normal brightness, good opacity, small pitch thus small viewing distance) while the other is meant for <strong>outdoor</strong> use (very high brightness and long viewing distance).<br></p>
<p><a href="https://www.limpkin.fr/public/RGB_Matrix/IMG_4122.JPG" title="Back of the led matrices"><img src="https://www.limpkin.fr/public/RGB_Matrix/.IMG_4122_m.jpg" alt="Back of the led matrices" class="media-center" title="Back of the led matrices, mai 2011"></a><br>
I have to say that the aspect and quality of these led panels seem <strong>very good</strong> when examining them (I still have the cliché that "made in china" = bad quality). Solders and assembly are neat, the seller even provided me with some <strong>magnet feet</strong> allowing me to put the led panels on every metalic surface (ie: my computer!). Very convenient if you don't have much space on your desk. The production date written on the board is end of september 2010 so I am very surprised that it is not possible to find this LED panel on the web.<br>
The main component in charge of controlling any of the (64 * 3 = 192) pixels of one line is the <strong>JXI5020</strong> chip (don't forget that you need to scan the array), which seems to be only used in china as I spent 3 hours to find its datasheet (which is in chinese of course). Look at the bottom of this page to download it. The JXI5020 is basically a 16bits shift register with store and output enable commands, and its outputs are inverted. The specified maximum clock frequency is 25 MHz and thus a maximum theoretical LED panel refresh rate of <strong>24.4KHz</strong>, allowing <strong>8 bits PWM</strong> for 60 FPS (thus 24bits / pixel).<br></p>
<p><a href="https://www.limpkin.fr/public/RGB_Matrix/IMG_4114.JPG" title="FPSLIC control board"><img src="https://www.limpkin.fr/public/RGB_Matrix/.IMG_4114_m.jpg" alt="FPSLIC control board" class="media-center" title="FPSLIC control board, mai 2011"></a><br>
As I wanted to quickly show you these matrices in action, I decided to adapt the wiring of my other FPSLIC based <a href="https://www.limpkin.fr/index.php?post/2010/02/14/The-FPSLIC-bicolor-matrix-project">led matrix control board</a> to make it work with these ones. This is when I was very happy that I applied my rule number one when producing this control board: always make <strong>two boards</strong> when you only need one! As the interface to control the pixels hasn't changed since single color led matrices (only additional contacts for the additional colors), <strong>no need to change my code in depth</strong>.<br></p>
<p><a href="https://www.limpkin.fr/public/RGB_Matrix/fpslic_arch.png" title="FPSLIC Architecture"><img src="https://www.limpkin.fr/public/RGB_Matrix/fpslic_arch.png" alt="FPSLIC Architecture" class="media-center" title="FPSLIC Architecture, mai 2011"></a><br>
<a href="https://www.limpkin.fr/index.php?post/2010/02/14/The-FPSLIC-bicolor-matrix-project">My other led matrix</a> is bi-color, composed of 3 64*32 led panels as well. As there is one additional color in the matrices I bought, with the same control board I can thus only control a 2 * 64*32 RGB led matrix panel without using any trick. One led panel interface is thus "sacrified" to connect its color data lines to the addional color on the other two indoor led panels (all the panels have synchronized signals). Of course it is possible to control more of these LED panels by soldering together the clock / latch / enable signals to free some pins on the FPSLIC.<br></p>
<p><a href="https://www.limpkin.fr/public/RGB_Matrix/IMG_4093.JPG" title="// Photo close up rgb"><img src="https://www.limpkin.fr/public/RGB_Matrix/.IMG_4093_m.jpg" alt="// Photo close up rgb" class="media-center" title="RGB Led matrix, mai 2011"></a><br>
The result looks quite nice! I didn't implement any PWM to correct the colors, but the white balance is still <strong>very</strong> sweet. Of course, if you are planning on assembling a bigger panel, you'll surely need to <strong>control this</strong>, as it is the biggest inconvenient of led screens nowadays.<br>
I indeed realize that my control board is now completely obsolete for the led panels I use, so a new one will be made in the coming months (I am thinking using an AT90SAM, FPGA + ARM in a single chip).<br><br>
In the meantime, I decided to tweak my VHDL & AVR code to allow additional functionalities and max my overall performances :<br>
- Separate buffers for red green and blue<br>
- Possibility to change the red, green and blue data buffer addresses on the FPGA side to allow double (or more) buffering<br>
- Higher display refresh rate: <strong> 480Hz!</strong> You don't see any flickering now...<br>
- Individual control of each color of the led matrix from the AVR side of the FPSLIC, with only one function call (on / off / normal / inverted). Cool effects are thus easy to do when bringing this led matrix to several shows :) .<br>
- 2bits PWM per color per pixel (woot!), thus allowing a total of <strong>160 frames per second</strong><br>
- <strong>1Mbit/s</strong> RS232 speed between the PC and the FPSLIC (through the use of the FTDI) to enable <strong>40 frames per second in streaming mode</strong><br></p>
<p><a href="https://www.limpkin.fr/public/RGB_Matrix/IMG_4091.JPG" title="RGB Led matrix"><img src="https://www.limpkin.fr/public/RGB_Matrix/.IMG_4091_m.jpg" alt="RGB Led matrix" class="media-center" title="RGB Led matrix, mai 2011"></a><br>
And then I wondered, as I always lack of things to display on my led matrices, where could I find nice animations to show on such small resolution screens? The solution was pretty obvious: <strong>animated gifs</strong>. Yes, these crappy things that are at least 10 years old, who were used so much at the time the internet was at its beginning! Small resolution, no anti-aliasing, simple design, this was perfect.<br>
As my control board is resource-limited, I created a simple <strong>100 lines Matlab script</strong> that display on the led matrix one after the other all the animated gifts in a given folder on your computer. Please look at the code below, you will see that Matlab makes it very easy to do such complex tasks. Ah yes, <a href="http://www.evilmadscientist.com/article.php/LEDpics" hreflang="en" title="photographing leds">photographing leds</a> (and even worse, filming them) is a very complex task that I still haven't mastered. So the colours you see in the different pictures and videos are not exactly the ones you actually see. Anyway, check out this video:<br></p>
<div class="external-media" style="margin: 1em auto; text-align: center;">
<object width="480" height="295"><param name="movie" value="https://www.youtube.com/v/Q9pLGGuIy7M?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/Q9pLGGuIy7M?version=3" type="application/x-shockwave-flash" width="600" height="395" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<br /><a href="https://www.youtube.com/watch?v=Q9pLGGuIy7M">Animated gifs on a 64*64 RGB led matrix</a>
</div>
<p>And here is a small video of my <a href="https://www.limpkin.fr/index.php?post/2011/04/07/Electronic-projects-and-matlab">matlab program</a> adapted for this new led panel (you will see that I added a "lag effect" to show the different colours):<br></p>
<div class="external-media" style="margin: 1em auto; text-align: center;">
<object width="480" height="295"><param name="movie" value="https://www.youtube.com/v/vERS_CKG2iQ?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/vERS_CKG2iQ?version=3" type="application/x-shockwave-flash" width="600" height="395" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<br /><a href="https://www.youtube.com/watch?v=vERS_CKG2iQ">64*64 RGB Led matrix + Matlab + Webcam</a>
</div>
<p>And if you are thinking of building a big led screen, look at what I found next to the Xidan metro station in Beijing (this is made with the SMD led panels):<br></p>
<div class="external-media" style="margin: 1em auto; text-align: center;">
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/XqejXevyHCc?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/XqejXevyHCc?version=3" type="application/x-shockwave-flash" width="600" height="474" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<br /><a href="http://www.youtube.com/watch?v=XqejXevyHCc">Led screen in Beijing</a>
</div>
<p>Here are all the files you might need:<br>
<a href="https://www.limpkin.fr/public/RGB_Matrix/JXI5020.pdf">JXI5020 datasheet</a> <a href="https://www.limpkin.fr/public/RGB_Matrix/fpslic_led_matrix.rar">FPSLIC VHDL display code</a> <a href="https://www.limpkin.fr/public/RGB_Matrix/rgb_screen_generation.m">Picture to led matrix transfer</a> <a href="https://www.limpkin.fr/public/RGB_Matrix/gif_screen_generation.m">Gif to led matrix transfer</a> <a href="https://www.limpkin.fr/public/RGB_Matrix/webcam.m">Webcam matlab script</a></p>