{"id":645,"date":"2013-08-29T19:40:04","date_gmt":"2013-08-29T17:40:04","guid":{"rendered":"http:\/\/paluweb.nl\/?p=645"},"modified":"2013-08-29T19:40:04","modified_gmt":"2013-08-29T17:40:04","slug":"work-in-progress-getting-the-raspberry-pi-to-talk-to-the-canopy","status":"publish","type":"post","link":"https:\/\/www.paluweb.nl\/?p=645","title":{"rendered":"Work in Progress: Getting the RaspBerry Pi to talk to the Canopy"},"content":{"rendered":"<p><BR><\/p>\n<blockquote><p>In my <a href=\"http:\/\/paluweb.nl\/?p=613\" title=\"Work in progress: Programming the Canopy\" target=\"_blank\">previous post<\/a> I managed to program the chips in the Canopy. Now I can adjust the code inside the Canopy where needed. Next thing to get working is to allow the Raspberry Pi to talk to the chips inside the Canopy.<\/p><\/blockquote>\n<p><BR><br \/>\n<strong>Raspberry Pi, Atmel AVR and serial communications<\/strong><\/p>\n<p>Luckily the Raspberry Pi has a serial port, because the AVR controllers I used have one too, and they use this serial port to get commands from whoever is controlling the bus&#8230; Which should be the Raspberry Pi. <\/p>\n<p>Problem is that the Raspberry Pi does not have a true RS232 serial port: the signals are there (on the GPIO headers), but they have 0-3.3V levels <!--more-->and they are inverted form the RS232 signal. Luckily the serial transmissions the AVRs in the Canopy expect are also inverted, but on a TTL (0-5V) level. Just connecting them up together will break stuff&#8230; Or maybe not?<br \/>\n<BR><br \/>\n<strong>Building the simplest interface possible<\/strong><\/p>\n<p>I started out with 74HCT540 chips to buffer the signals and convert their levels&#8230; But in the end I basically just connected them together. Why doesn&#8217;t this break things? Simple:<\/p>\n<ol>\n<li>The signals transmitted by the Raspberry Pi are 0 and 3.3V, well within the allowed levels of the Atmel AVR controllers (0-5V). Also, the AVR consider anything above 0.6 volts to be a logical &#8220;one&#8221;, so 3.3V is more than sufficient.<\/li>\n<li>The signals received by the Raspberry Pi would normally damage the RPi, as the 5V logic &#8220;high&#8221; is way above the 3.3V it accepts as a maximum. But because I have multiple AVR controllers on a single bus, all chips have a diode that effectively pull the voltage down for a zero, but RELEASE the wire for a high. So I could just mount a single pullup resistor to the +3.3V of the RPi, and now I receive serial signals between 0 and 3.3V.<\/li>\n<\/ol>\n<p>Problem solved! Now to build this &#8220;converter&#8221; in a way that it won&#8217;t break, AND fits into the RPi&#8217;s houseing. I think it worked out fine:<\/p>\n<div id=\"attachment_647\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3434.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-647\" src=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3434.jpg\" alt=\"Raspberry Pi with my serial communication &quot;level converter&quot;. It still fits in the RPi&#039;s housing, so I&#039;m happy.\" width=\"500\" height=\"333\" class=\"size-full wp-image-647\" srcset=\"https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3434.jpg 500w, https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3434-300x199.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-647\" class=\"wp-caption-text\">Raspberry Pi with my serial communication &#8220;level converter&#8221;. It still fits in the RPi&#8217;s housing, so I&#8217;m happy.<\/p><\/div>\n<p>After connecting it all up, I mounted the RPi inside the Canopy. What a tiny little controller it is inside this big wooden box:<\/p>\n<div id=\"attachment_649\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3442.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-649\" src=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3442.jpg\" alt=\"Let&#039;s play find the RPi. IT sits neatly between the LED light sources, just under the power supply.\" width=\"500\" height=\"333\" class=\"size-full wp-image-649\" srcset=\"https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3442.jpg 500w, https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3442-300x199.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-649\" class=\"wp-caption-text\">Let&#8217;s play &#8220;find the RPi&#8221;! It sits neatly between the LED light sources, just under the power supply.<\/p><\/div>\n<p>From here, it controls all 12 AVR controllers inside the Canopy. These controllers look like this:<\/p>\n<div id=\"attachment_650\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3456.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-650\" src=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3456.jpg\" alt=\"AVR Controllers inside the Canopy. Note the grey cable looping through all controllers to form a shared serial bus.\" width=\"500\" height=\"333\" class=\"size-full wp-image-650\" srcset=\"https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3456.jpg 500w, https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3456-300x199.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-650\" class=\"wp-caption-text\">AVR Controllers inside the Canopy. Note the grey cable looping through all controllers to form a shared serial bus.<\/p><\/div>\n<p>So what does the entire Canopy look like now? Check it out!<\/p>\n<div id=\"attachment_652\" style=\"width: 343px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3449.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-652\" src=\"http:\/\/paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3449.jpg\" alt=\"The entire Canopy with lights burning (not at 100%). Well almost... I just noticed I burnt a halogen in the bottom left :S\" width=\"333\" height=\"500\" class=\"size-full wp-image-652\" srcset=\"https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3449.jpg 333w, https:\/\/www.paluweb.nl\/wp-content\/uploads\/2013\/08\/IMG_3449-199x300.jpg 199w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/a><p id=\"caption-attachment-652\" class=\"wp-caption-text\">The entire Canopy with lights burning (not at 100%). Well almost&#8230; I just noticed I burnt a halogen in the bottom left :S<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post I managed to program the chips in the Canopy. Now I can adjust the code inside the Canopy where needed. Next thing to get working is to allow the Raspberry Pi to talk to the chips &hellip; <a href=\"https:\/\/www.paluweb.nl\/?p=645\">Read more <span class=\"meta-nav\">&raquo;<\/span><\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17,8,3],"tags":[143,155,153,123,150,152,151,154],"class_list":["post-645","post","type-post","status-publish","format-standard","hentry","category-automation","category-lighting","category-paludarium","tag-atmel-avr","tag-interfacing-rpi-to-atmel-avr","tag-level-converter","tag-raspberry-pi","tag-serial-port","tag-serial-port-atmel","tag-serial-port-raspberry-pi","tag-ttl"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=\/wp\/v2\/posts\/645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=645"}],"version-history":[{"count":7,"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=\/wp\/v2\/posts\/645\/revisions"}],"predecessor-version":[{"id":656,"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=\/wp\/v2\/posts\/645\/revisions\/656"}],"wp:attachment":[{"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paluweb.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}