{"id":1445,"date":"2015-03-12T00:45:45","date_gmt":"2015-03-11T22:45:45","guid":{"rendered":"http:\/\/blog.copcea.ro\/?p=1445"},"modified":"2017-01-21T20:25:57","modified_gmt":"2017-01-21T18:25:57","slug":"sku142210-big-display-clock-modified-with-temperature-and-automatic-dimming","status":"publish","type":"post","link":"http:\/\/blog.copcea.ro\/?p=1445","title":{"rendered":"SKU142210 big display clock modified with temperature, automatic dimming and semi-automatic software drift compensation"},"content":{"rendered":"<div class=\"02a7dab7e6fe5a0fbf433999ff85f046\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-2343103762362018\";\r\n\/* 336x280 *\/\r\ngoogle_ad_slot = \"8815738048\";\r\ngoogle_ad_width = 336;\r\ngoogle_ad_height = 280;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n<h1>0. Foreword<\/h1>\n<h1><\/h1>\n<p><span style=\"color: #ffff00;\"><strong>Please, do not post elsewhere the code found here.<\/strong><\/span><\/p>\n<p><span style=\"color: #ffff00;\">&#8211; The code should reside in one place and people should use links to my site instead. I have a hard time browsing the Internet for pieces of code sometimes, and finding old or obsolete code instead of links to the original developer is always a pain in the ass.<\/span><\/p>\n<p><span style=\"color: #ffff00;\">&#8211; I expect people to comment on the code and make optimizations\/new developments, especially for student usage. Having this in mind, the code itself is an ongoing process which can be followed by students, from its first state (intelligible, but unoptimized) to its latest state (optimized, but unintelligible). Many people asked me how the code becomes awful and almost impossible to understand. It is my chance to show that I always start from a human approach and I am ending to a computer approach, and that this is always an endeavour that takes time and patience and endless computations and verifications, it doesn\u2019t just come from thin air.<\/span><\/p>\n<p><span style=\"color: #ffff00;\">&#8211; the last reason is that I collect stats on page visits and downloads, which show me where to insist with open source development and where not to. I cannot collect stats from foreign sites, nor do I wish or have the time to do so.<\/span><\/p>\n<p><span style=\"color: #ffff00;\">Thank you!<\/span><\/p>\n<h1>1. Introduction<\/h1>\n<p>I have bought 3 pieces of <a href=\"http:\/\/www.banggood.com\/DIY-4-Digit-LED-Electronic-Clock-Kit-Large-Screen-Red-Blue-LED-p-935155.html\" target=\"_blank\">SKU14220 &#8211; DIY 4 Digit LED Electronic Clock Kit Large Screen Red Blue Green LED from banggood<\/a>.\u00a0 At ~ US$12, it seemed a good deal and most interesting. Following my experience with the EC1204B clock, I was almost sure the firmware was going to be bad.<\/p>\n<p>Bad is a nice thing to say. The firmware was horrible:<\/p>\n<p>&#8211; it doesn&#8217;t show day\/month\/year;<\/p>\n<p>&#8211; the setup is tricky and not easy to remember\/understand;<\/p>\n<p>&#8211; it lacks temperature;<\/p>\n<p>&#8211; many people comment it is too bright during the night.<\/p>\n<p>&#8211; the STC 15F204EA processor was a bad choice. 4K of flash do not suffice to build a nice and comfortable firmware for the end user, in my experience this design needs an processor with at least 8k flash.<\/p>\n<p>So I decided to modify the latest firmware for the EC1204B clock and make it available for this version, with the necessary modifications.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/blog.copcea.ro\/2015\/03\/12\/sku142210-big-display-clock-modified-with-temperature-and-automatic-dimming\/20150312_015503\/\" rel=\"attachment wp-att-1454\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1454\" title=\"20150312_015503\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015503-300x168.jpg\" alt=\"\" width=\"300\" height=\"168\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015503-300x168.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015503-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>Figure 1 &#8211; SKU142210 clock assembled &#8211; bottom view<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/blog.copcea.ro\/2015\/03\/12\/sku142210-big-display-clock-modified-with-temperature-and-automatic-dimming\/20150312_015430\/\" rel=\"attachment wp-att-1453\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1453\" title=\"20150312_015430\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015430-300x168.jpg\" alt=\"\" width=\"300\" height=\"168\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015430-300x168.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015430-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">Figure 2 &#8211; SKU142210 clock assembled &#8211; top view<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/blog.copcea.ro\/2015\/03\/12\/sku142210-big-display-clock-modified-with-temperature-and-automatic-dimming\/20150312_015410\/\" rel=\"attachment wp-att-1452\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1452\" title=\"20150312_015410\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015410-300x168.jpg\" alt=\"\" width=\"300\" height=\"168\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015410-300x168.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015410-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>Figure 3 &#8211; SKU142210 clock assembled &#8211; rear view<\/p>\n<p><em>Disclaimer:<\/em><\/p>\n<p><em>The software\/firmware presented here is a complete rewrite from scratch, just by observing the schematic and by understanding the way it works. It did not involve any kind of disassembly of the original firmware, reverse engineering or other similar stuff.<\/em><\/p>\n<p><em>I do not condone copying the work of others in any way. However, progress is difficult to achieve these days from zero and it is easier to build up on something that already exists, while respecting the original work and effort.<\/em><\/p>\n<p><em>I advice my readers to buy Banggood kits, the PCB has an excellent quality and all the parts delivered will be used, even with the modifications I suggest in this post. The idea is to start learning soldering and coding using affordable ressources.<\/em><\/p>\n<p>&nbsp;<\/p>\n<h1>\u00a02. Hardware modifications<\/h1>\n<p style=\"text-align: center;\"><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/AxjqVIzLMK4\" width=\"560\" height=\"315\" frameborder=\"0\"><\/iframe><br \/>\nVideo 1: The modified clock<\/p>\n<p>After studying the schematic, it became obvious the only thing that needed to be replaced was the processor itself, with another firmware.<\/p>\n<p>I couldn&#8217;t find any Atmel processor compatible pin to pin with the original, STC 15F204EA processor. The available place to insert a custom PCB in the processor&#8217;s slot is also narrow, so space would be of the essence in choosing a replacement processor.<\/p>\n<p>This is why I have decided to use an ATmega8 AU, which is the smd version of the ATmega8.<\/p>\n<p>Supplementary, a DS18B20 was added to measure temperature along with a photo-transistor, to implement automatic dimming of the display.<\/p>\n<p>&nbsp;<\/p>\n<p>From a mechanical point of view, the programming pins were designed to go through the plexiglass wall, in order to allow programming of the device even when it is fully enclosed, without the need to disassemble the enclosure (see Figure 3 above).<\/p>\n<h2>2.1 Schematic<\/h2>\n<p><a href=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/schematic.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1500\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/schematic-300x140.jpg\" alt=\"schematic\" width=\"504\" height=\"235\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/schematic-300x140.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/schematic-1024x478.jpg 1024w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/schematic.jpg 1031w\" sizes=\"(max-width: 504px) 100vw, 504px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u00a02.2 PCB<\/h2>\n<p><a href=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/PCB.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1499\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/PCB-300x142.jpg\" alt=\"PCB\" width=\"465\" height=\"220\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/PCB-300x142.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/PCB.jpg 999w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/><\/a><\/p>\n<h2>\u00a02.3 The actual PCB<\/h2>\n<p><a href=\"http:\/\/blog.copcea.ro\/2015\/03\/12\/sku142210-big-display-clock-modified-with-temperature-and-automatic-dimming\/20150312_015001\/\" rel=\"attachment wp-att-1460\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1460\" title=\"20150312_015001\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015001-300x168.jpg\" alt=\"\" width=\"300\" height=\"168\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015001-300x168.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_015001-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1502\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-300x300.jpg\" alt=\"20150419_101648\" width=\"300\" height=\"300\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-300x300.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-150x150.jpg 150w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-1024x1024.jpg 1024w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-50x50.jpg 50w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-96x96.jpg 96w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-24x24.jpg 24w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-36x36.jpg 36w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-48x48.jpg 48w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648-64x64.jpg 64w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150419_101648.jpg 1548w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">Figure 5. The bottom side of the PCB<\/p>\n<p><a href=\"http:\/\/blog.copcea.ro\/2015\/03\/12\/sku142210-big-display-clock-modified-with-temperature-and-automatic-dimming\/20150312_014934\/\" rel=\"attachment wp-att-1459\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1459\" title=\"20150312_014934\" src=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_014934-300x168.jpg\" alt=\"\" width=\"300\" height=\"168\" srcset=\"http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_014934-300x168.jpg 300w, http:\/\/blog.copcea.ro\/wp-content\/uploads\/20150312_014934-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">Figure 6. The top side of the PCB<\/p>\n<h1>\u00a03 Software-firmware<\/h1>\n<p>&nbsp;<\/p>\n<p>The software, or firmware, is a variation of the software used for the EC1204B clock, in a <a href=\"http:\/\/blog.copcea.ro\/2015\/02\/07\/ec1204b-clock-schematic-upgrade-firmware\/\">previous post of mine<\/a>.<\/p>\n<p>Disregarding the process of eliminating pieces of code that did not apply to this particular clock, the two main additions are:<\/p>\n<p>-the implementation of analog reading from a photo-diode, quite straightforward process;<\/p>\n<p>&#8211; the implementation of digital dimming a multiplexed display.<\/p>\n<p>A few words about the latter. The problem was to dim the display without having disturbing light shifts.<\/p>\n<p>How it was done: In a multiplexed display, only one digit is lit a a time, with the specific data for that digit. Then, we go to the second digit and so on until the last. Basically we have an eternal cycle of lighting each digit at a time, cycle equal to the number of digits to be lit. What if we would add to this cycle &#8220;dead&#8221; times, when we don&#8217;t lit any digit? The result will be a software pwm on the multiplexed digits, up to the point when all the digits start to tremble. After a few trials, I have discovered that this has to stop at around 50 cycles. After 50 cycles, the dimming process isn&#8217;t perceived by the human eye, but it inserts this trembling of the digits.<\/p>\n<p>The relationship between the level of light and the dimming is a simple transformation of the first degree, where dimming is inversely proportional to the level of light. The actual parameters are decided by experimenting. In this particular case, I had:<\/p>\n<p>0 light -&gt; 50 dimming cycles<\/p>\n<p>50 light -&gt; 4 dimming cycles.<\/p>\n<p>The transformation became : cycles = (54-light), which is a rough approximation of the hypothesis above. A supplementary condition is also in effect, after reading the light value:<\/p>\n<p>if (light&gt;50) light=50;<\/p>\n<p>This was necessary from direct observation: at 50 light, the display was too dimmed and the light\u00a0 value (0-100) didn&#8217;t correspond well with the dimming if it was to be used full scale.<\/p>\n<p>&nbsp;<\/p>\n<p>Feel free to play with the code and try to modify and optimize it. I hope it is easy enough to understand after 1-2 hours of study, in its most intimate details.<\/p>\n<h1>\u00a04. How it works<\/h1>\n<p>The upper button is the \u201cset\u201d button. The lower button is the \u201cselect\u201d button.<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Pressing the Set button will cycle between the DS18B20 temperature sensors present at start up. On the board there is only one sensor, but you may solder several other sensors, all connected in parallel, and the device detects them at start up.<\/li>\n<li>Pressing the Select button will enable you to program the microcontroller:\n<ul>\n<li>A short press (less than 5s) will show the date and month. Pressing it again will show the year. One more press reverts to clock display.<\/li>\n<li>A longer press (6-10s) will enter the alarm set mode. Press set to cycle between alarm hour, minutes, alarm enable and memory storage. Press select at each stage to cycle possible values (0-23 for hours, 0-59 for minutes, on\/off for enable);<\/li>\n<li>A longer press (11-15s) will enter the clock set mode. Press set to cycle between year, month, day, minutes, hours and memory storage. Press select at each stage to cycle possible values;<\/li>\n<li>A longer press (16-20s) will enter display mode. Press set to cycle between on, off and memory storage. Press select at each stage to cycle possible values;<\/li>\n<li>A longer press (21-25s) will enter the temperature unit select mode. Press set to cycle between C,F and memory storage. Press select at each stage to cycle possible values;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>At each stage, the last select key press is the memory storage. After storing selected parameters, the clock will beep. If you fail to store parameters (i.e. you do not press the button), the parameters will be in effect until the next reset of the clock.<\/p>\n<h1>5. Download<\/h1>\n<p>All the project for Atmel Studio 4, including a PDF with the PCB printout and necessary datasheets for parts (DS1302, DS18B20) can be downloaded <a href=\"http:\/\/blog.copcea.ro\/files\/electronica\/SKU142210.zip\" target=\"_blank\">here<\/a>.<\/p>\n<p>Following Bob Pike&#8217;s request to have the firmware show temperatures in F instead of C, the code was modified with the possibility to program the temperature display unit. The latest version can be downloaded <a href=\"http:\/\/blog.copcea.ro\/files\/electronica\/SKU142210-1.zip\" target=\"_blank\">here<\/a>.<\/p>\n<p>Last edit: 18.04.2015<\/p>\n<h1>6. Semi-automatic software drift compensation<\/h1>\n<p>Many people (including me) complain about the DS1302 drift, related to badly manufactured quartz resonators that do not offer a real 32 kHz (32768 Hz) clock.<\/p>\n<p>The drift may become so big, a clock can have easily +- 10 minutes drift in a matter of months. Having two or more clocks in different rooms may easily lead to headaches in the morning when the decision to leave for work becomes a growing pain week after week.<\/p>\n<p>The best practice would be to insert a trimmer capacitor in series with the quartz and set it to obtain a 32768 Hz clock. Even this practice is prone to errors due to:<\/p>\n<p>&#8211; bringing a metallic screwdriver next to the trimmer alters its capacity. After setting the trimmer it would change its capacity again, hence the clock;<\/p>\n<p>&#8211; normal trimmers are influenced by temperature. Just a little, but enough to generate a 1-minute drift every month or so;<\/p>\n<p>&#8211; usually there is no or very little space on the PCB to insert a trimmer properly;<\/p>\n<p>&#8211; the DS1302 clock could stop if a trimmer inserted in the circuit.<\/p>\n<p>I have imagined a software solution to the drift, by calculating it in between two clock settings.<\/p>\n<p>I began by asking myself what would be a disturbing drift, and I came with 5 minutes per year at a minimum, as being disturbing. However, setting the clock every year wouldn&#8217;t be too much to do, since I already set the clock twice a year when the daylight saving time appears and disappears.<\/p>\n<p>5 minutes per year would mean a drift of roughly 5*60\/12=25 seconds a month, less than 1 second per day.<\/p>\n<p>Since the setting is done manually and one could press the set button with a 1 second drift, if the setting would be done after 20 days, it would lead to a supplementary error drift of 365\/20=18.25 seconds a year, which is less than a minute per year: it wouldn&#8217;t even be noticeable.<\/p>\n<p>The whole idea is to set the clock twice in the same month from a good time source (like your PC, after synchronizing its time with a time server). Why during the same month? Just to make the subroutine that computes time difference easier and less flash consuming. Anyway, there&#8217;s less than 1K of flash available for this with this project.<\/p>\n<p>So: you set the clock on the 1st of the month and then you set it again on the 20th or 30th of the month.<\/p>\n<p>The software computes the time difference from the two settings, which were made using a good time source and it will also compute the time difference the DS1302 has run, thus determining the time drift in a given period of time (let&#8217;s say 34 seconds in 28 days).<\/p>\n<p>28 days equal 28*24*60=40320 seconds<\/p>\n<p>So we have a drift of 34 seconds every 40320 seconds, which means a drift of 1 second every 1185(.88) seconds.<\/p>\n<p>The clock will remember this drift and the processor will either add or subtract (depending on whether the drift is positive or negative) one second every 1185 seconds, by reading and rewriting the seconds in the DS1302.<\/p>\n<p>Two errors are now in place:<\/p>\n<p>&#8211; a 0.88 second (from rounding 1185.88 to 1185) every 40320 seconds, leading to roughly 12 seconds a year: almost non existent;<\/p>\n<p>&#8211; a supplementary error drift from manipulation of the setting button of 365\/20=18.25 seconds a year: almost non existent either;<\/p>\n<p>In fact, this kind of semi-automatic drift compensation can lead to an error of at most 30 seconds a year, much lower than we could obtain by inserting a trimmer and setting it to achieve a 32kHz clock for the DS1302. We would experience annoying drifts in 10 years of non-stop operation of the clock.<\/p>\n<p>What if we set the clock in different months? The software compares the month and the year of the last setting and the previous one. If these do not match, the clock drift is set to zero and there is no automatic drift compensation. A new clock setting in the same month would trigger a new drift computation and automatic drift compensation.<\/p>\n<p>What if we set the time more than once during the same month? The software would take into consideration the last interval between two settings. If the interval is too low (e.g. 3 days) it could lead to a wrong computation of the drift compensation.<\/p>\n<p>In order to set the drift compensation to zero, please operate two consecutive settings one after the other or by changing the month or year.<\/p>\n<p>This version of the firmware can be downloaded <a href=\"http:\/\/blog.copcea.ro\/files\/electronica\/SKU142210-v2.zip\" target=\"_blank\">here<\/a>.<\/p>\n<h1>7.\u00a0 Bug fixes, additions and optimizations<\/h1>\n<p>While working on my other project, the <a href=\"http:\/\/blog.copcea.ro\/2015\/02\/07\/ec1204b-clock-schematic-upgrade-firmware\/\">EC1204B Led rotating clock<\/a> and implementing some requests from my readers, I have discovered ways to improve the code and also minor bugs that were addressed.<\/p>\n<ul>\n<li>the code to multiplex the data on the display was optimized;<\/li>\n<li>there was a bug while displaying temperatures over 100. It was fixed.<\/li>\n<li>the colon display was modified. Now the colon displays whenever a second starts instead of displaying it on odd seconds only.<\/li>\n<li>Peter Casper had a request to alternatively show the clock and the temperature, for he wishes to use the clock in an infrared-heated room.I thought using the same idea as above, so a new EEMEM variable was defined and if at programming time it is equal to 1, it fires a condition in the main loop that shows the temperature for 1 second every 10 seconds. It displays just with one (or the first) temperature sensor.Some optimizations to the display routine were also made.Because this firmware is about to hit the available flash memory in the mega8515, I had to look closely of the size of the binary data that was about to be burned into the MCU. How to do this, since the HEX file size has nothing to do with the size of the binary code? I have written this morning a Windows tool that converts Intel HEX files to binary and viceversa + it allows for automation\u2026well, silent repetition of a load and save operations. I know, I am lazy, that\u2019s why I wished for automation. Find what it is all about in <a href=\"http:\/\/blog.copcea.ro\/2016\/12\/28\/intel-hex-to-binary-and-viceversa-windows-converter-for-avr-developers\/\">this <\/a><a href=\"http:\/\/blog.copcea.ro\/2016\/12\/28\/intel-hex-to-binary-and-viceversa-windows-converter-for-avr-developers\/\">post<\/a>.This version of the firmware can be downloaded <a href=\"http:\/\/blog.copcea.ro\/files\/electronica\/SKU142210-v3.zip\" target=\"_blank\">here<\/a>.<\/li>\n<\/ul>\n<h1>8. Combining all latest developments in one and allowing for setup without the need to reprogram the flash<\/h1>\n<p>While working on the latest requests for US mode (12H display and Fahnrenheit instead of Celsius), I used EEPROM variables to shorten the code and allow for its implementation. Unfortunately, to change these modes, the clock needed to be reprogrammed.<\/p>\n<p>After many optimizations, I have succeeded to implement a way to set these modes without the need for a programmer.<\/p>\n<p>Toggle between US and EU mode is now done from the menu itself:<\/p>\n<ul>\n<li>EU mode displays 24H and Celsius. Setting the clock and alarm shows 24H.<\/li>\n<li>US mode displays 12H and Fahnrenheit. Setting the clock and alarm shows 12H with A or P indicator for AM\/PM.<\/li>\n<\/ul>\n<p>Resetting the clock while pressing the SET key will toggle between regular clock display and clock\/temperature display (temperature is displayes for 1 second every 10 seconds).<\/p>\n<p>Enjoy downloading the latest firmware, datasheets etc, <a href=\"http:\/\/blog.copcea.ro\/files\/electronica\/SKU142210-v4.zip\" target=\"_blank\">here<\/a>.<\/p>\n<p>At this moment, the firmware has 8160 bytes, further development on this firware being almost impossible, at least with the ATmega8.<\/p>\n<h1>9. It becomes a never ending story, huh?<\/h1>\n<p>Following the latest developments on the EC1204B clock, a new set of improvements to the code were added:<\/p>\n<ul>\n<li>the code was optimized, again, to lower its size;<\/li>\n<li>the ghost digit disappeared;<\/li>\n<li>the clock can measure now negative temperatures on both C and F;<\/li>\n<li>toggling between EU and US modes may also be done by keeping SET pressed at startup. It can also be changed from the menu.<\/li>\n<\/ul>\n<p>Enjoy downloading the latest firmware, datasheets etc, <a href=\"http:\/\/blog.copcea.ro\/files\/electronica\/SKU142210-v5.zip\" target=\"_blank\">here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Last edited 17\/01\/2017<\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>0. Foreword Please, do not post elsewhere the code found here. &#8211; The code should reside in one place and people should use links to my site instead. I have a hard time browsing the Internet for pieces of code sometimes, and finding old or obsolete code instead of links to the original developer is <a href='http:\/\/blog.copcea.ro\/?p=1445' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14,12,6,297,13,1],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=\/wp\/v2\/posts\/1445"}],"collection":[{"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1445"}],"version-history":[{"count":40,"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=\/wp\/v2\/posts\/1445\/revisions"}],"predecessor-version":[{"id":1660,"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=\/wp\/v2\/posts\/1445\/revisions\/1660"}],"wp:attachment":[{"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1445"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.copcea.ro\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}