{"id":103,"date":"2010-12-20T22:02:21","date_gmt":"2010-12-21T06:02:21","guid":{"rendered":"http:\/\/blog.danielparnell.com\/?p=103"},"modified":"2010-12-20T22:02:21","modified_gmt":"2010-12-21T06:02:21","slug":"the-funky-clock","status":"publish","type":"post","link":"https:\/\/blog.danielparnell.com\/?p=103","title":{"rendered":"The Funky Clock"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; \">We have a problem in our house. &nbsp;The youngest has a habit of waking the whole house at a time that is not pleasing to the rest of us. &nbsp;We put a clock in his room, but that didn&#8217;t help much because the monster child can&#8217;t read yet.<\/p>\n<div><\/div>\n<div>As with everything I decided a technological solution MUST be the best, so I present, the funky clock.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221165640_orig_PC210002.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221165640_PC210002.jpg\" width=\"192\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div><\/div>\n<div>The <a href=\"http:\/\/www.sparkfun.com\/products\/682\">dual colour LED array<\/a> is from <a href=\"http:\/\/www.sparkfun.com\/\">Sparkfun<\/a>. &nbsp;It is driven using two 74595 chips for the columns and a pair of ULQ2003 chips for the rows (because I didn&#8217;t have a ULM2008 chip). &nbsp;The brain of the thing is a <a href=\"http:\/\/www.microchip.com\/wwwproducts\/Devices.aspx?dDocName=en010300\">PIC18F4550<\/a> running my native code compiling <a href=\"http:\/\/en.wikipedia.org\/wiki\/Forth_(programming_language)\">forth<\/a> which I control over USB. &nbsp;I plan to produce a screen cast showing this in action at some stage.<\/div>\n<div><\/div>\n<div>I wanted to make the whole thing fit behind the display, so I was forced to put the processor and the LED driver hardware on their own boards.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221165650_orig_PC210004.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221165650_PC210004.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221165742_orig_PC210011.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221165742_PC210011.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div>The top of the processor board.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221165835_orig_PC210010.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221165835_PC210010.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div>The bottom of the processor board.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221165922_orig_PC210008.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221165922_PC210008.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div>The LED driver board. &nbsp;I was really pleased with this one. &nbsp;The 74595s are positioned so that they line up with the correct pins on the LED matrix so I didn&#8217;t need to run as many wires. &nbsp;This meant that I had to rotate one of them 180&nbsp;.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221170003_orig_PC210009.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221170003_PC210009.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div>The bottom of the LED driver board.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221170050_orig_PC210006.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221170050_PC210006.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div>The power board plugs into the processor board using the same connector as the <a href=\"http:\/\/www.sparkfun.com\/products\/9973\">PICkit 3<\/a>.<\/div>\n<div><\/div>\n<div><A href=\"\/wp-content\/uploads\/20101221170131_orig_PC210012.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/20101221170131_PC210012.jpg\" width=\"266\" height=\"200\" border=\"0\" \/><\/A><\/div>\n<div>All four parts of the clock fit together nicely \ud83d\ude42<\/div>\n<div><\/div>\n<div>I&#8217;ve set it up to display the hour in the main display area. &nbsp;Blink the bottom left LED every second to let me know it is working, and display the minute in binary on the bottom row. &nbsp;When it is bed time the hour is displayed in red, and when it is time to get up the hour is green.<\/div>\n<div><\/div>\n<div>I doubt it will make any difference, but I had fun making the funky clock \ud83d\ude42<\/div>\n<div><\/div>\n<div>It is amazing how easy it is to develop on the thing using forth on the actual hardware.<\/div>\n<div><span style=\"-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; \"><\/p>\n<pre style=\"color: rgb(0, 0, 0); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); background-position: initial initial; background-repeat: initial initial; \"><span style=\"color: rgb(128, 0, 0); font-weight: bold; \">: <\/span><span style=\"color: rgb(0, 0, 0); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(168, 168, 0); background-position: initial initial; background-repeat: initial initial; \">CLOCK-TASK<\/span> <span style=\"color: rgb(105, 105, 105); \">( -- )<\/span>\n    HOURS <span style=\"color: rgb(0, 140, 0); \">C<\/span>@ RED-TIME <span style=\"color: rgb(227, 74, 220); \">IF<\/span>\n<span style=\"white-space:pre\">\t<\/span>HOUR-PATTERN RED-LEDS LEDS!\n<span style=\"white-space:pre\">\t<\/span>BLANK-PATTERN GREEN-LEDS LEDS!\n    <span style=\"color: rgb(227, 74, 220); \">ELSE<\/span>\n        HOUR-PATTERN GREEN-LEDS LEDS!\n<span style=\"white-space:pre\">\t<\/span>BLANK-PATTERN RED-LEDS LEDS!\n    <span style=\"color: rgb(227, 74, 220); \">THEN<\/span>\n\n    SECONDS <span style=\"color: rgb(0, 140, 0); \">C<\/span>@ <span style=\"color: rgb(0, 140, 0); \">1<\/span> <span style=\"color: rgb(128, 0, 0); font-weight: bold; \">AND<\/span> <span style=\"color: rgb(227, 74, 220); \">IF<\/span>\n        <span style=\"color: rgb(0, 140, 0); \">7<\/span> GREEN <span style=\"color: rgb(0, 140, 0); \">C<\/span>@ <span style=\"color: rgb(0, 140, 0); \">80<\/span> <span style=\"color: rgb(128, 0, 0); font-weight: bold; \">OR<\/span>  MINUTES <span style=\"color: rgb(0, 140, 0); \">C<\/span>@ <span style=\"color: rgb(128, 0, 0); font-weight: bold; \">OR<\/span> <span style=\"color: rgb(0, 140, 0); \">7<\/span> GREEN <span style=\"color: rgb(0, 140, 0); \">C<\/span>!\n    <span style=\"color: rgb(227, 74, 220); \">ELSE<\/span>\n        <span style=\"color: rgb(0, 140, 0); \">7<\/span> GREEN <span style=\"color: rgb(0, 140, 0); \">C<\/span>@ <span style=\"color: rgb(0, 140, 0); \">7F<\/span> <span style=\"color: rgb(128, 0, 0); font-weight: bold; \">AND<\/span> MINUTES <span style=\"color: rgb(0, 140, 0); \">C<\/span>@ <span style=\"color: rgb(128, 0, 0); font-weight: bold; \">OR<\/span> <span style=\"color: rgb(0, 140, 0); \">7<\/span> GREEN <span style=\"color: rgb(0, 140, 0); \">C<\/span>!\n    <span style=\"color: rgb(227, 74, 220); \">THEN<\/span>\n;<\/pre>\n<p><\/span><\/div>\n<div>It was so much fun making a forth from scratch. &nbsp;It is based very loosely on <a href=\"http:\/\/rwmj.wordpress.com\/2010\/08\/07\/jonesforth-git-repository\/\">jonesforth<\/a>&nbsp;in that it implements many of the same kernel words, however it differs in that it generates subroutine threaded code instead of being token threaded. &nbsp;I have also implemented a very simple co-operative task switcher. &nbsp;The above task is responsible for setting up the display. &nbsp;I have two other tasks running, one that drives the LEDs and another that updates the time. &nbsp;While these tasks are running I am also still able to interact with the forth system via the virtual serial port over USB.<\/div>\n<div><\/div>\n<div>I want to thank my <a href=\"http:\/\/coodenco.com\/\">Dad<\/a> again for all his help with the hardware.<\/div>\n<div><\/div>\n<div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We have a problem in our house. &nbsp;The youngest has a habit of waking the whole house at a time that is not pleasing to the rest of us. &nbsp;We put a clock in his room, but that didn&#8217;t help much because the monster child can&#8217;t read yet. As with everything I decided a technological &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.danielparnell.com\/?p=103\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The Funky Clock&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[35,2],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-hardware","category-programming","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p561S3-1F","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103"}],"version-history":[{"count":0,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}