{"id":716,"date":"2020-04-08T15:19:17","date_gmt":"2020-04-08T15:19:17","guid":{"rendered":"https:\/\/www.adrian-smith31.co.uk\/blog\/?p=716"},"modified":"2024-11-29T18:08:24","modified_gmt":"2024-11-29T18:08:24","slug":"dual-colour-animated-clock-using-16x32-bi-colour-matrix","status":"publish","type":"post","link":"https:\/\/www.adrian-smith31.co.uk\/blog\/2020\/04\/dual-colour-animated-clock-using-16x32-bi-colour-matrix\/","title":{"rendered":"Animated clock using 16&#215;32 bi colour LED matrix modules"},"content":{"rendered":"<p>I finally got round to finishing the improved version of my earlier <a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/2018\/12\/mono-pong-clock\/\" target=\"_blank\" rel=\"noopener noreferrer\">pong clock<\/a> which used two single colour 16&#215;24 led modules with a built in controller. This version can display 3 colours and has several different modes to the earlier version and also it can display scrolling graphics from the popular retro game, pac-man. I&#8217;m calling this an arcade game clock as the main mode is pong and is inspired by old late 70&#8217;s and early 80&#8217;s arcade machine games. The case I originally was going to use got damaged but I&#8217;ve managed to put the prototype into an Ikea deep photo frame instead.<\/p>\n<p><a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/Colour-pong-clock.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-717 alignleft\" src=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/Colour-pong-clock-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/Colour-pong-clock-300x169.jpg 300w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/Colour-pong-clock.jpg 320w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Now on to the electronics and in particular the LED modules I used. They are kind of standard but nothing like you would typically find on ebay however the firmware can be adapted to work with standard HUB75 1\/8 scan modules. Unlike the modules used in the previous clock they do not have a built in controller and all multiplexing etc has to be done in software.<\/p>\n<p><!--more--><\/p>\n<p><span style=\"color: #000000;\"><strong>The LED modules used for the project<\/strong><\/span><\/p>\n<p>Now forgive me for this section being rather lengthy but the LED modules I used were salvaged and not completely standard. They are outdoor LED modules and unlike newer LED modules that use a single LED with seperate red, green and blue LED chips in them this uses individual LED&#8217;s for each colour tightly spaced together. This is the norm for high brightness outdoor displays as typically each module is just one part of a much larger display that will be viewed at a distance. Close up they don&#8217;t work so well compared to the single LED types. But I got them for nothing so I thought I&#8217;d see how they work and if they can be used for anything. The capacitors have domed tops as well suggesting that they have overheated or are poor quality. I&#8217;ve been playing with the modules for 2 years and they have been fine though.<\/p>\n<figure id=\"attachment_720\" aria-describedby=\"caption-attachment-720\" style=\"width: 300px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0252.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-720 size-medium\" src=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0252-300x180.jpg\" alt=\"\" width=\"300\" height=\"180\" srcset=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0252-300x180.jpg 300w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0252-1024x613.jpg 1024w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0252-768x460.jpg 768w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0252.jpg 1401w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-720\" class=\"wp-caption-text\">The separate red and yellow LED&#8217;s shown in 16&#215;32 format<\/figcaption><\/figure>\n<p>RGB LED modules that are sizes 16&#215;32, 32&#215;32 and 32&#215;64 use a common interface standard HUB75. This isn&#8217;t a very well documented standard and there are some variations in how the displays are scanned. Data sheets and timing diagrams are almost always required from the manufacturer unless they way they work can be reverse engineered or figured out by trial and error. There are also HUB08 and HUB12 panels which also have virtually no documentation. Typically I&#8217;ve found that these are for single and dual colour modules and work on 1\/4 scanning. The modules I have used are actually HUB75 RGB compatible but only two LED colours are used. As you can guess they have no datasheet.<\/p>\n<figure id=\"attachment_721\" aria-describedby=\"caption-attachment-721\" style=\"width: 300px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0251.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-721 size-medium\" src=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0251-300x166.jpg\" alt=\"\" width=\"300\" height=\"166\" srcset=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0251-300x166.jpg 300w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0251-1024x568.jpg 1024w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0251-768x426.jpg 768w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0251.jpg 1271w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-721\" class=\"wp-caption-text\">The rear of the matrix showing the 12-5V regulators and the data input connector and output connector for daisy chaining.<\/figcaption><\/figure>\n<p>Doing some research common scan rates are 1\/4, 1\/8 and 1\/16. This means the number of lines that are lit at any one time. For a 16&#215;32 LED matrix a 1\/4 scan display will have a 4 lines lit at once and is favoured for outdoor modules due to the faster scanning and therefore higher brightnesses can be achieved. The disadvantage is high power consumption. 1\/8 scan displays have 2 lines lit at any one time and 1\/16 modules only have one lit at any one time. 1\/16 scan is the slowest rate but least power hungry and is typically used for single colour modules. As you can see 1\/8 scan is a nice balance between power consumption and brightness.<\/p>\n<p>Now to explain further the displays are split into two halves of 8&#215;32 LED&#8217;s. For a 1\/8 scan module lines 1 &amp; 9 will be scanned then lines 2 &amp; 10 until lines 8 &amp; 16 are reached then the process repeats. There are separate data pins for each half (in a colour module typically labelled R1,G1,B1 &amp; R2,G2,B2) but the latch, clock and enable lines are common to both halves. Most addressing of the lines are sent to the display in Binary Coded Decimal so for a 16&#215;32 LED matrix the address lines will be labelled A,B,C as the display controller will only need to count from 0-7 so only 3 lines are needed.<\/p>\n<p>This is a easy way to tell what type of panel you have. 1\/4 scan displays will only have A &amp; B address lines, 1\/8 will have A,B &amp; C and then finally 1\/16 scan modules will have 4 address lines labelled A,B,C &amp; D.\u00a0 Larger 32 line tall displays will have a fifth address line, E. There is a caveat here though as some modules clock the data in differently. Some scan it in a zig-zag pattern across the display e.g the first 8 bits are line 1 then the next 8 bits are line 8 then it jumps back up to line 1 for the next 8 bits. Others scan a whole line of 32 LED&#8217;s then move on to the next line. Another caveat is the output enable pin can be either active low or active high.<\/p>\n<p><em>Update: I&#8217;m now aware of HUB75B standard panels that have 3 address lines (16&#215;32) and use 1\/4 scan but scan the data in a zigzag (snake) pattern rather than row by row. These seem to be the new standard and a modified library has been made for such displays. See here <a href=\"https:\/\/forum.arduino.cc\/index.php?topic=503416.0\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/forum.arduino.cc\/index.php?topic=503416.0<\/a> and here <a href=\"https:\/\/forum.arduino.cc\/index.php?topic=310346.0\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/forum.arduino.cc\/index.php?topic=310346.0<\/a> if you have one of these newer displays.<\/em><\/p>\n<p>So you can see that the HUBxx standards are only loose standards and documentation is hard to find. I used the Adafruit RGBmatrixPanel library which works with 1\/8 scan HUB75 modules. This library is obviously designed to drive RGB modules but it worked fine with my modules simply by connecting R1 and R2 as you would normally Y1 and Y2 to G1 and G2 and then leave the pins on the arduino for B1 and B2 unconnected. On my modules I would send green if I wanted it to display yellow; this is simply because what would be green LED&#8217;s on the module are actually yellow.<\/p>\n<p>Finally, HUBxx standard modules use a 16 pin header. Mine does not although it is electrically compatible. Fortunately the pinout was shown on the matrix&#8217;s PCB of what goes where. Some lines were labelled different such as CLR (underlined to indicate active low) is actually output enable, typically labelled just OE on other modules.<\/p>\n<p><strong>The controller board<\/strong><\/p>\n<p>I used an ATMega2560 for this project as the matrixes require a lot of RAM. 1.5Kb to be precise for double buffer mode which is recommended otherwise the display will be very flickery. Add another 1kb of SRAM for your code and you have run out of SRAM on your Arduino uno. Also the program takes up 41kB of flash space so it&#8217;s unsuitable for a basic Arduino. You could try other microcontrollers such as the ATmega644PU or ATmega 1280 but this hasn&#8217;t been tested and the code will need to be adapted. Some of the display driver is written in assembly language and only supports ATmega328 and 1280\/2560.<\/p>\n<p>I used a cheap Arduino 2560 pro clone board as soldering the bare mega2560 onto a custom PCB would have been a nightmare. This was the simplest and cheapest option rather than designing my own PCB. The clone board was soldered to a matrix board and required components added such as the DC-DC converter. I didn&#8217;t use the onboard regulator on the pro board as it just got too hot. I used a switching 7805 drop in replacement regulator instead. The controller also supports an optional seven segment display that comes on when the main module is turned off. In my code this is done automatically between 11pm and 6am and can be turned on and off by pushbuttons.<\/p>\n<p>Unfortunately I didn&#8217;t make a schematic as the connections are shown in the code and this project, for now is just a one-off. The 7 segment display is a common anode type and uses PNP transistors on the digit pins. 82 ohm resistors were used for the current limiting resistors. If you want to learn how the seven segment displays are multiplexed, check out this <a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/2019\/11\/multiplexing-seven-segment-displays-on-an-arduino\/\" target=\"_blank\" rel=\"noopener noreferrer\">article.<\/a><\/p>\n<p><strong>The case<\/strong><\/p>\n<p><a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0253.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-724 alignleft\" src=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0253-300x175.jpg\" alt=\"\" width=\"300\" height=\"175\" srcset=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0253-300x175.jpg 300w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0253-1024x596.jpg 1024w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0253-768x447.jpg 768w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/DSC_0253.jpg 1343w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>Originally I had purchased a 3.75&#8243; deep photo frame to house the project but that got broken. Instead I used an Ikea frame and made it deeper by adding some self adhesive trunking onto the rear. I then mounted the electronics onto a plastic plate and then screwed that to the frame. I then used the original back cover to fit over the exposed PCB. A 3A 12V AC adaptor provides power to the clock. I will possibly re-case it if the clock is going to be used as intended or maybe keep as something to mess around with. Maybe even get a proper RGB matrix and modify it accordingly.<\/p>\n<p><strong>The source code &amp; demo video<\/strong><\/p>\n<p><a href=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2020\/04\/Dual_Colour_Pong_Clock-1.23-CA-sevenseg.zip\" target=\"_blank\" rel=\"noopener noreferrer\">Here is the source code<\/a> which is a heavily modified mish mash of various snippets of code from various incarnations of the pong clock. Credits listed in the code.<\/p>\n<p>Finally here is a video of it working.<\/p>\n\n<div class=\"youtube-embed\" itemprop=\"video\" itemscope itemtype=\"https:\/\/schema.org\/VideoObject\">\n\t<meta itemprop=\"url\" content=\"https:\/\/www.youtube.com\/v\/852I4QHp8hQ\" \/>\n\t<meta itemprop=\"name\" content=\"Animated clock using 16&#215;32 bi colour LED matrix modules\" \/>\n\t<meta itemprop=\"description\" content=\"Animated clock using 16&#215;32 bi colour LED matrix modules\" \/>\n\t<meta itemprop=\"uploadDate\" content=\"2020-04-08T15:19:17+00:00\" \/>\n\t<meta itemprop=\"thumbnailUrl\" content=\"https:\/\/i.ytimg.com\/vi\/852I4QHp8hQ\/default.jpg\" \/>\n\t<meta itemprop=\"embedUrl\" content=\"https:\/\/www.youtube.com\/embed\/852I4QHp8hQ\" \/>\n\t<meta itemprop=\"height\" content=\"340\" \/>\n\t<meta itemprop=\"width\" content=\"560\" \/>\n\t<iframe loading=\"lazy\" style=\"border: 0;\" class=\"youtube-player\" width=\"560\" height=\"340\" src=\"https:\/\/www.youtube.com\/embed\/852I4QHp8hQ\" allowfullscreen><\/iframe>\n<\/div>\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally got round to finishing the improved version of my earlier pong clock which used two single colour 16&#215;24 led modules with a built in controller. This version can display 3 colours and has several different modes to the earlier version and also it can display scrolling graphics from the popular retro game, pac-man. [&hellip;]<\/p>\n","protected":false},"author":179,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Animated clock using 16x32 bi colour LED matrix modules - Adrian's electronics blog","description":"I finally got round to finishing the improved version of my earlier pong clock which used two single colour 16x24 led modules with a built in controller. This v"},"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-716","post","type-post","status-publish","format-standard","hentry","category-microcontrollers","category-projects"],"_links":{"self":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts\/716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/users\/179"}],"replies":[{"embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=716"}],"version-history":[{"count":16,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts\/716\/revisions"}],"predecessor-version":[{"id":1825,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts\/716\/revisions\/1825"}],"wp:attachment":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}