tag:blogger.com,1999:blog-78080369654097189272024-02-25T07:28:31.882+00:00Sparks N SmokeA list of my little discoveries and projects with my newly-found pastime - fiddling around with computing and electronics.
For the full story as it happened, read from the first post (at the bottom).S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.comBlogger73125tag:blogger.com,1999:blog-7808036965409718927.post-33795818860655240422023-02-03T15:15:00.005+00:002023-02-03T15:39:39.953+00:0073. Using ChatGPT to generate code for the Raspberry Pi Pico<p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">108,991 page views!!</b><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1KBg2g50dlnwS6KpQnhxwV8iDM_mlDO6hpsiUswFGkIk79pL8wM9zAc6V0TaaQpSpGwi_Mow0QU5und9btPcPUrud8KLekc_wCY_SwyjUu14c3fS5bTI0Tq2L30pk8rGMA-c-J9R_rFDZIjzFEx6UmIFVWSIYgPW3lALaocwRh6TZkFisrW9wnV9iAg/s1907/Untitled-1.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="987" data-original-width="1907" height="309" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1KBg2g50dlnwS6KpQnhxwV8iDM_mlDO6hpsiUswFGkIk79pL8wM9zAc6V0TaaQpSpGwi_Mow0QU5und9btPcPUrud8KLekc_wCY_SwyjUu14c3fS5bTI0Tq2L30pk8rGMA-c-J9R_rFDZIjzFEx6UmIFVWSIYgPW3lALaocwRh6TZkFisrW9wnV9iAg/w596-h309/Untitled-1.jpg" width="596" /></a></div><br />ChatGPT is a wonderful <b>chatbot</b> under development by OpenAI which uses Artificial Intelligence to respond to text input. It can respond to any request from conversations about almost any subject to writing essays.<p></p><p></p><p>It can also write computer code in many languages.</p><p>I gave it the following input:</p><p><span face="Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"" style="color: #343541; font-size: 16px; white-space: pre-wrap;"><b>write micropython code for raspberry pi pico to display the following effects on a 60 led strip at pin 0:</b></span></p><span face="Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"" style="color: #343541; font-size: 16px; white-space: pre-wrap;"><b>Rainbow cycle
Theater chase rainbow
Twinkle
Sparkle
Flame
Running lights
Alternating colors</b></span><p>and it responded with the following code:</p><p><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">from machine import Pin
import neopixel
import </span><span class="hljs-selector-tag" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">time</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">
import random
num_pixels = </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">60</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">
pin = </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">Pin</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels = neopixel</span><span class="hljs-selector-class" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">.NeoPixel</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(pin, num_pixels)
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">rainbow_cycle</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for j in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">256</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(num_pixels):
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, j, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;"> - j)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">theater_chase_rainbow</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for j in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">256</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">):
for q in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">3</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, num_pixels, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">3</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">):
pixels[i + q] = (j, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;"> - j, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, num_pixels, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">3</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">):
pixels[i + q] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">twinkle</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(num_pixels):
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sparkle</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(num_pixels):
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">flame</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(num_pixels):
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">165</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">running_lights</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(num_pixels):
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
def </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">alternating_colors</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait):
for i in </span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">range</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(num_pixels):
if i % </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">2</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;"> == </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">:
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
else:
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">255</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
pixels.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">write</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">()
time.</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">sleep</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(wait)
pixels[i] = (</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">, </span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)
effects = [rainbow_cycle, theater_chase_rainbow, twinkle, sparkle, flame, running_lights, alternating_colors]
while True:
for effect in effects:
</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">print</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-string" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #00a67d; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">"Running effect: "</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;"> + effect.__name__)
</span><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #e9950c; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">effect</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-number" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: black; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #df3079; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">0.1</span><span style="background-color: black; color: white; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 14px; white-space: pre;">)</span></p><p>and added the following information:</p><p><span face="Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"" style="background-color: #f7f7f8; color: #374151; font-size: 16px; white-space: pre-wrap;">This code will run each effect in a loop, printing the name of the effect before it starts. You can adjust</span></p><p>I connected the 60 LED WS2812B strip (Neopixel) to the Pico's TX pin (Pin 0) as in the image below: (I included the push button to allow re-setting of the Pico). </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLzcIJpp8mzIoiSDDrzIY-cManCsVnHlfGLG4ynWXtMqLVaXdmIDaHaUN-7BhKO6AaPBz2Pwbw150YgphGNHLqhZGfx5dxi-lAcs9ZiF6PAfdHz30XlHH1heY8WEpN3r3BU3ps5CO1tQzaFDw5KHpqRBp4MSYgdElhkTG9P-c-L89odFKXx8RzUBTVaQ/s2137/P2038065.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1440" data-original-width="2137" height="404" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLzcIJpp8mzIoiSDDrzIY-cManCsVnHlfGLG4ynWXtMqLVaXdmIDaHaUN-7BhKO6AaPBz2Pwbw150YgphGNHLqhZGfx5dxi-lAcs9ZiF6PAfdHz30XlHH1heY8WEpN3r3BU3ps5CO1tQzaFDw5KHpqRBp4MSYgdElhkTG9P-c-L89odFKXx8RzUBTVaQ/w598-h404/P2038065.jpg" width="598" /></a></div><i><div style="text-align: center;"><i>The Raspberry Pi Pico connected to the GND (black wire) and the signal output (white wire) of the Neopixel strip. The Neopixel strip gets its power from a 5V, 5A exterior supply. The Pico itself is powered through the connector on the right, from the Raspberry Pi 4 (not shown).</i></div></i><p>The Pico is powered by a Raspberry Pi 4, which comes with <b>Thonny</b>, a Python Integrated Development Environment (IDE). I Installed MicroPython on the Pico and when I fired up Thonny, I copied the code generated by ChatGPT into Thonny and clicked the <b><i>Run current script</i></b> button.</p><p></p><p>And... it worked!!</p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='599' height='498' src='https://www.blogger.com/video.g?token=AD6v5dwi8y0R_BIz2zP9BPPQzNHueEhbTBavE_sKxXrMoPh_smZmPTZ0WLr8LnA_XkgaGWn1F4Zmj8BgW2qCDIhaYA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><br /><p><br /></p><div><br /></div><p></p></div>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-84216586485041551052020-08-04T12:03:00.012+01:002020-08-04T12:09:18.703+01:0072. The Elegoo Tumbller auto-balancing robot<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">95,555 page views!!</b><div> <div>My latest project:
</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/QP0Qnr5TU68" width="320" youtube-src-id="QP0Qnr5TU68"></iframe></div><div><br /></div></div>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-27857608833403230212015-12-02T10:10:00.003+00:002018-04-20T16:06:31.915+01:0071. A Raspberry Pi Security Camera System<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">78,000 page views!!</b><br />
I came across <b><i>motionPie</i></b> [this has now become <b><i>motionEYE OS</i></b>] some time ago and bookmarked it for later reference. I only remembered it recently and looked into it in detail. I discovered a fantastic system which is what I've been looking for for ages.<br />
<br />
I've done live video via <b>SSH</b> <b><a href="http://smokespark.blogspot.co.uk/2013/06/23-making-time-lapse-sequences-with-pi.html" target="_blank">HERE</a></b> which was interesting, and even did control of LEDs via wireless network <b><a href="http://smokespark.blogspot.co.uk/2013/05/19-back-to-raspberry-pi-webiopi.html" target="_blank">HERE</a></b> but I hadn't realised that access to web pages on the internet is not possible unless you open a port on your router. This is called <b>Port Forwarding</b>, and I've always been afraid to get involved in this by meddling with my router's settings in case I messed the whole thing up.<br />
<br />
Anyway, this time I bit the bullet and had a go, and it worked!! What I now have is an extremely cheap security camera system - with 2 cameras - and I can broadcast the live video images to the internet!<br />
<br />
<b>Camera 1</b> is the <b>RasPi Camera</b> at 1600 x 1200 pixels. <b>Camera 2</b> is the <b>Logitech</b> USB camera at 640 x 480 pixels.<br />
<br />
The instructions for installing <b><i>motionPie</i></b> are very clearly given <b><a href="http://pimylifeup.com/raspberry-pi-security-camera/" target="_blank">HERE</a> </b>by Gus of <b>PI My LifeUP</b>. He also gives instructions for setting your router up for <b>Port Forwarding <a href="http://pimylifeup.com/raspberry-pi-port-forwarding/" target="_blank">HERE</a></b>. [The download page for <b><i>motionEYE OS</i></b> can be found <b><a href="https://github.com/ccrisan/motioneyeos/releases" target="_blank">HERE</a></b>]. However, while the instructions give all the essential information, his router is not the same as my <b>BT Infinity Hub 3.0</b> router. So I went to my Home Hub web page and the information there is also useful, although after setting it up, you don't know whether your port is open or not.<br />
<br />
However, I then found a useful site <b><a href="http://www.yougetsignal.com/tools/open-ports/" target="_blank">HERE</a> </b>which will confirm that your port is open and is not being blocked by the firewall. There are of course other good sites with <b>Port Forwarding</b> testers.<br />
Another program useful for showing you what devices are on your network is Zenmap available from <b><a href="https://nmap.org/" target="_blank">HERE</a></b>. Run it with a target of <b>192.168.1.0/24</b> and a command of <b>nmap -sn 192.168.1.0/24</b>. This will list all the addresses of connected devices (hosts).<br />
<br />
<b><i>motionEye</i></b> requires a dedicated SD card image on the Pi, because it is a stand-alone operating system (OS), but this is not a problem. Once set up, you don't even need a monitor attached to the Pi, your <b><i>motionEye</i></b> console gives you access to everything you need, including downloading images to your PC and deleting images from the Pi.<br />
<br />
The two cameras I am using are the <b>RasPi Camera</b> board, connected to the Pi through the CSI - camera serial interface - in the usual way, and a cheap USB camera I used to use for Skyping from my PC. <b>PI My LifeUP</b> suggests that you can have even more USB cameras. I will have to test that.<br />
<br />
Here is an image of the control console [the <b><i>motionEye</i></b> console is almost identical, with some improvements]:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjylSR_oeIpTnb3qeOlRtSnKkcMlTO7LCS4SDS6KDikE5GeLesFWGC2VlmRwe48ysTvKWRIPWUUCXQ8kKVW_rlLG9Jhegd8bltOQDeJOtVDj2JRdVhPCSIYalZIjon5Gd0BsoWrK1m7zidq/s1600/motionPieConsole.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="363" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjylSR_oeIpTnb3qeOlRtSnKkcMlTO7LCS4SDS6KDikE5GeLesFWGC2VlmRwe48ysTvKWRIPWUUCXQ8kKVW_rlLG9Jhegd8bltOQDeJOtVDj2JRdVhPCSIYalZIjon5Gd0BsoWrK1m7zidq/s640/motionPieConsole.jpg" width="640" /></a></div>
The available control options are too numerous to capture in one picture, but the image shows the main sections which open up and give almost total control of your video, stills, time lapse or motion activated images from all your cameras.<br />
<br />
There's only one problem that I've noticed after running this for a couple of days - my router port has for some reason closed a couple of times (it changed its IP address once too - maybe is this what is meant by Dynamic DNS - Dynamic Domain Name System?). When this happens, you no longer have the ability to re-boot the Pi through the <b><i>motionEye</i></b> console. If the Pi were to be placed somewhere remote, you would have to go to it and de-power and re-power it to get the system running again. This is just something to bear in mind.<br />
<br />
I have added a couple of time-lapse sequences (conveniently produced by <b><i>motionPie/motionEye</i></b>) below:<br />
<br />
<div style="text-align: center;">
<b>Camera 1:</b></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dyzbG8i8Um9ztanB9lNjno-Q0IdKfYCzZzFEtmwK5Drs2mdjiir2dDp7ZXRw9Wd-qRcPCYhlTIwzBN2MHia' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="text-align: start;">Camera 2:</b></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dzugbj1CJ6tmk9PQmySHGUXIdLFQte0MXjYJbVy6G7XqRRGVqZKWM3x8K_G3rrU0LPEq2YA7fvN5jxFiD00Jw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
Here's a photo of the Pi with the <b>RasPi Camera</b> looking through my 8X zoom Telephoto lens. You can see the cable running up to the USB camera which is looking through the window higher up.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHaYbWWdvBSz5x-SaEPoXrSA0HZo0sK0ykNqtmEa-nXwAFBdj0f7Llbv5e7thS4O57b3MrJmra9d3rERhwcedPcU_gx0JYZeKzCc8gIuVZKEcyu2EbVFC2RUUeih1kUtE3RAHVyQJftMC9/s1600/PC023860.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHaYbWWdvBSz5x-SaEPoXrSA0HZo0sK0ykNqtmEa-nXwAFBdj0f7Llbv5e7thS4O57b3MrJmra9d3rERhwcedPcU_gx0JYZeKzCc8gIuVZKEcyu2EbVFC2RUUeih1kUtE3RAHVyQJftMC9/s640/PC023860.JPG" width="640" /></a></div>
Have a close look at this picture and see if you notice that pesky Jay bird nosing about.<br />
<br />
Here he is pinching the tits' lunch:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqbzcvHwWQzjoRITzSZ_LpyafNC0Wk_huyabR5P_1IcDhV3KCWZBAeHj3kx-6jtg6P1VaMQ5STSJPbU0QeoF8WgKfAoZSzWlWjTrzNp3IYkvUAL-DqSEO2nCT7hXxfbXkymjKjdf0C60Zy/s1600/JayBird.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqbzcvHwWQzjoRITzSZ_LpyafNC0Wk_huyabR5P_1IcDhV3KCWZBAeHj3kx-6jtg6P1VaMQ5STSJPbU0QeoF8WgKfAoZSzWlWjTrzNp3IYkvUAL-DqSEO2nCT7hXxfbXkymjKjdf0C60Zy/s640/JayBird.jpg" width="640" /></a></div>
Nice bird - a type of crow, and related to the mag<b><i style="background-color: black;"><span style="color: white;">pie</span></i></b> - apparently not that common in this part of the world - except my garden! They are said to be "shy woodland birds" - this one's anything but shy. I must report him to the RSPB!<br />
<br />
<b style="font-style: italic;">motionEye</b> is a really super piece of software.<br />
<br />S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-33217226731979556152015-11-21T16:56:00.002+00:002015-11-28T16:55:22.375+00:0070. The 4-digit 7-segment LED Display Revisited<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">46,000 page views!!</b><br />
In a previous post (see <b><a href="http://smokespark.blogspot.co.uk/2013/10/36-4-digit-7-segment-led.html" target="_blank">HERE</a></b>) I used an <b>Arduino</b> to drive a 4-digit, 7-segment LED display to count down from 9999 seconds to zero. Just a few days ago, <b>Alex Eames</b> of <b><i>RasPi.TV</i></b> blogged (see <b><a href="http://raspi.tv/2015/how-to-drive-a-7-segment-display-directly-on-raspberry-pi-in-python" target="_blank">HERE</a></b>) to say that he managed to drive one of these displays with a <b>Raspberry Pi</b> and make it into a real-time clock. In fact, he also offered a kit of parts to carry this out, so I bought one (only £12 including postage). Here's the kit:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://raspi.tv/wp-content/uploads/2015/11/RasPiO-7seg_700.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://raspi.tv/wp-content/uploads/2015/11/RasPiO-7seg_700.jpg" height="370" width="640" /></a></div>
<br />
<br />
I thought this was interesting because other real time clocks I have built, have had a small circuit board powered by a separate button battery to keep the clock going even when the main board is switched off. (See <b><a href="http://smokespark.blogspot.co.uk/2013/12/40-second-version-of-yacht-race-timer.html" target="_blank">HERE</a></b>.) I wondered how you could do this even with a <b>Raspberry Pi</b> as, like the <b>Arduino</b>, it doesn't have a built in clock either.<br />
<br />
The secret is that the <b>Raspberry Pi</b> is on-line and the <b>Python</b> language's <b><i>time</i></b> library is capable of reading the time at regular intervals from the internet, using the <b><i>time.ctime()</i></b> function. This had been previously reported just about a year ago by <b><i>bertwert</i></b> (see <b><a href="https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=91796" target="_blank">HERE</a></b>). <br />
<br />
The details of Alex's kit can be found in his blog, referenced above, so I'll not repeat them here.<br />
<br />
<h2 style="clear: both; text-align: left;">
Common Cathode</h2>
Here is the kit assembled and connected to my <b>Raspi B+</b>:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcIDTUJwKpoMk6pr99Gge9v0xJ7_HMpLguossaFUdtOIZP1VQcHQG_Hp9ZZVptNRIoIf80s_IObpWSWPaNL-KILNF5aoYo6_I0hf7P2XLnfoRYCU4orwLBsHXDhz5UJtSunR9sTJSoeIDF/s1600/PB193844.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcIDTUJwKpoMk6pr99Gge9v0xJ7_HMpLguossaFUdtOIZP1VQcHQG_Hp9ZZVptNRIoIf80s_IObpWSWPaNL-KILNF5aoYo6_I0hf7P2XLnfoRYCU4orwLBsHXDhz5UJtSunR9sTJSoeIDF/s640/PB193844.JPG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Note that the <b>Pi</b> has a WiFi dongle and is connected to my wireless network. You can see the LED Display unit mounted on the mini-breadboard, and the 8x 100 Ω resistors, all supplied by Alex.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's a video:</div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="360" mozallowfullscreen="" src="https://player.vimeo.com/video/146513265" webkitallowfullscreen="" width="640"></iframe> </div>
<a href="https://vimeo.com/146513265">PB193845</a> from <a href="https://vimeo.com/user25118189"></a><a href="https://vimeo.com/">Vimeo</a>.<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
And here's my version of Alex's code which was derived from that of <b><i>bertwert</i></b>:</div>
<script src="https://gist.github.com/kcranley1/fea9a8942cf89b1dcd35.js"></script>
<br />
<div class="separator" style="clear: both; text-align: left;">
You can see from lines 38 to 51 that the <b><i>time.ctime()</i></b> command is repeatedly executed, reading the time from the internet, in the fo<span style="font-family: "times" , "times new roman" , serif;">rm <span style="background-color: #fbfbfb; line-height: 18px;">‘<b><i>Sat Nov 21 17:11:05 2015</i></b>’. </span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: #fbfbfb; font-family: "times" , "times new roman" , serif; line-height: 18px;">This is parsed to extract just the hour (</span><b style="font-family: times, 'times new roman', serif; line-height: 18px;"><i>17</i></b><span style="background-color: #fbfbfb; font-family: "times" , "times new roman" , serif; line-height: 18px;">) and the minutes (</span><b style="font-family: times, 'times new roman', serif; line-height: 18px;"><i>11</i></b><span style="background-color: #fbfbfb; font-family: "times" , "times new roman" , serif; line-height: 18px;">) and display these four digits. The decimal point for the second digit (digit 1) is used to separate the minutes from the seconds and to flash every second.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "times" , "times new roman" , serif;"><span style="background-color: #fbfbfb; line-height: 18px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "times" , "times new roman" , serif;"><span style="background-color: #fbfbfb; line-height: 18px;">The code loops, for each digit, each of its segments, and depending on whether the <b><i>num</i></b> dictionary specifies that segment to be <b>0</b> or <b>1</b> ie off or on, switches that segment on for 5 milliseconds. This happens very fast, so each segment to go on, actually flashes on for 5 milliseconds in each loop. This <b><i>time.sleep(0.005)</i></b> command is repeatedly executed until the time read from the internet changes (for example another second is updated). So the LEDs are actually flashing repeatedly. This is a form of <b>Pulse Width Modulation</b>, and the eye-brain system of an observer doesn't notice the flashes, but observes the segment of the digit as a steady light of constant brightness, even though the brightness of the flashes is much higher. This has been described before as <b>Persistence of Vision</b> (POV).</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Alex of course, goes on (see <b><a href="http://raspi.tv/2015/7-segment-display-python-raspberry-pi-countdown-ticker#comment-59939" target="_blank">HERE</a></b>) to make a count-down ticker, but still dizzy with excitement, I remembered that I had a spare 4-digit 7-segment LED Display so I dug it out. It is of a different type, COMMON ANODE, as opposed to the COMMON CATHODE one above supplied by Alex.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
So I started wondering how I could wire up my spare LED display, and realised that there was more to it than just a simple swap-over. Before I risked blowing anything up, I consulted Alex.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here is the internal circuit diagram for the COMMON CATHODE oue:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw9iBG0dcqOdsz6TTa252-k5ZMPyqy2qgZXLJdfmZTPKriXqGWmtMj87cXRoN_Qyl9f-iuNO7m8NYDd1X0YygPqxMh5YcaIkvNOfhFX1Wg7WxfCG8i2sWwxvmFU2yQ-pqlWn-prg3MOKl_/s1600/4digit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="366" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw9iBG0dcqOdsz6TTa252-k5ZMPyqy2qgZXLJdfmZTPKriXqGWmtMj87cXRoN_Qyl9f-iuNO7m8NYDd1X0YygPqxMh5YcaIkvNOfhFX1Wg7WxfCG8i2sWwxvmFU2yQ-pqlWn-prg3MOKl_/s640/4digit.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj4w-FSIjSf9VMiCiCC9s-IvIVvYqbKfDhOB22w0-_ICUidb6xIpX7_nq2Hi1bxSm9RyiNMNTZs8ItMJ7G6E_Uc4St57lUQfZMkQ4ugTBKAMx0iE8aGOwZkRltMGvVeY6QuNg_6VeKK1DZ/s1600/commonCathode.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="366" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj4w-FSIjSf9VMiCiCC9s-IvIVvYqbKfDhOB22w0-_ICUidb6xIpX7_nq2Hi1bxSm9RyiNMNTZs8ItMJ7G6E_Uc4St57lUQfZMkQ4ugTBKAMx0iE8aGOwZkRltMGvVeY6QuNg_6VeKK1DZ/s640/commonCathode.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
The diodes are arranged so that for each digit, <b>DIG.1, DIG.2, DIG.3</b> and <b>DIG.4</b>, the cathodes are all connected together (to <b>pin 12</b> for <b>DIG.1</b>, <b>pin 9</b> for <b>DIG.2</b> etc). Using wiring paths in this way, ie the same wires doing different things depending on the software logic, is known as <b><i>multiplexing</i></b>.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here is the wiring diagram for the Common Cathode display:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_foEr8mmgC26rzUAtAesrQml-B5ruwRkqy6YB67_Zf9GQ5hDqtzY3j0zuEpoYCpDLWRikJqIb4U88zKP8NrWSLai3BQru87RydkMLTHPUR6vY054VP097NMZ9btA1GZ7JPM4WldTfx9UI/s1600/4dig7segCommonCathode.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_foEr8mmgC26rzUAtAesrQml-B5ruwRkqy6YB67_Zf9GQ5hDqtzY3j0zuEpoYCpDLWRikJqIb4U88zKP8NrWSLai3BQru87RydkMLTHPUR6vY054VP097NMZ9btA1GZ7JPM4WldTfx9UI/s640/4dig7segCommonCathode.jpg" width="556" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h2 style="clear: both; text-align: left;">
Common Anode</h2>
<div class="separator" style="clear: both; text-align: left;">
The COMMON ANODE one looks like this:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaLpUYrWKBK1FDMOwa7zmK7AR_qakD5mrmig9XdGVxBxMPcT5pL82o9yV5XUcD8ubQ-N58E3PhYWhusfRhU_H7Z9b-_sfUA2hTRTVgjOjXMCHTq2wZGpG-eW6Q8R9_Xfsrk5RAAZ17_49C/s1600/Untitled-2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaLpUYrWKBK1FDMOwa7zmK7AR_qakD5mrmig9XdGVxBxMPcT5pL82o9yV5XUcD8ubQ-N58E3PhYWhusfRhU_H7Z9b-_sfUA2hTRTVgjOjXMCHTq2wZGpG-eW6Q8R9_Xfsrk5RAAZ17_49C/s400/Untitled-2.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaAX5CBoCi19g_18HE6F15WIV1NYCnZpnnCbHRWbbigo4-NbXHgjpc8n9ThX0BxHEDsxgo0IIvvQdKexB9PWG5L2QwgUF6PE4KUP0dlRibmAtZ0lgy5Q03RO1hnGelnV0z5jC17PBvSm0J/s640/4x7Pinout.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaAX5CBoCi19g_18HE6F15WIV1NYCnZpnnCbHRWbbigo4-NbXHgjpc8n9ThX0BxHEDsxgo0IIvvQdKexB9PWG5L2QwgUF6PE4KUP0dlRibmAtZ0lgy5Q03RO1hnGelnV0z5jC17PBvSm0J/s640/4x7Pinout.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Notice that the diodes are pointing from anodes which are common for each digit's 7 segments and decimal point, <b>DP1, DP2, DP3</b> and <b>DP4</b>. Also notice that there is a colon (<b>L1</b> and <b>L2</b>) and an apostrophe (<b>L3</b>), but they aren't used here.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's my COMMON ANODE display connected to my <b>Raspberry Pi 2</b>:</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Drlb2Lo0sxaKbOYdvdbYAmN2fSFWi9Kyeym6u7Ix54pEljthvy9_klDQa2vB8RPkYIFe5K7u3u5u_i_Uf6FDlOx8If1vhv92litO6CzX3fPOthA8vMiHIqtI626LHl5eIW1R24i49T4F/s1600/PB213848.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Drlb2Lo0sxaKbOYdvdbYAmN2fSFWi9Kyeym6u7Ix54pEljthvy9_klDQa2vB8RPkYIFe5K7u3u5u_i_Uf6FDlOx8If1vhv92litO6CzX3fPOthA8vMiHIqtI626LHl5eIW1R24i49T4F/s640/PB213848.JPG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
You can just about see my black mini-breadboard with the resistors (this time 8x 680 Ω).</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's a video:</div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="360" mozallowfullscreen="" src="https://player.vimeo.com/video/146533473" webkitallowfullscreen="" width="640"></iframe> <br />
<a href="https://vimeo.com/146533473">PB213849</a> from <a href="https://vimeo.com/user25118189"></a><a href="https://vimeo.com/">Vimeo</a>.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's the code for the COMMON ANODE setup:</div>
<script src="https://gist.github.com/kcranley1/b586e73654d96a4971ce.js"></script>
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Notice that a few changes have been made, mostly changing 0's to 1's and 1's to 0's. You'll see on Alex's post that I asked him for advice in doing this part, and he kindly responded and put me on the right track. Thanks again Alex!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's the wiring diagram for the Common Anode Display:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdZWWBCYg-MkzIUqwGjaLoObNduTvZ7IdfhCivqQqnw7Amzf3adu8ttSM5fu0omnIebaF2QUTek8iw8qbyfPnaSiWLarvBe1iEDiFHuu9lvt6b6Vz3DbRJyZmnG0Q5cwiRdQnUAM8qYfRJ/s1600/4dig7segCommonAnode.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdZWWBCYg-MkzIUqwGjaLoObNduTvZ7IdfhCivqQqnw7Amzf3adu8ttSM5fu0omnIebaF2QUTek8iw8qbyfPnaSiWLarvBe1iEDiFHuu9lvt6b6Vz3DbRJyZmnG0Q5cwiRdQnUAM8qYfRJ/s640/4dig7segCommonAnode.jpg" width="542" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
And here is the Common Anode Display wired through the RasPiO Duino. The Duino doesn't have anything to do with the 4-digit, 7-segment LED Display, but in fact it is running a sketch which is driving a darkness-enabled mood lamp (see the mood lamp made <b><a href="http://smokespark.blogspot.co.uk/2013/10/36-4-digit-7-segment-led.html" target="_blank">HERE</a> </b>previously):</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcc3T7OF5IBdFvwz8ebzr_8udaYKw400bNLTkGcg-PB9bIzIsaja9CItQW0z4UHt03381NDdW5s-5X5_3kCEY7fgt_ZfTP5rvN4zw8WKb5ewpsPAfGAaH0SUK2U2jl45G0dULIzItzdlM1/s1600/4dig7segThruRasPiODuinoAndMood.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="462" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcc3T7OF5IBdFvwz8ebzr_8udaYKw400bNLTkGcg-PB9bIzIsaja9CItQW0z4UHt03381NDdW5s-5X5_3kCEY7fgt_ZfTP5rvN4zw8WKb5ewpsPAfGAaH0SUK2U2jl45G0dULIzItzdlM1/s640/4dig7segThruRasPiODuinoAndMood.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Here's a video of this circuit working:</div>
<iframe allowfullscreen="" frameborder="0" height="360" mozallowfullscreen="" src="https://player.vimeo.com/video/147098604" webkitallowfullscreen="" width="640"></iframe> <br />
<a href="https://vimeo.com/147098604">PB233854</a> from <a href="https://vimeo.com/user25118189"></a><a href="https://vimeo.com/">Vimeo</a>.<br />
<div class="separator" style="clear: both; text-align: left;">
The next step I want to make is to drive the LED Display with the Duino, which hopefully will be getting the time information from the internet via the Raspberry Pi. Watch this space!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-83168290081930377062015-10-01T11:38:00.002+01:002015-10-13T07:34:26.924+01:0069. The Sense HAT's Inertial Measurement Unit<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">45,000 page views!!</b><br />
I described this <b>HAT</b> (Hardware Attached on Top) for the <b>Raspberry Pi</b> a couple of posts ago (<b><a href="http://smokespark.blogspot.co.uk/2015/09/67-sense-hat.html" target="_blank">HERE</a></b>). Among its many goodies are a <b>gyroscope</b>, which measures momentum and rotation, an <b>accelerometer</b> which measures acceleration forces including that due to gravity, and a <b>magnetometer</b>, which measures the earth's magnetic field. <br />
<br />
These three sensors make up what is collectively described as an Inertial Measurement Unit (<b>IMU</b>). I have described the operation of the <b>IMU</b> in a previous post (<b>No 53</b> <b><a href="http://smokespark.blogspot.co.uk/2014/05/53-robotics-gyroscope-accelerometer.html" target="_blank">HERE</a></b>). Three orthogonal axes are chosen, and rotational directions around these axes are known as <b>roll</b>, <b>pitch</b> and <b>yaw</b>. Here is an illustration of the <b>roll</b>, <b>pitch</b> and <b>yaw</b> rotations of the Pi with the <b>HAT</b> fitted:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzfGo5LAmTOjjMRgFpaENIWVQCRK1WERsH1uydpGUbPERRUevY5uWfbRr0MbuyuNv6ZFzRdRv-pOVqYOwXIT2M2ieuOHW_KUKxFFAdRWxFHkkrOBQtzMnoRL93O6FjXDr5ZlEol9uVxq_B/s1600/PiAxes.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="448" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzfGo5LAmTOjjMRgFpaENIWVQCRK1WERsH1uydpGUbPERRUevY5uWfbRr0MbuyuNv6ZFzRdRv-pOVqYOwXIT2M2ieuOHW_KUKxFFAdRWxFHkkrOBQtzMnoRL93O6FjXDr5ZlEol9uVxq_B/s640/PiAxes.jpg" width="640" /></a></div>
<br />
To further illustrate this, take as an example an aircraft, where <b>roll</b> describes the rotation about the direction of travel. For example, when the wings go up on one side and down on the other: <b>pitch</b> is the motion when the nose of the plane goes up or down, and <b>yaw</b> describes a left or right turn. They are the three orthogonal axes about which rotation of any object can be made, and combined rotations around all three axes give all the possible orientations that any body can have. Here's a useful video to describe this:<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="360" src="https://www.youtube.com/embed/pQ24NtnaLl8" width="640"></iframe>
<br />
<br />
So when the <b>Raspberry Pi</b> with its <b>HAT</b> on is tilted in various directions, the <b>IMU</b> can detect this and send the orientation data to the <b>Raspberry Pi</b> which can run software to represent this on a display. <br />
<br />
I wrote a little <b>Python</b> script to make use of the <b>8 x 8 RGB LED</b> display to indicate two of the rotations, <b>pitch</b> and <b>roll</b>. Trying to represent <b>yaw</b> as well as <b>pitch</b> and <b>roll</b> on a 2D display is too difficult! Here's the video:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dz9uj3SG-UhJM44BG97Hgsp-6M_NYChI5tck7ZhgE3k-a188iLzPK36YnYjIs7A1Ija9qps7HgZ-07FosL_Pg' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
You can see that my <b>Pi 2B </b>has the <b style="color: #222222; line-height: 26px;">Raspberry Pi Camera Board</b> attached, even though that's not needed for this project. <br />
<div>
<br /></div>
Here's my code:<br />
<br />
<script src="https://gist.github.com/kcranley1/13e4cec1a141cb51d642.js"></script>
While I was at it, I thought I would load up the <b>3D Apollo-Soyuz Demo</b>, and it works well. Here's the video (watch out for my thumb!):<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dzSdJxc7eV8Ep9016mCuIcnFBPsyy_touj9vG8kQ9lT-FUNhPfI7oytl0wC1J44ZJSRPxKwcWVK-IMRotSwVQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
You will have seen that I also have the <b>8 x 8 RGB LED</b> array lit up, even though this also is not part of this project. <br />
<br />
At the later part of the above video, I used the keyboard key " <b>= </b>"<b> </b>to rotate (<b>yaw</b>) the spacecraft in a clockwise direction. I could equally have used the " <b>-</b> " key to offset the <b>yaw</b> of the spacecraft in a counter-clockwise dire<span style="font-family: Times, Times New Roman, serif;">cti</span>on. Other keys that can be used are " <b>a</b> " which will toggle the <b>accelerometer</b> on and off, " <b>g</b> " to toggle the <b>gyroscope</b> on and off, and " <b>m</b> " to toggle the <b>magnetometer</b> on and off. See how this facility is included in the code below (lines 62 to 74) by <b>Ben Nuttall</b> of the <b>Raspberry Pi Foundation</b>:<br />
<script src="https://gist.github.com/kcranley1/f27cd012ec708ec31023.js"></script>The code uses a file <a class="js-directory-link js-navigation-open" href="https://github.com/kcranley1/apollo-soyuz/blob/master/apollo-soyuz.obj" id="a0b426fc4346ff5293fc8f50bd990b00-c9f37bdccc4d3ee67e47c27a1dc0143ce60839ff" style="background-color: whitesmoke; box-sizing: border-box; color: #4078c0; line-height: 20px; outline: 0px; white-space: nowrap;" title="apollo-soyuz.obj"><span style="font-family: Times, Times New Roman, serif;">apollo-soyuz.obj</span></a> which has all the necessary details of the spacecraft model to generate the display. Apparently it's possible to use <a href="http://www.sketchup.com/" target="_blank"><b>Sketchup</b></a> or <b><a href="https://www.blender.org/about/" target="_blank">Blender</a></b> to make models and use them like this. I must have a go at that!<br />
<br />
Here is a depiction of the 1975 spacecraft of the first joint Soviet-USA space flight - <b>Apollo </b>/<b>Soyuz </b> (and also the last <b>Apollo</b> mission, the <b>Space Shuttle</b> taking over after that):<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8nQOsPWIo9NNc_jp1XS-QA1rUKN96lyKUL2HieGJmkNmzbIGDGeIprRnmyGQ7tKBFPahFWSsvPT04Dp_s2vL8mGUDwaOzF8k3Q8iN0HREFHz6blgXxm9ROWeTLLvM-4C9AWVnzzEa1Kf3/s1600/ApolloSoyuz.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="368" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8nQOsPWIo9NNc_jp1XS-QA1rUKN96lyKUL2HieGJmkNmzbIGDGeIprRnmyGQ7tKBFPahFWSsvPT04Dp_s2vL8mGUDwaOzF8k3Q8iN0HREFHz6blgXxm9ROWeTLLvM-4C9AWVnzzEa1Kf3/s640/ApolloSoyuz.jpg" width="640" /></a></div>
<br />
Note that the diagram refers to <b>Apollo 18</b>. <b>Apollo 18</b> was actually cancelled, and in this joint mission it was simply referred to as <b>Apollo</b>. This <b>Apollo-Soyuz Test Project</b> was successful, but <b>Apollo </b>got into a spot of bother on re-entry. You can read about it <b><a href="https://en.wikipedia.org/wiki/Apollo%E2%80%93Soyuz_Test_Project" target="_blank">HERE</a></b>.<br />
<br />
The <b>3D Apollo-Soyuz Demo</b> is supplied as part of the <b>Sense HAT</b> (<b>Astro Pi</b>) software repository on <b>GitHub</b>. See <b><a href="https://github.com/raspberrypilearning/astro-pi-guide/blob/master/sensors/movement.md" target="_blank">HERE</a></b>.<br />
<br />
Thanks Ben!S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-68913732924538698502015-09-10T11:39:00.003+01:002015-10-01T14:38:43.397+01:0068. The RasPiO Duino HAT<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">44,000 page views!!</b><br />
Here's the previously-mentioned <b>HAT</b> (Hardware Attached on Top) that has been developed by Alex Eames of <a href="http://raspi.tv/">RasPi.TV</a> and <a href="http://rasp.io/">RasP.iO</a>. This comes as a kit which is easy to solder together. The aim with this was to make it easy to carry out <b>Arduino</b> programming on the <b>Raspberry Pi</b>. So the scripts are in the <b>Arduino</b> language and are run on the built-in <i><b>Atmel ATMEGA328P-PU</b></i> (ie an <b>Arduino</b>) chip. <br />
<br />
Having uploaded the <b>Arduino</b> sketch on the <b>Arduino IDE</b> from the <b>Raspberry Pi</b>, from that point on, the <b>Pi</b> itself does nothing more than supply power to the <b>Arduino</b>, although having said that, you could conceivably have <b>Pi </b>software that interacts with the <b>Arduino</b>, or even does something completely different. <br />
<br />
Depending on the software that you write, the hat could be removed and all it would need then would be power to continue running the sketch. For £14 (delivered) within the UK, it represents great value.<br />
<br />
There is an extremely clearly written e-book (<b><i>Learning Arduino Programming with RasPiO Duino</i></b>) available <b><a href="http://rasp.io/wp-content/uploads/2015/04/raspio-duino.pdf" target="_blank">HERE</a>. </b>The book brings you from the very simple Blink sketch right up to using the analog inputs for fading LEDs using pulse-width modulation (<b>PWM</b>) and taking advantage of the eye-brain system's persistence of vision |(<b>POV</b>), previously explained in my post 15 <b><a href="http://smokespark.blogspot.co.uk/2013/04/15-programming-attiny85-with.html" target="_blank">HERE</a>.</b><br />
<br />
The sketch I am demonstrating is almost identical to my <b><i>ATTiny85</i></b> code which I used in that post, which came originally from <b>Instructables.com</b> <b><a href="http://www.instructables.com/id/ATtiny85-Mini-RGB-Mood-Light/" target="_blank">HERE</a></b>.<br />
<br />
Here's a picture of the <b>RasPiO Duino</b> hat mounted on my <b>Raspberry Pi B+</b>:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1OILcBK9lXBTg5RhZqCvOitjjoBNAkACqwYyjUisOX6aj1i1Z0eDTOa_mKY8p2GSbatgB1DniI5Fl_VUqGsGIIKl88B3DB1HIwXg29eNDBEUm0F6vzUDuqQA9Rl48R0rPvBwIZqlMd8Yb/s1600/P9103731.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1OILcBK9lXBTg5RhZqCvOitjjoBNAkACqwYyjUisOX6aj1i1Z0eDTOa_mKY8p2GSbatgB1DniI5Fl_VUqGsGIIKl88B3DB1HIwXg29eNDBEUm0F6vzUDuqQA9Rl48R0rPvBwIZqlMd8Yb/s640/P9103731.JPG" width="640" /></a></div>
You can see that I have made use of the <b>RasPiO Duino's</b> prototyping area (with lots of holes) to make connections to the <b>RGB LED</b> common cathode to <b>GND</b> and the red, green and blue anodes to the <b>Arduino</b> pins 11, 10 and 9, through 330<span style="background-color: #fff9ee; color: #222222; font-family: Verdana; font-size: 15.4px; line-height: 21.56px;">Ω</span> resistors, on the blue mini-breadboard. Instead of using the mini-breadboard, the <b>RasPiO Duino's</b> prototyping area could have been used instead.<br />
<br />
There's also a light dependent resistor (<b>LDR</b>) shown at the bottom centre, connected in series with a 10k<span style="background-color: #fff9ee; color: #222222; font-family: Verdana; font-size: 15.4px; line-height: 21.56px;">Ω</span> resistor to <b>GND</b> at one end, and <b>Arduino</b> pin 3 at the other end. In the above picture, the <b>RGB LED</b> is hidden under a light diffuser (A draft Guinness can widget). I also keep a 2 inch length of heat shrink over the <b>LDR</b> so that I can see the mood lamp working during the daylight hours.<br />
<br />
The idea is of course, to program, through the <b>Raspberry Pi</b>, the <b>Arduino</b> chip, as a night-time mood lamp, cycling through all the colours in turn, provided there is minimal light reaching the<b> LDR</b>.<br />
<br />
Here's a video where all is revealed:<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dxYqJowotKGmSIHt6qKmMHBOmHr42ilKCDot0YYedvpGUdYnoaT538sDYr42c0fKg8FNFUjRm5DsSHHgAzCNQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
and here's the code:<br />
<br />
<script src="https://gist.github.com/kcranley1/a8324654712a13745981.js"></script>
Must say, I do love mood lamps. Thanks Instructibles.com, and thanks Alex.S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-74002793920045120962015-09-09T16:36:00.002+01:002015-10-01T13:27:10.814+01:0067. The Sense HAT (Hardware Attached on Top)<b>HAT</b>s (Hardware Attached on Top) are the latest thing for the <b>Raspberry P</b>i. They are units of circuitry that neatly attach on to the Pi's 40 <b>GPIO</b> pins, which not only give very good mechanical stability, but also allows the relevant pins to be connected. The last <b>HAT</b> I got was the <b>RasPiO Duino</b> by Alex Eames (see <b><i>http://rasp.io/</i></b>). It's a great piece of equipment which came as a kit, but is very easy to solder together. There will be more about that later!<br />
<br />
In the meantime, I'm on the learning curve for the <b>Sense HAT</b>, by the <b>Raspberry Pi Foundation</b> itself. There's a whole story about this, available <b><a href="https://www.raspberrypi.org/blog/astro-pi-tech-specs/" target="_blank">HERE</a>,</b> so I'll not say much more than that it's the heart of the <b>Astro Pi</b> unit, two of which Tim Peake, UK astronaut, will be taking into space on the <b>International Space Station</b> at the end of this year. So I just <b>had</b> to get one! (only £24.50 including delivery).<br />
<br />
The <b>Sense HAT</b> has a number of<span style="font-family: inherit;"> <span style="background-color: white; color: #222222; line-height: 26px;">goodies as follows:</span></span><br />
<br />
<ul>
<li><span style="background-color: white; color: #222222; font-family: inherit; line-height: 26px;">a 3DoF (degrees of freedom) Accelerometer, a 3 DoF Gyroscope and a 3 DoF Magnetometer</span></li>
<li><span style="background-color: white; color: #222222; font-family: inherit; line-height: 26px;">a Temperature and Barometric Pressure sensor</span></li>
<li><span style="background-color: white; color: #222222; font-family: inherit; line-height: 26px;">a Relative Humidity and Temperature sensor</span></li>
<li><span style="background-color: white; color: #222222; font-family: inherit; line-height: 26px;">a 5-button miniature joystick</span></li>
<li><span style="background-color: white; color: #222222; font-family: inherit; line-height: 26px;">a slot which allows the <b>Raspberry Pi Camera Board</b> to be connected simultaneously</span></li>
<li><span style="background-color: white; color: #222222; font-family: inherit; line-height: 26px;">an <b>8 x 8 RGB LED array</b> (nearly 200 LEDs!)</span></li>
<li><span style="font-family: inherit;"><span style="background-color: white; color: #222222; line-height: 26px;">an<span style="font-family: inherit;"> </span></span></span><span style="background-color: white; color: #222222; line-height: 26px;"><span style="font-family: inherit;"><b>Atmel ATTINY88</b> micro controller unit (not re-programmable)</span></span></li>
</ul>
<br />
<span style="background-color: white; color: #222222; line-height: 26px;"><span style="font-family: inherit;">With the <b>Python API</b> and lots of documentation and code on <b>GitHub</b>, there's a wealth of stuff to be getting on with. The mind just boggles with the possibilities of this machine!</span></span><br />
<span style="color: #222222;"><span style="background-color: white; line-height: 26px;">Here's mine mounted on my <b>Pi 2B</b>, with my <b>Raspberry Pi Camera Board</b> also connected:</span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWrtzoMj5nljAyVixXHjzZsu1L_OqEXc0X4yG-csoqUBn3Plf-GjJqt9Z_O-kmre_COkYv-Yy77-REv0FayEUIT4VXbRA5dvNV8pRq4nP_vYvVC2Vlb7KDAZ94peIKVr7j7UIK7EwnVpYj/s1600/P9093729.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWrtzoMj5nljAyVixXHjzZsu1L_OqEXc0X4yG-csoqUBn3Plf-GjJqt9Z_O-kmre_COkYv-Yy77-REv0FayEUIT4VXbRA5dvNV8pRq4nP_vYvVC2Vlb7KDAZ94peIKVr7j7UIK7EwnVpYj/s640/P9093729.JPG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;">The <b>Sense Hat</b> mounted on a <b>Pi 2</b> connected to monitor, WiFi, wireless keyboard and mouse, with the <b>RasPiCam</b> on top</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
The LEDs are actually displaying a multi-coloured display from <b><i>rainbow.py</i></b>. It's difficult to get the exposure right with such bright LEDs - they all come out almost white. There are a number of <b>Python</b> test scripts which can put the various sensors and input/output devices through their paces. Here's a video of my version of the <b><i>astro_cam.py</i></b> script running:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dwEMm0Pdsk8HqhTVxq2R1QayiiHHHNB14DoSRrejT8rqjje7DH9VCtILyeH_SF9fG_UMJieRP1XROyrkTztAw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
The video shows a white square outline surrounded by black, which I made on <b>MS Excel</b> and converted into a <b>jpg</b>. The <b>PiCam</b> "sees" the pattern on my PC monitor, and the software converts it into an 8 x 8 array of pixels, displayed on the <b>64 RGB LED</b> array, but also on the <b>Pi</b>'s monitor, so that I can see what the <b>PiCam</b> sees.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
There are a couple of things to note here - firstly the LED array image is not square, but squashed vertically into a rectangle. This must be because of the viewing angle. The other thing to note is that it's the top left of the image that is displayed. This can no doubt be changed in the software. Additionally, the output picture on the Pi's monitor is pulsating. This seems to happen in <b><i>camera.start_preview() </i></b>mode, the zoom appearing to vary with each pulse. This could be an explanation of the squashed rectangle LED image, if that is truly what the <b>PiCam</b> sees.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here's the <b><i>Python</i></b> script:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<script src="https://gist.github.com/kcranley1/8cc68c3cf099e0194ce4.js"></script></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<span style="color: #222222;"><span style="background-color: white; line-height: 26px;">To illustrate the ability of this system to reproduce colour, here is an example where the <b>Raspberry Pi'</b>s startup image is reproduced:</span></span><br />
<span style="color: #222222;"><span style="background-color: white; line-height: 26px;">
<table style="width: 100%;">
<tbody>
<tr>
<td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQAzLHxMnT_h1zI68G6d20W8vl_oDurXie3cyWNow5mQA697nkwUFxpoheDcHkqNIqqXlkE7oxJFZJ7YWNWxSxPrrbpZYAXcGxWtdMa8vy4y1slwHplPjm1ThDrriCP-j_lhuu7GxvIQFB/s1600/P9083726.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="264" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQAzLHxMnT_h1zI68G6d20W8vl_oDurXie3cyWNow5mQA697nkwUFxpoheDcHkqNIqqXlkE7oxJFZJ7YWNWxSxPrrbpZYAXcGxWtdMa8vy4y1slwHplPjm1ThDrriCP-j_lhuu7GxvIQFB/s320/P9083726.JPG" width="347" /></a></td>
<td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJlFyH_bGaWBRsENQNldcCm560GhGDegp4EtjZYz7TO3ZnzGhlN5vuK7jSewioogkmRYn7Vq58zADAai9NuvJWlE04-h1diCegXjBZJRXDb0ocg5JHMpVzKkEI8OynsU-mm75mUu6mczyy/s1600/P9083725.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="264" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJlFyH_bGaWBRsENQNldcCm560GhGDegp4EtjZYz7TO3ZnzGhlN5vuK7jSewioogkmRYn7Vq58zADAai9NuvJWlE04-h1diCegXjBZJRXDb0ocg5JHMpVzKkEI8OynsU-mm75mUu6mczyy/s320/P9083725.JPG" width="347" /></a></td>
</tr>
</tbody></table>
</span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div align="right">
</div>
<div class="separator" style="clear: both; text-align: right;">
</div>
<div class="separator" style="clear: both; text-align: left;">
As I said before, it's difficult to photograph the coloured LEDs so that the bright colours do not white-out. As viewed by the eye, the colours are much more convincing.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Other scripts I have tried so far include:</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>colour_cycle.py</i></b> - this cycles the colours for all the LED pixels at the same time (ie all the same)</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>conway.py</i></b> - a simple demonstration of the <b>Conway Game of Life</b></div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>env.py</i></b> - this script displays scrolling text showing the environmental readings for example, "Temperature = 36.2. Pressure = 1025.6. Humidity = 32.5"</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>eyes.py</i></b> - this is a simple animation of a pair of eyes</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>orientation.py</i></b> - gives a contiunous print oyt on the terminal of pitch, roll and yaw of the <b>Sense Hat</b></div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>press_letter.py</i></b> - outputs on the LED array, any letter or character entered on the keyboard</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>pygame_joystick.py</i></b> - indicates on the LED array, which of the positions the joystick has been moved</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>rainbow.py</i></b> - shows a beautiful animation of the colours of the rainbow moving across the array</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>random_sparkles.py</i></b> - makes each pixel independently and randomly change colour</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>rotating_letter.py</i></b> - makes a letter on the array and rotates it through 90 degree steps</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>rotation.py</i></b> - makes an alphanumeric character rotate</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>shake.py</i></b> - any movement of the Sense Hat causes an exclamation mark to be displayed on the array</div>
<div class="separator" style="clear: both; text-align: left;">
<b><i>text_scroll.py</i></b> - makes inverted text scroll on the array</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Most of these have been provided by <b>Ben Nuttall</b> of the <b>Raspberry Pi Foundation</b> - thanks Ben!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<span style="color: #222222;"><span style="background-color: white; line-height: 26px;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqCRGp-bRdKwavl61E45HpYCtnXNPqfUskWC4b1K0wps76kfQYW2PtazHbKgXwowvh4iK5pLttVhyphenhypheneeVeldnypKR37buWBaPA2MrXbr3VUsizY_vX-fsbggSGyzEeHao_jew1_6vp04uFI/s1600/P9083725.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqCRGp-bRdKwavl61E45HpYCtnXNPqfUskWC4b1K0wps76kfQYW2PtazHbKgXwowvh4iK5pLttVhyphenhypheneeVeldnypKR37buWBaPA2MrXbr3VUsizY_vX-fsbggSGyzEeHao_jew1_6vp04uFI/s1600/P9083725.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqCRGp-bRdKwavl61E45HpYCtnXNPqfUskWC4b1K0wps76kfQYW2PtazHbKgXwowvh4iK5pLttVhyphenhypheneeVeldnypKR37buWBaPA2MrXbr3VUsizY_vX-fsbggSGyzEeHao_jew1_6vp04uFI/s1600/P9083725.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a></div>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-4200903902946653892015-05-01T13:03:00.000+01:002015-09-10T16:08:31.679+01:0066. A Graphical User Interface, written in Python, for use with the Raspberry Pi Camera<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">42,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In the course of investigating the Pi's GPIO ports and also python Graphical User Interfaces (GUI), I thought I would re-visit the Raspberry Pi camera and see how I could exploit the software attributes of this magnificent piece of hardware, and include GPIO control at the same time.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here is the physical setup:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_D7SpjoNiW7GB2eJxAboa8lHRzLOCn3EqEbSYmUSTPdYInVQJswhk4kEuOhq1Y48vFZsi1xEvILCtRVi1W7CuKqEYsz6ccILE7fGLnuKg8nNYTI1Zg7K5vV_P41J9-Lc5UPTmxBTFLjpY/s1600/P5012553.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_D7SpjoNiW7GB2eJxAboa8lHRzLOCn3EqEbSYmUSTPdYInVQJswhk4kEuOhq1Y48vFZsi1xEvILCtRVi1W7CuKqEYsz6ccILE7fGLnuKg8nNYTI1Zg7K5vV_P41J9-Lc5UPTmxBTFLjpY/s1600/P5012553.JPG" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;">As you can see, the <b><i>Raspberry Pi Camera Module</i></b> is connected through the <a href="http://shop.pimoroni.com/products/pibow-coupe" target="_blank"><b><i>Pimoroni</i></b></a> </span><span style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"><b><i>Pibow Coupé Flotilla case</i></b> </span><span style="font-family: Arial, Helvetica, sans-serif;">case to the <b><i>Pi 2</i></b>. The Pi's GPIO pins are connected to the </span><b style="color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 21.5599994659424px;"><i>Cyntech B+ 40-way Paddle Board</i></b><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 21.5599994659424px;"><i> </i></b><span style="font-family: Arial, Helvetica, sans-serif;">and from that, connections from GND and GPIO17 are made to a mini breadboard containing a mini push button switch.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here is a picture of the the GUI:</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9jlbAkH98rIDdufhLH3t6w_cHTazh9wnnaa6U-x5IPDHB31k0QBO2ARseUwJ30k4yH4dauq1IXpRR1y4VMuULnDHly8j-HBwNbuuIPw-j0hyphenhyphenu6G4kH28D4m9Z8LrYSB681JFaa2g0eXw_/s1600/GUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9jlbAkH98rIDdufhLH3t6w_cHTazh9wnnaa6U-x5IPDHB31k0QBO2ARseUwJ30k4yH4dauq1IXpRR1y4VMuULnDHly8j-HBwNbuuIPw-j0hyphenhyphenu6G4kH28D4m9Z8LrYSB681JFaa2g0eXw_/s640/GUI.jpg" width="268" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">and here is a whole-screen shot:</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1bm2B6xthPsYETRfivCEFSQOrTc4kS4MVlqNbseNp7EpStuUNFzBIGrJcPod7myYTjdGiU1wxkbLZWnZyjxuLZZHAsLjZ2oksyQVNWZOqRtm5vQTfRpYJkZUPhcfanybNNtLjeGUQIWC3/s1600/P5012555a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="361" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1bm2B6xthPsYETRfivCEFSQOrTc4kS4MVlqNbseNp7EpStuUNFzBIGrJcPod7myYTjdGiU1wxkbLZWnZyjxuLZZHAsLjZ2oksyQVNWZOqRtm5vQTfRpYJkZUPhcfanybNNtLjeGUQIWC3/s1600/P5012555a.jpg" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><i>The sunflower seedling in the pot was the subject of a one week time lapse sequence of 2-hour delayed images, showing the birth of this seedling from a single seed. The sequence of images was very impressive, and I would have liked to show them here, but unfortunately I lost all the images! I'll try it again some time.</i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><i><br /></i></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In the meantime, here's an animated GIF of a time lapse sequence of an internet clock, taken at 60 second intervals:</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisjwlqcfJRb1vFsU7z-NNIzbFrZFFZ9E3zRHfSvcM-vPxjbhRKR5MfAyrH02OClF6fOabfbma1PFCpVoE7kJJ18puH5H-GYmCj2SnXPFCprrxaTnOcknAcfGHynsPbAaqhkRB7sLz7PaVj/s1600/images.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisjwlqcfJRb1vFsU7z-NNIzbFrZFFZ9E3zRHfSvcM-vPxjbhRKR5MfAyrH02OClF6fOabfbma1PFCpVoE7kJJ18puH5H-GYmCj2SnXPFCprrxaTnOcknAcfGHynsPbAaqhkRB7sLz7PaVj/s1600/images.gif" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><i>(I'm not sure what happened the alignment here - it looked nicely centred in the Preview).</i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><i><br /></i></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i>Here's a better one, taken at 30 minute intervals:</i></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnP3MO6im4IIKueR-UFGtuAQuiXjGIo91w9-FmzDyfsJaIsb4mfxq6NCXDueE2dsrZoDiPAA_lhou11iJU5c8XUxS3iolxcjrNqg7YQVBTNhzjV45afZ9vCYM9nu4CwFEK6HMEiv0GChi7/s1600/images.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnP3MO6im4IIKueR-UFGtuAQuiXjGIo91w9-FmzDyfsJaIsb4mfxq6NCXDueE2dsrZoDiPAA_lhou11iJU5c8XUxS3iolxcjrNqg7YQVBTNhzjV45afZ9vCYM9nu4CwFEK6HMEiv0GChi7/s1600/images.gif" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><i><br /></i></span>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">You can see from the second hand in both the above examples, that a small delay introduced by the software increases the set interval by approximately one second each exposure.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here is a shot where one example of the 22 available (including '<b><i>none</i></b>') image effects - '<b><i>negative</i></b>' - has been set:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPD4q0BZ4wbxd9YWEOq-HInHgOuNxKPqCVPLkPNnSoUXpKHaeTkqpEXqx8y7D1wzSjSWP3ZXmvoX2fh8eqPn36ADpW0AxlBVglCxpM9CY5DctXXQ4xFSsAkPVz8FflAXRR8Qu3y13CCBFn/s1600/P5012557.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="366" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPD4q0BZ4wbxd9YWEOq-HInHgOuNxKPqCVPLkPNnSoUXpKHaeTkqpEXqx8y7D1wzSjSWP3ZXmvoX2fh8eqPn36ADpW0AxlBVglCxpM9CY5DctXXQ4xFSsAkPVz8FflAXRR8Qu3y13CCBFn/s1600/P5012557.jpg" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can see that on the left of the screen, there is an indication (in the <b>LXTerminal</b>) of values of such things as Brightness, Contrast, Saturation, Image Effect etc.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The "<b><i>Set favourites</i></b>" button returns all attributes (except Brightness, Contrast and Saturation) to their initial settings.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The "<b><i>Demo</i></b>" button starts a routine where the automatic white balance (<b>awb</b>) is changed for each 3-second preview, right through all 10 of the available effects (including "<b>auto</b>" and "<b>off</b>"). However, these <b><i>camera.image_effect</i></b> attributes do not seem to be operational currently, at least they don't seem to have any noticeable effect.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The "<b><i>Quit</i></b>" button cleanly exits the program, but only after any currently running routine has finished. For example, the program would wait until a time lapse sequence would run through to the end before it terminates.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In addition to buttons in the GUI, I added some sliders, for Brightness, Contrast and Colour Saturation. There is an additional slider at the bottom for setting the delay in seconds for time lapse sequences. The maximum time lapse interval I have set is 7200, for 2-hour intervals. This maximum time of course can be changed in the code.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The breadboard pushbutton is used for the "<b><i>Take still</i></b>" and "<b><i>Take video</i></b>" modes. It is pushed to take a single still picture, with the settings displayed. For recording video, the button is pressed once to start the video exposure, and then pressed again to finish the video sequence. When the program is expecting a button push, it prints the message "<b><i>Press the Button!</i></b>" in the <b>LXTerminal</b> on the left of the screen.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The program uses the <b><i>Tkinter</i></b> library to draw the GUI elements such as buttons and sliders etc. The <b><i>picamera</i></b> library is invoked for using all the imaging attributes such as <b><i>camera.brightness</i></b> and so on. <b><i>RPi.GPIO</i></b> of course is imported as the <b>GPIO17</b> port is used for the pushbutton.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">One nice little addition is the "<b><i>LED</i></b>" button which toggles the Camera Module's red LED on and off. </span><span style="font-family: Arial, Helvetica, sans-serif;">I used the statements <b><i>camera.led = False</i></b> and </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>camera.led = True</i></b><span style="font-family: Arial, Helvetica, sans-serif;">.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Finally you will see near the bottom of the GUI shown above, that there is a <b>Motion detect</b> button, followed by a slider labelled <b>Threshold %</b>. The slider allows values between 1.5 and 2.5 per cent to be chosen. The percentage refers to that of the image pixels which have to change before motion is considered to have been detected. The button starts the motion detection part of the program. The initial setting at line 20 of the code:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="background-color: white; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;">20 threshPercent</span><span class="pl-k" style="background-color: white; color: #a71d5d; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;">=</span><span class="pl-c1" style="background-color: white; color: #0086b3; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;">1.8</span><span style="background-color: white; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;"> </span><span class="pl-c" style="background-color: white; color: #969896; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;">#This value is close to ideal for most cases</span><br />
<span class="pl-c" style="background-color: white; color: #969896; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">is 1.8 per cent, which is useful for detecting significant motion, without filling the Pi's SD card with hundreds of images.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Later I added the ability to zoom in on images, which works quite well, except I haven't found a way to centre the image after zooming,</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I also added to my Pi Camera board, a zoom lens. This gives reasonable magnification, but the image quality is a little disappointing. I haven't got to the bottom of this yet, but here's an animated GIF image taken through the zoom lens and with motion detection::</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdnRHTWwKQAYXOGEhPiUpPHEIUWOgR6ZUAcLeZQvCDf-9rOSRhvnjpj5caBP9jIhVS16ohTkRq02bS3xVC1w_FNBnGt70oOdMeokefzeWJLLLHCazH6i1viA82eNIzyhK2kifXKc0JXdD3/s1600/MotionPics.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdnRHTWwKQAYXOGEhPiUpPHEIUWOgR6ZUAcLeZQvCDf-9rOSRhvnjpj5caBP9jIhVS16ohTkRq02bS3xVC1w_FNBnGt70oOdMeokefzeWJLLLHCazH6i1viA82eNIzyhK2kifXKc0JXdD3/s320/MotionPics.gif" width="320" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;">Here are a couple of pictures of my 8 x </span><span style="font-family: Arial, Helvetica, sans-serif;">zoom</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">clip-on lens mounted on the Raspberry Pi Camera Board:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgDa7PD1D04OKAPfqsmXQ9SMstKFOZr8mopm8YNkWbPgP09v7Voi3i1olykQLdIglbCgYMsRVRPCfUWenP7K0L5T5Ks_b85KCidZGqd7zfQGlzQeVQwbVqnxnVoJxyvD4LN-m7kjrwu1_m/s1600/P7263380.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgDa7PD1D04OKAPfqsmXQ9SMstKFOZr8mopm8YNkWbPgP09v7Voi3i1olykQLdIglbCgYMsRVRPCfUWenP7K0L5T5Ks_b85KCidZGqd7zfQGlzQeVQwbVqnxnVoJxyvD4LN-m7kjrwu1_m/s320/P7263380.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQFU3NmJ_iBmMbf3xJBxyHAf77nSYKXOjAMp7mIzP4nRN1BHWi-dUnohj6Q74KIv0Eq_ulfyrElG_cxIf812xgmDZuESqyYECV2wxYruVZaHTd3Wor0v4fZEZJWgtLM9cygnASMUQKdQYq/s1600/P7263379.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQFU3NmJ_iBmMbf3xJBxyHAf77nSYKXOjAMp7mIzP4nRN1BHWi-dUnohj6Q74KIv0Eq_ulfyrElG_cxIf812xgmDZuESqyYECV2wxYruVZaHTd3Wor0v4fZEZJWgtLM9cygnASMUQKdQYq/s320/P7263379.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">You can see in the first picture, the zoom lens clipped on to the camera board (and supported by a foil pie dish). You can also see that the camera LED is on. The second view shows the lens, Raspberry Pi in its case, and a push button mounted on a mini breadboard, through the </span><b style="color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"><i>Cyntech B+ 40-way Paddle Board</i></b><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"> (previously described in my </span><b style="color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;">Post 55</b><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"> at </span><a href="http://smokespark.blogspot.co.uk/2014/10/55-exploring-pis-gpio-ports.html" style="color: #888888; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px; text-decoration: none;" target="_blank">http://smokespark.blogspot.co.uk/2014/10/55-</a><span style="font-family: Arial, Helvetica, sans-serif;">. The push button is for taking still shots or for starting and ending video recordings.</span> <span style="font-family: Arial, Helvetica, sans-serif;">(You can just about see out through the window, a couple of garden birds on my peanut bird feeder).</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />Here's the Python code:</span><br />
<br />
<script src="https://gist.github.com/kcranley1/3bd43a3c6aeb3ac0804e.js"></script><span style="font-family: Arial, Helvetica, sans-serif;">
I will continue to develop this as there are more <b><i>picamera.PiCamera() </i></b>attributes that can be built in to this program. Keep watching this space!</span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-78823257497778407832015-04-06T12:31:00.002+01:002015-04-07T11:56:00.155+01:0065. Driving Charlieplexed LEDs with the Raspberry Pi<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">33,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Do you remember a couple of years ago, when I built a set of Charlieplexed LEDs? Here's the post:<a href="http://smokespark.blogspot.co.uk/2013/08/32-charlieplexing-4-x-3-led-array.html" target="_blank">http://smokespark.blogspot.co.uk/2013/08/32-charlieplexing-4-x-3-led-array.html</a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">I was driving them with an <b>Arduino</b> and I thought I would try it with the Pi, as I'm on an exploration of the Pi's GPIO capabilities.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's a video of the result:</span><br />
<iframe allowfullscreen="" frameborder="0" height="354" mozallowfullscreen="" src="https://player.vimeo.com/video/124198896" webkitallowfullscreen="" width="630"></iframe>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">It's interesting that nothing is connected to <b>GND</b> - the four wires run to the four LED terminals from <b>GPIO18, GPIO23, GPIO24</b> and <b>GPIO25</b>. Current flows in different directions, depending on whether the software has set the ports to <b>INPUT</b> or <b>OUTPUT</b>, and if set to <b>OUTPUT</b>, whether that is set to <b>HIGH </b>or<b> LOW.</b>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">As I have recently been interested in Python Graphical User Interfaces (GUIs), I also wrote a GUI for this exercise. I have a grid of buttons, labelled <b>1</b> to <b>12</b>, each one controlling its own personal LED, and which turn red when the corresponding LED is on. So any one of the LEDs can be individually energised.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This also allows loops to be created, with sequences of lighting up the LEDs. I made two further buttons, <b><i>Loop - no delay</i></b> and <b><i>Loop - 0.1s delay</i></b>, which both light up each LED in turn, and then continue this loop for a pre-set number of iterations.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The iterations can have a delay after lighting each LED, and this delay can be made </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>zero</i></b><span style="font-family: Arial, Helvetica, sans-serif;">, so that the lighting sequence is carried out as fast as the Pi can manage it. With a zero delay, all the LEDs appear to light up together, albeit dimmer than one lit on its own, with only a slight flicker. This is how persistence of vision (POV) can be used to fool the brain into thinking that they are all illuminated at the same time. The image below shows all the buttons in my GUI, which include a </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>Clear</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> button, turning all the LEDs off, and a </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>Quit</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> button, which closes the program down properly:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinalZRo5ywQRRT9xJN6R_UJfoFDRmB3YTji8EePnTsGjdyEc7yICe4oS7CydqfdelzyuPx4Js5xmC_wzETS6BEXEypLrfLqJfUc9sUyimwfFCThixanPyWJVHJbjCZMgHosSGDCJpsbE3C/s1600/KCpic.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinalZRo5ywQRRT9xJN6R_UJfoFDRmB3YTji8EePnTsGjdyEc7yICe4oS7CydqfdelzyuPx4Js5xmC_wzETS6BEXEypLrfLqJfUc9sUyimwfFCThixanPyWJVHJbjCZMgHosSGDCJpsbE3C/s1600/KCpic.jpg" height="400" width="342" /></a> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">and here's a photo showing LED no 4 lit up as the GUI above indicates.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN1Fk36h0oDl5qboEyt0jQXEpH9BlHkoqOt89WqGptYlqmdvbEhxTuSEejxOPHfDH3A93bs1sndDM2SzMcoKHPlFl1VJU2F_a0dvkNTsdBlUeYs0WjNldUSTHWifLuZjQcx6XM_IT4jEC4/s1600/P4062491.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN1Fk36h0oDl5qboEyt0jQXEpH9BlHkoqOt89WqGptYlqmdvbEhxTuSEejxOPHfDH3A93bs1sndDM2SzMcoKHPlFl1VJU2F_a0dvkNTsdBlUeYs0WjNldUSTHWifLuZjQcx6XM_IT4jEC4/s1600/P4062491.JPG" height="480" width="640" /></span></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the code:</span><br />
<script src="https://gist.github.com/kcranley1/e475a38755e536bda8ec.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here is a reminder of how Charlieplexing works with a very simple example of 2 LEDs:</span><br />
<span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;">Pairs of <b>LEDs</b> are connected in <b><i>anti-parallel</i></b> (as opposed to parallel) and when the current is driven in one direction (<b>Pin 1</b> to <b>Pin 2</b> in the diagram below), one diode allows current to pass (<b>LED1</b> lights up) while <b>LED2</b> does not. Then when the current is reversed - ie from <b>Pin 2</b> to <b>Pin 1</b>, <b>LED1</b> does not allow current to pass, but <b>LED2</b> does, and </span><b style="color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;">LED2</b><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"> lights up this time.</span><br />
<span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"><br /></span><span style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"></span>
<br />
<div style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px; text-align: center;">
<img alt="File:Complementary Drive.png" src="http://upload.wikimedia.org/wikipedia/commons/a/ad/Complementary_Drive.png" style="-webkit-box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; background: rgb(255, 255, 255); border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px;" /></div>
<br style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;" />
<span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;">So, by alternating the direction of relative polarity of <b>Pin 1</b> and <b>Pin 2</b>, <b>LED1</b> or <b>LED2</b> can be made to glow. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">If 4 GPIO ports are available, then a 4 x 3 array of LEDs can be handled. In general, if <b><i>n</i></b> ports are available, a Charlieplexed array of <b>n x (n-1)</b> LEDs can be driven.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is the diagram I used to show the wiring of the 12 LEDs. You will need to read <b>GPIO18</b>, <b>23</b>,<b> 24</b> & <b>25</b> for <b>ArduinoPin2, 3,4 and 5</b>.</span><br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLLu8smxrDd8e63fs-IlTsgg9Laai_jFzin9Eu4zyxrA-ldENMNYht_YlE4YcUv0b3krv9blq6IH7I3HPpwbHjNYY7vkZ2hbZHOW5y50QdE9STgwT7Pz71uud4b26ceJkQqVqrkHGTJw8F/s640/CharlieplexDiagram.jpg" /><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's a reminder of the <b><i>truth table</i></b> for 4 x 3 Charlieplexed LEDs:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 480;"><tbody>
<tr><td style="border-bottom: solid windowtext 1.5pt; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<b>Pins:<o:p></o:p></b></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<b><br /></b></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<b><br /></b></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<b><br /></b></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<b><br /></b></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<b>LEDs:</b><o:p></o:p></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<br /></div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext 1.5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<br /></div>
</td></tr>
<tr><td style="border-bottom: solid windowtext 1.5pt; border-left: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: right;">
<b>GPIO:</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
<b>18<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>23<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>24<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>25<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>2<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>3<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>4<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>5<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>6<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>7<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>8<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>9<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<b>10<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<b>11<o:p></o:p></b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.5pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-bottom-alt: 1.5pt; mso-border-color-alt: windowtext; mso-border-left-alt: .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: .5pt; mso-border-style-alt: solid; mso-border-top-alt: 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<b>12</b><o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext 1.5pt; mso-border-top-alt: solid windowtext 1.5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b><o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b><o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td></tr>
<tr><td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 37.55pt;" valign="top" width="50"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 26.15pt;" valign="top" width="35"><div class="MsoNormal">
<div style="text-align: center;">
H<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
i<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.55pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
L<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 43.5pt;" valign="top" width="58"><div class="MsoNormal">
<div style="text-align: center;">
<br /></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.0pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 20.05pt;" valign="top" width="27"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
0<o:p></o:p></div>
</div>
</td><td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 24.45pt;" valign="top" width="33"><div class="MsoNormal">
<div style="text-align: center;">
<b>1</b></div>
</div>
</td></tr>
</tbody></table>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">The pins are set to either <b>OUTPUT</b> with a 3V3 potential (<b><span style="color: red;">H</span></b>) or zero V</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">condition</span><span style="font-family: Arial, Helvetica, sans-serif;"> (</span><b style="font-family: Arial, Helvetica, sans-serif;"><span style="color: red;">L</span></b><span style="font-family: Arial, Helvetica, sans-serif;">) or as </span><b style="font-family: Arial, Helvetica, sans-serif;">INPUT</b><span style="font-family: Arial, Helvetica, sans-serif;"> (</span><b style="font-family: Arial, Helvetica, sans-serif;"><span style="color: red;">i</span></b><span style="font-family: Arial, Helvetica, sans-serif;">). Making a port an <b>INPUT</b> effectively turns it off in this case. The fact that there are 3 possibilities for port conditions is known as </span><b style="font-family: Arial, Helvetica, sans-serif;">tri-state logic</b><span style="font-family: Arial, Helvetica, sans-serif;">.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To address <b>LED 1</b>, <b>GPIO18</b> needs to be set as an <b>OUTPUT</b>, in the <b>LOW </b>state, <b>GPIO23</b> also needs to be set as an <b>OUTPUT</b>, but in the <b>HIGH</b> state. Both <b>GPIO24 </b>and <b>25</b> need to be set as <b>INPUTS</b>. Then to light up <b>LED2, GPIO18</b> and <b>23</b> need to swap their states, and so on.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Thanks, Charlie! (Reference <b><a href="http://en.wikipedia.org/wiki/Charlieplexing" target="_blank">HERE</a></b>).</span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-27916264292570156592015-04-02T11:11:00.005+01:002015-04-02T13:13:47.146+01:0064. Another Python GUI to control the Pi 2B's GPIO Pins<span style="font-family: Arial, Helvetica, sans-serif;">An even quicker one here - just another script to create a <b>Python</b> GUI to control the <b>GPIO</b> ports.</span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_3vOcVakNCnaKhSD3vf-WKFo-TGZDpm11groDSDnw084d6AAsbsle_DBwsmFbXR8VqlxEXQilT3JON1FDuON1tPUB_UodwM1Uw9fYYUa0x_ODOGrGt3Ok7BeSrdL8NTIF0dy9WL6zwHhq/s1600/captureKC.2.jpg" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_3vOcVakNCnaKhSD3vf-WKFo-TGZDpm11groDSDnw084d6AAsbsle_DBwsmFbXR8VqlxEXQilT3JON1FDuON1tPUB_UodwM1Uw9fYYUa0x_ODOGrGt3Ok7BeSrdL8NTIF0dy9WL6zwHhq/s1600/captureKC.2.jpg" height="42" width="640" /></a><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The buttons are programmed so that when a particular button needs to be pressed for its respective colour to come on, it reads <b>Turn (colour) On</b>, and when the colour is on, the button reads <b>Turn (colour) Off</b>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The configuration above has <b>Red Off</b>, <b>Green ON</b> and <b>Blue ON</b>, giving a beautiful cyan colour as in the picture below.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The <b>Quit</b> button is important - it closes the program down properly, so that all the <b>GPIO</b> ports are ready for the next program which may need to access them. If we just closed the window without using the <b>Quit</b> button, the program would continue listening for button presses, even though the window had disappeared. The <b>Quit</b> button, when pressed, invokes the <b>Python</b> function <b><i>exit</i></b>, which ensures a clean termination to the program.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />The wiring part is exactly the same as the last post - 3 x </span><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;">330</span><span style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"><span style="font-family: Calibri, sans-serif; font-size: 14pt; line-height: 21.4666652679443px;"><b>Ω </b>resistors, one between each of the red, green and blue <b>RGB LED</b> anodes and the Pi's <b>GPIO</b> ports 23, 24 and 25. The Draft Guinness widget is still doing its job admirably!</span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinOtGTUKfBL5H7BuVIZWwfftjw7DzAKm0grlMhWXWMnIHMgkj82fGtAmNi5jRJJhkUhI453vFQs6hNzxDA8h8XzP8AJJWP6w0obmbGgJad5tXp1-Xf4LQ2Q7suauudSs85uMqUWX-1nsJ8/s1600/P4022486.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinOtGTUKfBL5H7BuVIZWwfftjw7DzAKm0grlMhWXWMnIHMgkj82fGtAmNi5jRJJhkUhI453vFQs6hNzxDA8h8XzP8AJJWP6w0obmbGgJad5tXp1-Xf4LQ2Q7suauudSs85uMqUWX-1nsJ8/s1600/P4022486.JPG" height="480" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here is the code:</span><br />
<script src="https://gist.github.com/kcranley1/7dcb7a20e21f325d7d8f.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;">The original code was written by Matt Richardson at <a href="https://www.youtube.com/watch?v=xfxSH790rZ0" target="_blank">https://www.youtube.com/watch?v=xfxSH790rZ0</a> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Nice one Matt!</span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-5603676809639453472015-04-01T16:09:00.001+01:002015-04-02T13:13:32.626+01:0063. A Python GUI to control the Pi 2B's GPIO Pins<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">32,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">What do you think of my new Pi2B with its <span style="background-color: white; line-height: 21px;">Pibow Coupé Flotilla case from <a href="http://shop.pimoroni.com/products/pibow-coupe" target="_blank">Pimoroni</a> - I think it's even snazzier than the Pi B+ in its red </span><span style="background-color: white; line-height: 21px;">Pibow Coupé case! </span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; line-height: 21px;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; line-height: 21px;">T</span></span><span style="font-family: Arial, Helvetica, sans-serif;">his is just a quick description of a means of making a Graphical User Interface (GUI) using Python (with </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>tkinter</i></b><span style="font-family: Arial, Helvetica, sans-serif;">, a Python library for drawing graphics) to show and control the status of the </span><b style="font-family: Arial, Helvetica, sans-serif;">GPIO</b><span style="font-family: Arial, Helvetica, sans-serif;"> ports on the Raspberry Pi.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's a screenshot, taken on the Pi using the <b><i>scrot</i></b> program's command:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>scrot -cd 10 -u captureKC.jpg</b></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFeCxZ7WXOOedaUUaqsLCQUzESXiePuMmyWpjOkkDmKT5XTZLEiNpkenxQkq4RQZAN6SH_mvOfzfxERmjskNDyZnbKzBystZwkl2NZy2QKjEY034rhDcGtqxXScN-xQHGS9U-PDmZYe1d/s1600/captureKC.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFeCxZ7WXOOedaUUaqsLCQUzESXiePuMmyWpjOkkDmKT5XTZLEiNpkenxQkq4RQZAN6SH_mvOfzfxERmjskNDyZnbKzBystZwkl2NZy2QKjEY034rhDcGtqxXScN-xQHGS9U-PDmZYe1d/s1600/captureKC.jpg" height="440" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is showing that I have selected <b>GPIO</b> pins <b>23</b>, <b>24</b> and <b>25</b> as outputs, and when I click on the respective tick-boxes to send these Outputs to High or Low, the RGB LED anodes are activated through the three 330</span><b><span style="font-family: "Calibri","sans-serif"; font-size: 14.0pt; line-height: 115%; mso-ansi-language: EN-GB; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 11.0pt; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">Ω</span></b><span style="font-family: Arial, Helvetica, sans-serif;"> resistors (Ideally 3 different values of resistors should have been used to get pure white when all are on).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The link to information about </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>scrot</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> is here:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://www.raspberrypi-spy.co.uk/2013/10/how-to-take-screenshots-on-the-raspberry-pi/" target="_blank">http://www.raspberrypi-spy.co.uk/2013/10/how-to-take-screenshots-on-the-raspberry-pi/</a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I have temporarily (only temporarily, I hope) lost the ability to run the Pi headless, (and I can't connect to <b><i>WinSCP </i></b></span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">to transfer files from the Pi to the PC</span><b style="font-family: Arial, Helvetica, sans-serif;"><i>!!</i></b><span style="font-family: Arial, Helvetica, sans-serif;">), so I had to use </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>scrot </i></b><span style="font-family: Arial, Helvetica, sans-serif;">to capture the window on the Pi, and I exported this file to the PC using a memory stick!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I should probably at this point explain what the above command does: <b> -cd 10</b> gives a 10 second countdown before the image is captured, to allow time to put the focus on the correct window, and <b>-u</b> tells it to capture the current active window, rather than the whole screen. The file <b><i>captureKC.jpg</i></b> is written to the current directory of the Pi, in this case, the <b><i>Home Folder</i></b>, where my program is.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The reason for the 10 second delay is to allow time for me to leave the current active window (the LXTerminal) and click on the window I wanted to image.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The Python GUI was written by <b><a href="http://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=20512" target="_blank">scotty101</a></b> and the code is shown below:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><script src="https://gist.github.com/kcranley1/b367d7c1d64320ff4ae0.js"></script><span style="font-family: Arial, Helvetica, sans-serif;">You can see that </span><b style="font-family: Arial, Helvetica, sans-serif;">scotty101</b><span style="font-family: Arial, Helvetica, sans-serif;"> intends to put more functionality on this code. Thanks Scotty!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here is a picture of the very simple connections to the Pi:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaZwyCQFURKvxyDrBbZ0LLhRn2Jo781qkJLJv3IIZdx4jPlP0eDGcx7YgxZ7hhCnMFk8l49CBRMJN64GoPc4FlWhZ3MVpNbNVxAVVnFTHGGiPs3vN80QwSWfJwbmTZwSBLSHxUXNAOTgMI/s1600/P4012485.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaZwyCQFURKvxyDrBbZ0LLhRn2Jo781qkJLJv3IIZdx4jPlP0eDGcx7YgxZ7hhCnMFk8l49CBRMJN64GoPc4FlWhZ3MVpNbNVxAVVnFTHGGiPs3vN80QwSWfJwbmTZwSBLSHxUXNAOTgMI/s1600/P4012485.JPG" height="480" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can just see the </span><span style="font-family: Arial, Helvetica, sans-serif;">330</span><b>Ω</b><span style="font-family: Arial, Helvetica, sans-serif;"> resistors on the mini breadboard connecting the RGB LED's three anodes to the </span><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15.3999996185303px; line-height: 21.5599994659424px;"><b><i>Cyntech B+ 40-way Paddle Board</i></b> (previously described in my <b>Post 55</b> at <a href="http://smokespark.blogspot.co.uk/2014/10/55-exploring-pis-gpio-ports.html" target="_blank">http://smokespark.blogspot.co.uk/2014/10/55-exploring-pis-gpio-ports.html</a>)</span><span style="font-family: Arial, Helvetica, sans-serif;">. The RGB LED (with all three colours illuminated, as indicated in the screen-shot above) has been covered with a light diffuser (Draft Guinness widget - much better than a table tennis ball).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">What I would like to do with this is to develop it to include GUI control of the RasPi Camera. That would be really coooool !</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-55546427015164326982015-01-12T13:24:00.002+00:002015-02-12T11:49:36.138+00:0062. Exploring the Pi B+'s Ports VIII - Self-Levelling Platform<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">30,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">All I did was re-arrange the two servos which I used in the last post, and fix the <b>GY-521</b> board on top of a horizontal platform, by screwing it to a piece of plastic which I then glued to the platform. The platform consists of a dummy CD with a plastic yoghurt pot lid on top. A 4-core cable connects the device to the Pi and the </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21.5599994659424px;"><i><a href="https://www.modmypi.com/adafruit-16-channel-12-bit-pwm-servo-driver?filter_name=Adafruit%20PWM/Servo%20Driver" style="color: #888888; text-decoration: none;" target="_blank">Adafruit 16 Channel 12 Bit PWM and Servo Driver Breakout Board</a></i></b><span style="font-family: Arial, Helvetica, sans-serif;">, through a hole in the platform.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgodOfBGoOMImEw9fR4k62wZrPuiQ_mcyiIgoguc_7XoGEnPGKHgIrjuAvBa15bXnvfT-ojGPtwfIkB344eaogLziSvl-APAo9jiZ_HNvB07OCS3ab2XE0hurnDHHHRFlFaBEmge_sy7EK4/s1600/P1122428.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgodOfBGoOMImEw9fR4k62wZrPuiQ_mcyiIgoguc_7XoGEnPGKHgIrjuAvBa15bXnvfT-ojGPtwfIkB344eaogLziSvl-APAo9jiZ_HNvB07OCS3ab2XE0hurnDHHHRFlFaBEmge_sy7EK4/s1600/P1122428.JPG" height="480" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is the top view of the platform with the <b>GY-521</b> on top. You can see the connecting pins and the first four on the left are connected through the hole directly below.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNZH-JkEonKD1Lcxtytkxf7Par6HgVhFaOGXr90bUUFUgM2EbTQIdzNmFy2R0FOFpzobeHRM9OmttIqV9ePtoE36rTqIvNso2gl-JHiSxZZzPVwRj8ILkI67fh4AsJ3cnclE-aKWL4U3nt/s1600/P1122427.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNZH-JkEonKD1Lcxtytkxf7Par6HgVhFaOGXr90bUUFUgM2EbTQIdzNmFy2R0FOFpzobeHRM9OmttIqV9ePtoE36rTqIvNso2gl-JHiSxZZzPVwRj8ILkI67fh4AsJ3cnclE-aKWL4U3nt/s1600/P1122427.JPG" height="480" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is the view from below the platform, one servo fixed on top of the upright pillar, and the upper one fixed to the underside (the dummy CD) of the platform. The rotors of the two servos have been glued together so that when the lower servo's rotor rotates, (about the y-axis) the entire structure above, including the top servo, rotates. Rotation of the platform about the x-axis is achieved by having the rotation plane of the upper servo perpendicular to that of the lower servo.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The software at this point has not been changed significantly from that in the previous post, but if you look at the video below, you'll see that the platform does correct for tilts in the x- and y- directions. I did some tweaking to make it more sensitive and responsive. I just wanted to put it on record at this point in case I broke something and missed the opportunity:</span><br />
<iframe allowfullscreen="" frameborder="0" height="371" mozallowfullscreen="" src="//player.vimeo.com/video/116646052?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="660"></iframe>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The software was adjusted to make the servos move correctly. So far I have tried changing the value of </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, sans-serif; font-size: 15px; line-height: 21.5599994659424px;">τ</b><span style="font-family: Arial, Helvetica, sans-serif;"> in the expression</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b style="background-color: #fff9ee; color: #222222; font-family: Arial, sans-serif; font-size: 15px; line-height: 21.5599994659424px;">α = τ/(τ + Δt), </b></span></div>
<br />
<b style="background-color: #fff9ee; color: #222222; font-family: Arial, sans-serif; font-size: 15px; line-height: 21.5599994659424px;"><br /></b>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">from 500 ms to 1 second, and I have applied a factor of 1.5 to the variable <b>slope</b> which is used in the calculation of<b> roll</b> and<b> pitch</b>, and this seems to have improved the performance.</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">You may notice some jitter in the movement which I managed to reduce a little by increasing the time constant </span><b style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">τ</b><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;"> as I mentioned </span><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">above.</span></span><br />
<span style="color: #222222; font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21.5599994659424px;"><br /></span></span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">And yes - you spotted it - it's a Draft Guinness widget rolling about on the top! You may even be able to spot some of the precious liquid leaking from the widget onto the yoghurt carton lid.</span></span><br />
<span style="color: #222222; font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21.5599994659424px;"><br /></span></span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">However, no doubt I could find a better feedback mechanism, and i</span><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;">f any one out there has any suggestions, I would love to hear from you.</span></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fff9ee; color: #222222; line-height: 21.5599994659424px;"><br /></span></span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-14834021962087830852015-01-08T14:04:00.003+00:002015-01-12T08:07:02.251+00:0061. Exploring the Pi B+'s Ports VII - Controlling Servos Using an IMU and Complementary Filter<span style="font-family: Arial, Helvetica, sans-serif;">Let's look more closely at what this amazing <b><i>MPU-6050</i></b> device (Inertial Measurement Unit - IMU) can do: it consists of an <b>accelerometer</b> and a <b>gyroscope. </b> These two components are known as MEMS - </span><span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 16px; line-height: 19.2000007629395px;">Micro-Electro-Mechanical Systems. In other words, they have moving parts.</span><span style="font-family: Arial, Helvetica, sans-serif;"> The chip also incorporates an on-board Digital Motion Processor (DMP) which executes a lot of the motion algorithms for </span><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 14px;">rotation matrix, quaternion, Euler Angle, or raw data formats, </span><span style="font-family: Arial, Helvetica, sans-serif;">inside the chip. </span><span style="font-family: Arial, Helvetica, sans-serif;">Other features include an embedded temperature sensor</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">and an on-chip oscillator with ±1% accuracy over the operating range -40°C to +85°C. </span><span style="font-family: Arial, Helvetica, sans-serif;"> Let's look at some of these features:</span><br />
<h3>
<span style="font-family: Arial, Helvetica, sans-serif;">Temperature</span></h3>
<h3>
<div style="font-size: medium; font-weight: normal;">
<span style="font-family: Arial, Helvetica, sans-serif;">Lines 19 to 22 of the code read one of the registers which contains the </span><span style="font-family: Arial, Helvetica, sans-serif;">chip's</span><span style="font-family: Arial, Helvetica, sans-serif;"> core temperature. This number needs to be calibrated to degrees, as recommended in the <a href="http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf" target="_blank">InvenSense Product Specification</a>. The performance of the unit could vary if there was a build-up of heat, so a measurement of its temperature could assist in making temperature corrections if necessary.</span></div>
</h3>
<h3>
<span style="font-family: Arial, Helvetica, sans-serif;">Accelerometer</span></h3>
<span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif;">Accelerometers measure linear acceleration. When at rest, the only acceleration experienced by a body is that due to gravity, acting in the -z direction. When the device is tilted, as in applying <b><i>roll</i></b> (about the x-axis) or <b><i>pitch</i></b> (about the y-axis) the x- or y- components of gravity increase and these changes are detected by the unit, allowing the measurement of angles of pitch and roll. Accelerometers cannot measure <b><i>yaw</i></b>, which is rotation in the plane perpendicular to the gravity vector, because yaw does not affect the force experienced due to gravity. Furthermore, the accelerometer is very sensitive to vibrations, causing high-frequency noise.</span></span><br />
<h3>
<span style="font-family: Arial, Helvetica, sans-serif;">Gyroscope</span></h3>
<span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif;">A gyro provides information on how fast it is turning (rotation rate about one of the axes) only. Because it is possible to time-integrate the rotation rate about any axis, the angle through which the unit turns can be calculated. This information alone would be very valuable if it were not for the tendency of the gyroscope signals to drift, as integration introduces low-frequency noise.</span></span><br />
<h3>
<span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif;">Combining the Accelerometer and Gyroscope Data</span></span></h3>
<span style="color: #333333;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">By combining the best of both worlds, it is possible to come up with a good estimate of the extent of rotation of the unit about the x- and y-axes. The idea is to minimise the high-frequency noise (low-pass filter) of the accelerometer and the low-frequency noise (high-pass filter) of the gyroscope.</span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgXEo70Wo0kxre0TA1faq-JjbQcoMWD5dKHf8KSv3YKLo0l-INeMrEoSnOXT6CUHZdvetJuZmpqk1FIWk9KMH_Gch_bDIT8znbNbn6BzJvGperFRwAhE-lSpD3SEkQmIzgDkOMnJlmW2MS/s1600/03%5B1%5D.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgXEo70Wo0kxre0TA1faq-JjbQcoMWD5dKHf8KSv3YKLo0l-INeMrEoSnOXT6CUHZdvetJuZmpqk1FIWk9KMH_Gch_bDIT8znbNbn6BzJvGperFRwAhE-lSpD3SEkQmIzgDkOMnJlmW2MS/s1600/03%5B1%5D.gif" height="580" width="640" /></a></div>
<span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><b>Acknowledgement: <a href="http://www.starlino.com/imu_guide.html" target="_blank">http://www.starlino.com/imu_guide.html</a></b></span></span><br />
<span style="color: #333333; line-height: 21px;"><br /></span>
<span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif;">The diagram shows, on the x-y-z axis system, the direction vector <b>R</b>, representing the direction that the </span></span><b style="font-family: Arial, Helvetica, sans-serif;"><i>MPU-6050</i></b><span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif;"> 's zenith has moved from the z-axis. The projection of <b>R</b> on to the x-z plane makes the angle </span></span><b><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><span style="color: #333333; line-height: 21px;"><span style="font-family: Arial, Helvetica, sans-serif;"> with the z-axis, </span></span><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">and its projection on to the y-z plane makes the angle </span><b><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"> with the z-axis. </span><b><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">, </span><b><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">y</sub></b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"> and </span><b><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"> are the components of <b>R</b> along the 3 axes, respectively. The accelerometer reads out the 3 components of the vector <b>R</b>. </span><br />
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"><br /></span>
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">This makes it relatively easy to calculate the angles of rotation about the y-axis, </span><b><span style="font-family: Arial, Helvetica, sans-serif; text-align: center;">A</span><sub style="font-family: Arial, Helvetica, sans-serif; text-align: center;">xz</sub></b><sub style="font-family: Arial, Helvetica, sans-serif;"> </sub><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">and about the x-axis, </span><b><span style="font-family: Arial, Helvetica, sans-serif; text-align: center;">A</span><sub style="font-family: Arial, Helvetica, sans-serif; text-align: center;">yz</sub></b><sub style="font-family: Arial, Helvetica, sans-serif;"> </sub><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">from the expressions:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div style="text-align: center;">
<b><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"> = </span><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">atan2[</span></b><b style="text-align: start;"><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">, </span></b><b style="text-align: start;"><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">], </span><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">and </span><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"> = </span><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">atan2[</span></b><b style="text-align: start;"><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">y</sub></b><b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;">, </span></b><b style="text-align: start;"><span style="font-family: Arial, Helvetica, sans-serif;">R</span><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 21px;"><b>]</b>.</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">Use is made of the <b>atan2</b> function, instead of the </span></span><b style="font-family: Arial, Helvetica, sans-serif; line-height: 21px;">atan</b><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"> function, because it has a range of <b>-</b></span></span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><b>π</b></span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"> to <b>+</b> </span></span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><b>π</b></span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">, while the <b>atan</b> function has the less useful range of </span></span><span class="apple-converted-space"><span style="font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 20.7000007629395px;"><b> </b></span></span><span style="line-height: 18.3999996185303px;"><span style="font-family: Arial, Helvetica, sans-serif;"><b>-π/2</b> to <b>+π/2</b></span></span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 21px;">. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif; line-height: 21px;"><br /></span>
<span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif; line-height: 21px;">Please note that the angles which I am calculating for the accelerometer are not the same as the angles between the vector <b>R</b> and the x and y-axes</span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">, A</span><sub style="font-family: Arial, Helvetica, sans-serif;">xr </sub></b><span style="font-family: Arial, Helvetica, sans-serif;">and </span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">yr </sub></b><span style="font-family: Arial, Helvetica, sans-serif; line-height: 21px;">which Andrew Birkett seems to be calculating.</span></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">The quantities measured by </span><span style="font-family: Arial, Helvetica, sans-serif;">the gyro</span><span style="font-family: Arial, Helvetica, sans-serif;"> are the angular velocities:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif; line-height: 115%;"><br /></span>
<br />
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif; line-height: 115%;"> <b>Δ</b></span><b><span style="font-family: Arial, Helvetica, sans-serif;">(G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub><span style="font-family: Arial, Helvetica, sans-serif;">)/</span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 115%;">Δ</span><span style="font-family: Arial, Helvetica, sans-serif;">t, </span><span style="font-family: Arial, Helvetica, sans-serif;">and </span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;">Δ</span><span style="font-family: Arial, Helvetica, sans-serif;">(G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub><span style="font-family: Arial, Helvetica, sans-serif;">)/</span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;">Δ</span></b><span style="font-family: Arial, Helvetica, sans-serif;"><b>t</b> </span><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">where </span><b><span style="font-family: Arial, Helvetica, sans-serif; line-height: 115%;">Δ</span><span style="font-family: Arial, Helvetica, sans-serif;">(G<span style="font-size: 13px;">)</span></span></b><span style="font-family: Arial, Helvetica, sans-serif;"><b> </b>is the change in the angle during the small increment in time </span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><b>Δ</b></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>t</b></span><span style="font-family: Arial, Helvetica, sans-serif;">.</span><br />
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">So if the gyro output is sampled repeatedly at the time interval </span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><b>Δ</b></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>t</b>, the readings can be multiplied by </span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><b>Δ</b></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>t</b> to give the angle from the angular rotation rate. We can then get the rotation about the y-axis, </span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><span style="font-family: Arial, Helvetica, sans-serif;">, and the rotation about the x-axis, </span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><span style="font-family: Arial, Helvetica, sans-serif;">,</span><span style="font-family: Arial, Helvetica, sans-serif;">of the vector <b>R</b></span><span style="font-family: Arial, Helvetica, sans-serif;">.</span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">We now have estimates of the angles from both the accelerometer and the gyroscope, the accelerometer data being imperfect because of high frequency noise, and the gyro data being subject to low frequency noise (drift). </span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;">We need a way of combining the two estimates of angles, <b>A</b> and <b>G</b>, so that we get the best accuracy and least noise. This is where there is a mixture of art and science. The accuracy should look after itself in that both methods should be right, no matter what proportions they are taken in. The method of choosing the proportions may need tuning to get the best mix of high-pass filter and low-pass filter which give the most acceptable levels of noise. </span><span style="font-family: Arial, Helvetica, sans-serif;">The best approach is an iterative algorithm, which starts with the accelerometer's first reading as an approximation. Let's look at the rotation about the y-axis first:</span><br />
<br />
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm;">
<b><span style="font-family: Arial, sans-serif;">pitch</span></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><b><span style="font-family: Arial, sans-serif;">[0] = </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[0] </span></b><span style="font-family: Arial, sans-serif;">.....the initial accelerometer data</span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm;">
<span style="font-family: Arial, sans-serif;"><b><br /></b></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif;">The initial gyro data is represented by<b> </b></span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><span style="font-family: Arial, sans-serif;"><b>[0]</b></span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;">The accelerometer noise time
constant, <b>τ</b>,<span class="apple-converted-space"> </span>typically about 0.5 to 1 second, and the time interval <b>Δt</b>, typically about 10 milliseconds,
combine to give a value of <b>α</b> of something like 0.95 to 0.98. </span><b style="font-family: Arial, sans-serif;">α</b><span style="font-family: Arial, sans-serif;"> is used to apportion the contributions of </span><span style="font-family: Arial, sans-serif;">gyroscope (</span><b style="font-family: Arial, sans-serif;">α</b><span style="font-family: Arial, sans-serif;">) and </span><span style="font-family: Arial, sans-serif;">accelerometer (</span><b><span style="font-family: Arial, sans-serif;">1 </span><span style="font-family: Arial, sans-serif; font-size: 18px;">- </span></b><b style="font-family: Arial, sans-serif;">α</b><span style="font-family: Arial, sans-serif;">) to the final estimate of the </span><span style="font-size: 13.5pt;"><o:p></o:p></span><span style="font-family: Arial, Helvetica, sans-serif;">x-axis and y-axis rotations.</span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif;"><b>α = τ/(τ + Δt)</b></span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;">and these
are plugged into the loop:</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[1] = </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[1] - </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[0] </span><o:p></o:p></b></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif;"><b><br /></b></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif;"><b>pitch</b></span><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><span style="font-family: Arial, sans-serif;"><b>[1] = α<span style="font-size: large;">{</span>pitch</b></span><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><span style="font-family: Arial, sans-serif;"><b>[0] + </b></span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><span style="font-family: Arial, sans-serif;"><b>[1]Δt<span style="font-size: large;">}</span> +
(1 - α)</b></span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><span style="font-family: Arial, sans-serif;"><b>[1]</b></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<span style="font-family: Arial, sans-serif; font-size: 13.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;">Here the
gyro increment data updates the expression at each
iteration, every <b>Δt</b> seconds. The second term then combines this with
a small proportion of the latest accelerometer data.</span><o:p></o:p></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;">The
generalised form of the loop for the rotation about the y-axis is then:</span><span style="font-size: 13.5pt;"><o:p></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[n] = </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[n] - </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[n-1] ie </span><o:p></o:p></b><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px; text-align: center;"><b>Δ</b></span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">(G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub><span style="font-family: Arial, Helvetica, sans-serif;">)</span></b></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<br /></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<b><span style="font-family: Arial, sans-serif;">pitch</span></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><b><span style="font-family: Arial, sans-serif;">[n] = α</span></b><b style="font-family: Arial, sans-serif;"><span style="font-size: large;">{</span></b><b><span style="font-family: Arial, sans-serif;">pitch</span></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">x</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><b><span style="font-family: Arial, sans-serif;">[n-1] + </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[n]Δt<span style="font-size: large;">}</span> + (1 - α)</span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">xz</sub></b><b><span style="font-family: Arial, sans-serif;">[n]</span></b></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">and included in the loop is, </span><span style="font-family: Arial, sans-serif;">for the rotation about the x-axis</span><span style="font-family: Arial, Helvetica, sans-serif;">:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><b><span style="font-family: Arial, sans-serif;">[n] = </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><b><span style="font-family: Arial, sans-serif;">[n] - </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><b><span style="font-family: Arial, sans-serif;">[n-1]</span><o:p></o:p></b><b><span style="font-family: Arial, sans-serif;"> ie </span><o:p></o:p></b><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px; text-align: center;"><b>Δ</b></span><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">(G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub><span style="font-family: Arial, Helvetica, sans-serif;">)</span></b></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<br /></div>
<div style="margin: 0cm 0cm 0.0001pt 36pt;">
<b><span style="font-family: Arial, sans-serif;">roll</span></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">y</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><b><span style="font-family: Arial, sans-serif;">[n] = α</span></b><b style="font-family: Arial, sans-serif;"><span style="font-size: large;">{</span></b><b><span style="font-family: Arial, sans-serif;">roll</span></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">y</sub></b><b style="text-align: center;"><sub style="font-family: Arial, Helvetica, sans-serif;">z</sub></b><b><span style="font-family: Arial, sans-serif;">[n-1] + </span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">G</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><b><span style="font-family: Arial, sans-serif;">[n]Δt<span style="font-size: large;">}</span> + (1 - α)</span></b><b style="text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;">A</span><sub style="font-family: Arial, Helvetica, sans-serif;">yz</sub></b><b><span style="font-family: Arial, sans-serif;">[n]</span></b></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is carried out for both the x-axis rotation and the y-axis rotation, and is known as a version of the <b><i>Complementary Filter</i></b>. These angle values are fed to the x- and y-axis servos.</span><br />
<h3>
<span style="font-family: Arial, Helvetica, sans-serif;">Plotting the Outputs and Filter Results</span></h3>
<span style="font-family: Arial, Helvetica, sans-serif;">I followed Andrew Birkett's excellent <a href="http://blog.bitify.co.uk/2013/11/using-complementary-filter-to-combine.html" target="_blank">blog</a> to use <b>Gnuplot</b> to plot graphs on the Pi: Firstly the program needs to be downloaded and installed on the Pi:</span><span style="background-color: #f7f7f7; color: #222222; font-family: 'Courier 10 Pitch', Courier, monospace; font-size: 15px; line-height: 21px;"><br /></span><br />
<span style="background-color: #f7f7f7; color: #222222; font-family: 'Courier 10 Pitch', Courier, monospace; font-size: 15px; line-height: 21px;">sudo apt-get install gnuplot-x11</span><br />
<span style="background-color: #f7f7f7; color: #222222; font-family: 'Courier 10 Pitch', Courier, monospace; font-size: 15px; line-height: 21px;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I named my Python script </span><a href="https://gist.github.com/kcranley1/fbfa3c4c9df9c9f6f1d2#file-kc6050servod-py" style="color: #666666; font-weight: bold; text-decoration: none;"><span style="font-family: Arial, Helvetica, sans-serif;"><i>KC6050ServoD.py</i></span></a><span style="font-family: Arial, Helvetica, sans-serif;"> and then entered the following instruction:</span><br />
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">sudo ./KC6050ServoD<span style="line-height: 19.6000003814697px;">.py > plot.dat</span></pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"></pre>
<div style="background-color: white; line-height: 19.6000003814697px;">
<span style="font-family: Arial, Helvetica, sans-serif;">This directs the output to a file named <b><i>plot.dat</i></b>, instead of printing it on the terminal window.</span><span style="font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px;"></span></div>
<div style="background-color: white; line-height: 19.6000003814697px;">
<span style="font-family: Arial, Helvetica, sans-serif;">I put the following <b>Gnuplot</b> commands into a file named <b><i>gnuplot-command.plg</i></b>:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="background-color: white; line-height: 19.6000003814697px;">
<span style="font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">set terminal wxt persist size 800,600 background '#000000' # enhanced font 'Consolas,10' </span></div>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">set style line 99 linecolor rgb "#ffffff" linetype 0 linewidth 2
set key top right textcolor linestyle 99
set grid linestyle 99
set border linestyle 99
set xlabel "time (s)" textcolor linestyle 99
set ylabel "degrees" textcolor linestyle 99
set yrange [-180:180]
plot filename using 1:2 title "Accelerometer X" with line linewidth 2 , </pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">\<span style="line-height: 19.6000003814697px;">filename using 1:3 title "Gyroscope X" with line linewidth 2 , </span></pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"><span style="line-height: 19.6000003814697px;">\</span><span style="line-height: 19.6000003814697px;">filename using 1:4 title "Filter X" with line linewidth 2 lc rgb 'gold'</span></pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">
#plot filename using 1:5 title "Accelerometer Y" with line linewidth 2 , </pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">\filename using 1:6 title "Gyroscope Y" with line linewidth 2 , </pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">\filename using 1:7 title "Filter Y" with line linewidth 2<span style="line-height: 19.6000003814697px;"> lc rgb 'gold'</span></pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif; line-height: 19.6000003814697px; white-space: normal;">Note that I have commented the last line out. This enables the X components to be displayed. Similarly, by commenting out the second last line instead, the Y components are shown. This file containing <b>Gnuplot</b> commands was then run by entering:</span></pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; line-height: 19.6000003814697px;"><pre class="console-input" style="font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">gnuplot -e "filename='plot.dat'" gnuplot-command.plg</pre>
</pre>
<pre class="console-input" style="background-color: white; line-height: 19.6000003814697px;"></pre>
<pre class="console-input" style="background-color: white; font-family: Inconsolata, 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"></pre>
<span style="font-family: Arial, Helvetica, sans-serif;">Below is a plot of the output of the Accelerometer, Gyroscope and Complementary Filter, as displayed by the Pi:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUJiVnlcU_bIH5TADGbUuu4DsOUIeIXFMgTS-SFXDUF1xJP4mDP0eysyFBepHFNoZqeF6KAHhlkevVgk_i39q2-vIVrYTyGWvJ0lSG9BL5A4LDzLQ8Epm5p5gh3oOOsgF-qQNA10tq4_J0/s1600/GnuplotOutputX.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUJiVnlcU_bIH5TADGbUuu4DsOUIeIXFMgTS-SFXDUF1xJP4mDP0eysyFBepHFNoZqeF6KAHhlkevVgk_i39q2-vIVrYTyGWvJ0lSG9BL5A4LDzLQ8Epm5p5gh3oOOsgF-qQNA10tq4_J0/s1600/GnuplotOutputX.jpg" height="476" width="640" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfZq7JEdLWRYsVsYhyrdURs6N4oH46YL4C83M5ciqZm1SLzC3fS5mvxarSnEGkBy2wPiJedpUGAolKsSVnX9hi9iILmqvbUyjRbtC3K-gNwyc0x7X-D-wXnbXeL6eEsOnzZasPjrXCN8DZ/s1600/GnuplotOutputY.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfZq7JEdLWRYsVsYhyrdURs6N4oH46YL4C83M5ciqZm1SLzC3fS5mvxarSnEGkBy2wPiJedpUGAolKsSVnX9hi9iILmqvbUyjRbtC3K-gNwyc0x7X-D-wXnbXeL6eEsOnzZasPjrXCN8DZ/s1600/GnuplotOutputY.jpg" height="476" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">These waveforms represent the angles of roll (upper graph) and pitch (lower graph) respectively, recorded simultaneously as I rotated the <b><i>MPU-6050</i></b> board about firstly its x-axis (1 to 4 seconds), and then about its y-axis (4 to 7 seconds) Around 7 seconds there was a combination of roll and pitch, and this is apparent in both the x- and y plots. Within each graph can be seen the Accelerometer's estimates of rotation angle (in red), the Gyroscope's estimates of rotation (in green) and the combination of Accelerometer and Gyroscope readings using the complementary filter (in yellow).</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Note that up to about 1 second, the device was at rest on a table, and all three were in agreement (zero degrees). The red Accelerometer plot then exhibits large spikes, which come from the high frequency vibrations that the device is subject to. The yellow filter plot 'ignores' the spikes, and is generally between the Accelerometer and Gyro readings. The Gyro, however, tends to overshoot or undershoot when the tilt is changed. In the upper plot, after about 6 seconds, the Gyro slowly drifts to a significantly higher level, representing the low frequency noise it exhibits. The filter, however, seems to 'detect' this, and sticks with the Accelerometer, omitting the spike which occurred - </span><span style="font-family: Arial, Helvetica, sans-serif;">probably</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">as I finally (quite gently) set the board down on the table.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">I did a compound plot of a different series of rotations. </span><span style="font-family: Arial, Helvetica, sans-serif;">It starts to get over-crowded, but here it is anyway</span><span style="font-family: Arial, Helvetica, sans-serif;">:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZzJV-RE9mYZoQEX4H55wBVLoKTV7vdcxFdSsthIOo-OjW4g06ee9wVEmngP-4WcCYP0OzAMLaXNjwsdnq28GapEhd4QF9RPasc5Q3QWWYAMQscH59geAC7EwskG-pto-6WbtkOva2oeEi/s1600/AccelGyroAll.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZzJV-RE9mYZoQEX4H55wBVLoKTV7vdcxFdSsthIOo-OjW4g06ee9wVEmngP-4WcCYP0OzAMLaXNjwsdnq28GapEhd4QF9RPasc5Q3QWWYAMQscH59geAC7EwskG-pto-6WbtkOva2oeEi/s1600/AccelGyroAll.jpg" height="476" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Once again, the Gyroscope plots end up having drifted well away (more than </span><b>±</b><span style="font-family: Arial, Helvetica, sans-serif;">50</span>⁰)<span style="font-family: Arial, Helvetica, sans-serif;"> from the true reading of 0</span>⁰<span style="font-family: Arial, Helvetica, sans-serif;">, corresponding to the device sitting horizontally on the table, while the filter results have 'ironed out' the high frequency noise from the Accelerometer data and have fully corrected Gyroscope drift.</span></div>
<h3 style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">The Python Program</span></h3>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">For the script below, I used the code for the above plots, modified to drive the servos </span><span style="font-family: Arial, Helvetica, sans-serif;">using the Complementary Filter data</span><span style="font-family: Arial, Helvetica, sans-serif;">. Many thanks to Andrew Birkett, as it is largely based on his work:</span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<script src="https://gist.github.com/kcranley1/fbfa3c4c9df9c9f6f1d2.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;">and here is the video:</span><br />
<iframe allowfullscreen="" frameborder="0" height="371" mozallowfullscreen="" src="//player.vimeo.com/video/116247112?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="660"></iframe>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">You can see that the motion of the servos is now nice and smooth.</span></div>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-55640687134456829052014-12-22T12:29:00.003+00:002015-01-01T14:50:08.467+00:0060. Exploring the Pi B+'s Ports VI - Controlling Servos Using the MPU-6050<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">27,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Hopefully I'm getting a bit closer to a self-balancing platform. The stage I'm at now effectively has the accelerometer signal being sent to the 2 servos, rotation of the MPU-6050 about its x-axis, rotating one servo, and rotation about the y-axis controlling the second servo.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the code:</span><br />
<script src="https://gist.github.com/kcranley1/084010579a18bdc81aef.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the video:</span><br />
<iframe allowfullscreen="" frameborder="0" height="371" mozallowfullscreen="" src="//player.vimeo.com/video/115164782?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="660"></iframe>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The sensitivity can be changed by adjusting the code</span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-49771891665698252472014-12-20T16:30:00.004+00:002014-12-22T15:04:52.604+00:0059. Exploring the Pi B+'s Ports V - Controlling Servos and Reading the MPU-6050<span style="font-family: Arial, Helvetica, sans-serif;">Controlling servos using an Arduino is very easy. Remember the light follower at my post number 45, which used the Arduino <b>Servo.h</b> library <b><a href="http://smokespark.blogspot.co.uk/2014/02/45-improved-light-follower-with-wide.html" target="_blank">HERE</a>?</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif; line-height: 16.3800010681152px;">The Arduino chip is good at this because it can deliver what the servo needs - very accurate PWM (Pulse Width Modulation) signals. This is not possible to do on a Pi (see the <b><i>RasPi.tv</i></b> article <a href="http://raspi.tv/2013/how-to-use-soft-pwm-in-rpi-gpio-pt-2-led-dimming-and-motor-speed-control" target="_blank"><b>HERE</b></a>) because there are so many routines running and interrupting.</span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; line-height: 16.3800010681152px;"> In any case, t</span><span style="background-color: white;">he Raspberry Pi has </span></span><span style="background-color: white; font-family: Arial, Helvetica, sans-serif;">only</span><span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"> </span><span style="background-color: white; font-family: Arial, Helvetica, sans-serif;">one hardware and one software PWM output.</span><br />
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The way to do it on a Pi is to use the <b><i><a href="https://www.modmypi.com/adafruit-16-channel-12-bit-pwm-servo-driver?filter_name=Adafruit%20PWM/Servo%20Driver" target="_blank">Adafruit 16 Channel 12 Bit PWM and Servo Driver Breakout Board</a></i></b> which does all of the hard work while the Raspberry Pi just tells it what to do. This board is based on a <b>PCA9685</b> chip which was actually designed to be an LED controller. It is a PWM driver, controlled by </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><i>I<sup>2</sup>C</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> with a fast built-in clock, capable of operating at frequencies up to 1MHz. The 16 channels allow up to 16 PWM devices to be connected - ideal for robotics with lots of servos. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The board only requires a <b>3V3</b> power supply for the </span><span style="font-family: Arial, Helvetica, sans-serif;">chip</span><span style="font-family: Arial, Helvetica, sans-serif;">, <b>GND</b>, and two connections, <b>SCL</b> (the clock line) and <b>SDA </b>(the data line), both of which hang off the </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><i>I<sup>2</sup>C</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> bus. There are 2 further ports for external power and <b>GND</b> for the servos, which the Raspberry Pi would not be able to deliver. The Adafruit board cost £11.98 including delivery from <b>ModMiPi</b>. I also bought 2 x </span><span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;"><b><i>YKS New NEW SG90 9g Mini Servo</i></b> motors from <b><a href="http://www.amazon.co.uk/gp/product/B00DAN8XI0?psc=1&redirect=true&ref_=oh_aui_detailpage_o04_s00#productDetails" target="_blank">Amazon</a></b> for £2.30 (free delivery). These have a 180 degree range - even better than the previous ones I used in the Light Follower, which can rotate about 135 degrees.</span><br />
<span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;"><br /></span>
<span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;">The photos below give an idea of the circuitry:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV2Z8X0pHjYqUVKJoF8YtrARwVegvxdqlQ9jTVMBPw_J5aDPOLDVJLNvW4rXcFL7voSWmn99GzXt5_a0ZoZlhUNq6lkpaBR082JQBdIqy5nqb6hCOJaWb1h2Ilg-FSERHTJEl8QnyfVbL7/s1600/PC192372.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV2Z8X0pHjYqUVKJoF8YtrARwVegvxdqlQ9jTVMBPw_J5aDPOLDVJLNvW4rXcFL7voSWmn99GzXt5_a0ZoZlhUNq6lkpaBR082JQBdIqy5nqb6hCOJaWb1h2Ilg-FSERHTJEl8QnyfVbL7/s1600/PC192372.JPG" height="480" width="640" /></a></div>
<span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;">From above, you can see the Pi with the <b><i>Cyntech paddle board</i></b>, connected as before to the <b>GY-521</b> breakout board with the</span><span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;"> <b>MPU6050 </b>(on the blue breadboard). I have taken the </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><i>I<sup>2</sup>C</i></b><span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;"> lines and the <b>3V3</b> power and <b>GND</b> from that to the <b><i>Adafruit servo driver</i></b>. The external power to the Adafruit board comes from an a</span><span style="font-family: Arial, Helvetica, sans-serif;">djustable <b><i>Step Down Supply Power Module</i></b> with a 4V to 40V input and a 1.5V to 35V output. It is capable of supplying a current of 2A. I bought it about a year ago for about £2. That's it on the white breadboard at the top of the picture. It is powered from a mains supply of nominal 12V (capable of up to 1 amp). </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I tuned the output of the step down module to 5V for the servos, using its adjustable potentiometer<i>. </i>You can see the 2 servos joined at right angles to each other on the left - each of them can draw currents of some hundreds of mA. The servos are connected to channels 11 and 15 of the Adafruit board.</span><br />
<span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; line-height: 18px;"><br /></span>
<span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Using the command:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fcfcfc; line-height: 18px;"><br /></span></span><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Courier New, Courier, monospace;"><b>i2cdetect -y 1</b></span></span><span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;"> </span><span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; line-height: 18px;">(the 1 refers to Revision 2 or later Raspberry Pis)</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">the following output was printed on the terminal:</span><br />
<br />
<b><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;"> 0 1 2 3 4 5 6 7 8 9 a b c d e f</span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">00: -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">10: -- -- -- -- -- -- -- -- -- -- -- </span><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">--</span><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;"> -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">70: 70 -- -- -- -- -- -- -- </span><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 12px; line-height: 15.210000038147px;"> </span></b><br />
<span style="background-color: #f7f7f9; color: #8b8b8b; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 12px; line-height: 15.210000038147px;"><br /></span><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;">This shows a map of the registers on the Pi's </span><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><span style="font-family: Arial, Helvetica, sans-serif;"> bus. Two extra entries at the hexadecimal addresses </span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; font-weight: bold; line-height: 19.6000003814697px;">0x40</span><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; line-height: 19.6000003814697px;"> and </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; font-weight: bold; line-height: 19.6000003814697px;">0x70</span><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> show that two </span></span><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> devices (the 2 servos in this case) have been detected at those addresses. </span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhThK_k4Miq-I80J4tZe2Av-AxodmRGE2pUbMC7DmvWtBuCSyon7tL_O7-MzfQai55awh27ZbTm3UnEnaEgMdAwFcZdWX_bvCMXKDvXqWHWnZ11Pwl8vM2EeKRfSEb3pDX5Ty0IrWAcRkb0/s1600/PC192373.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhThK_k4Miq-I80J4tZe2Av-AxodmRGE2pUbMC7DmvWtBuCSyon7tL_O7-MzfQai55awh27ZbTm3UnEnaEgMdAwFcZdWX_bvCMXKDvXqWHWnZ11Pwl8vM2EeKRfSEb3pDX5Ty0IrWAcRkb0/s1600/PC192373.JPG" height="480" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the Python script which I put together from Andrew Birkett's and Adafruit's work. This is another step on the way to controlling the servos from the signals from the MPU6050:</span></div>
<span style="background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 1.3;"><br /></span>
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif; line-height: 16.3800010681152px;"><br /></span>
<script src="https://gist.github.com/kcranley1/df77ce5a1467b6700333.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;">Note that the <b><i>xrot</i></b> and <b><i>yrot</i></b> outputs (rotations in degrees about the x- and y-axes respectively) which are printed on the screen at the beginning of the video, are calculated from accelerometer data only, even though the gyroscope data is read also.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">And here's the video:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="371" mozallowfullscreen="" src="//player.vimeo.com/video/115172681?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="660"></iframe>
</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Hopefully I'm going in the right direction to make a self-balancing platform!!</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-86080813551074721402014-12-12T12:03:00.000+00:002014-12-17T16:05:22.187+00:0058. Exploring the Pi B+'s Ports IV - Reading the MPU-6050 using Python<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">26,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The last post described the 3D wireframe </span><span style="font-family: Arial, Helvetica, sans-serif;">demonstration of</span><span style="font-family: Arial, Helvetica, sans-serif;"> the <b><i>MPU-6050</i></b>'s rotations (ie the </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>GY-521</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> breakout board</span><span style="font-family: Arial, Helvetica, sans-serif;">) about the x-, y- and z-axes, and other scripts which displayed the readout of quaternions etc. Those test programs were written in the C++ programming language. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This time test programs are written in Python, giving me a better chance of understanding what's going on! The circuitry is identical to that used in the last post, and of course, </span><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif;">the </span><span style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; line-height: 18.3999996185303px;"><span style="font-family: Arial, Helvetica, sans-serif;"><b><i>I<sup>2</sup>C</i></b></span></span><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif;"> interface has previously been enabled.</span><br />
<span style="background-color: #fff9ee; font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="background-color: white; font-family: Arial, sans-serif;"><b><i>smbus</i></b> is a Python module which allows SMBus (system management bus - a sub-set of the </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><i>I<sup>2</sup>C</i></b><span style="background-color: white; font-family: Arial, sans-serif;"> protocol) access through the </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><i>I<sup>2</sup>C</i></b><span style="background-color: white; font-family: Arial, sans-serif;"> interface on Linux hosts. This is the key module for Python access.</span><br />
<br />
<h3>
<span style="font-family: Arial, Helvetica, sans-serif;">Reading Accelerometer Data</span></h3>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">In this first program, in addition to reading the data from the accelerometer, the output values are sent to a web page, just for fun! The address of the web page depends on the Pi's IP address, which can be found using the terminal command</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><i>ifconfig</i></b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">and appending <b>:8080</b> to the end. For example,</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<b style="background-color: white; line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif;">http://ip-address-of-your-pi:8080</span></b><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the Python code for <b><i>server.py</i></b>:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><script src="https://gist.github.com/kcranley1/11c404d7977264476ef6.js"></script><span style="font-family: Arial, Helvetica, sans-serif;">Andrew Birkett's really neat code reads the accelerometer part of the </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>MPU-6050</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> and prints out the x- and y-axis rotations which are calculated by the program. </span><span style="font-family: Arial, Helvetica, sans-serif;">The output via the web page looks like this:</span><br />
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="color: blue; font-family: Courier New, Courier, monospace;"><b>x-rotation: 0.2 degrees. y-rotation: -2.2 degrees.</b></span></pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;"></pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: Arial, Helvetica, sans-serif;">The values of course change as the <b><i>MPU-6050</i></b> is rotated about its x- and y-axes. for example:</span></pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="color: blue; font-family: Courier New, Courier, monospace;"><b>x-rotation: 50.8 degrees. y-rotation: 18.4 degrees.</b></span></pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: Arial, Helvetica, sans-serif;">The web page has to be refreshed to see new values.</span></pre>
<h3 style="white-space: pre-wrap; word-wrap: break-word;">
<span style="font-family: Arial, Helvetica, sans-serif;">Reading Gyro & Accelerometer Data</span></h3>
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: Arial, Helvetica, sans-serif;">This program, <b><i>Reading6050.py</i></b>, also written by Andrew Birkett, looks like this:</span></pre>
<script src="https://gist.github.com/kcranley1/b9588eff46e398b10e08.js"></script>
<br />
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: Arial, Helvetica, sans-serif;">The program produces results like this:
</span></pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;"><div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>pi@raspberrypi ~ $ sudo python Reading6050.py
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>gyro data
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>---------
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>gyro_xout: -202 scaled: -2
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>gyro_yout: -191 scaled: -2
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>gyro_zout: 11 scaled: 0
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>accelerometer data
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>------------------
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>accel_xout: 176 scaled: 0.0107421875
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>accel_yout: 160 scaled: 0.009765625
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>accel_zout: 15364 scaled: 0.937744140625
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>x rotation: 0.596614942501
</b></span><br />
<div style="white-space: normal;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>y rotation: -0.656278927449
</b></span><br />
<div style="white-space: normal;">
<b><span style="color: blue; font-family: Courier New, Courier, monospace;">pi@raspberrypi ~ $ </span></b>
<br />
<div style="font-family: 'Times New Roman'; white-space: normal;">
<b>
</b>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</pre>
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: Arial, Helvetica, sans-serif;">So what does the program do and what do these results mean?</span></pre>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-3471483980420136262014-11-28T13:23:00.002+00:002014-12-14T14:50:23.510+00:0057. Exploring the Pi B+'s Ports III - Connecting the MPU-6050 Inertial Measurement Unit to the I2C bus<span style="font-family: Arial, Helvetica, sans-serif;">Some time back (see <b><a href="http://smokespark.blogspot.co.uk/2014/05/53-robotics-gyroscope-accelerometer.html" target="_blank">HERE</a></b>) I had this <b><i>GY-521</i></b> breakout board connected to an Arduino. This time it's connected to the Raspberry Pi through the Cyntech paddle board:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuCCj7ZOhv_nqkPRvQgmBrSQvIMTxrXRdAWM0zRKcxvgT-EU6EVa68TvfMAVkD3a_fvFn4KfZXnjZaS0IDVX_C-vt0_IB90u2zHBMMNbg-LHO8ZBJYHVoPxKNOQt8ykvifUyA0at9vG_kI/s1600/PB282327.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuCCj7ZOhv_nqkPRvQgmBrSQvIMTxrXRdAWM0zRKcxvgT-EU6EVa68TvfMAVkD3a_fvFn4KfZXnjZaS0IDVX_C-vt0_IB90u2zHBMMNbg-LHO8ZBJYHVoPxKNOQt8ykvifUyA0at9vG_kI/s1600/PB282327.JPG" height="480" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;">As before, moving the small breadboard about (it's a blue one this time) generates signals in the on-board gyroscope and accelerometer, which are read via the </span><span style="line-height: 115%;"><b><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b></span><span style="font-family: Arial, Helvetica, sans-serif;"> interface (serial data line, <b><i>SDA - GPIO2</i></b> and serial clock line, <b><i>SCL - GPIO3</i></b>) by the Raspberry Pi.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">A video of the demonstration is shown below:</span><br />
<iframe allowfullscreen="" frameborder="0" height="530" mozallowfullscreen="" src="//player.vimeo.com/video/113097757?title=0&byline=0&portrait=0" webkitallowfullscreen="" width="660"></iframe>
<span style="font-family: Arial, Helvetica, sans-serif;">
I used </span><b><i>ShareX 9.4.2</i></b> <span style="font-family: Arial, Helvetica, sans-serif;">free software with </span><b><i>FFmpeg</i></b> <span style="font-family: Arial, Helvetica, sans-serif;">added to capture the Pi's desktop from my PC, and used</span> <b><i>Vimeo</i></b> <span style="font-family: Arial, Helvetica, sans-serif;">to embed the video.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">In the video I ran 3 different programs, using the following commands: <b><i>./demo_dmp</i></b>, <b><i>./demo_raw</i></b> and <b><i>./demo_3d</i></b> which I will explain later.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h3>
<b><span style="font-family: Arial, Helvetica, sans-serif;">Enabling the </span><span style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></span><span style="font-family: Arial, Helvetica, sans-serif;"> interface</span></b></h3>
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif;">Install the i2c-tools:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo apt-get install python-smbus</span><br />
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo apt-get install i2c-tools</span><br />
<ul>
<li><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Enable <b style="font-family: 'Times New Roman'; line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b> and SPI protocols:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo nano /etc/modprobe.d/raspi-blacklist.conf</span><br />
<ul>
<li><span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">This will open the above file in a text editor, allowing the following lines to be commented out:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">#blacklist spi-bcm2708</span><br />
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">#blacklist i2c-bcm2708</span><br />
<ul>
<li><span style="background-color: #fcfcfc; font-size: 15px; line-height: 18px;"><span style="font-family: Arial, Helvetica, sans-serif;">Edit the following file as follows, to allow the </span></span><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><span style="background-color: #fcfcfc; font-size: 15px; line-height: 18px;"><span style="font-family: Arial, Helvetica, sans-serif;"> module to be started automatically on start up:</span></span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo nano /etc/modules</span><br />
<ul>
<li><span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 18px;">When opened in the editor, add the last line as follows:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">i2c-dev</span><br />
<ul>
<li><span style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; line-height: 18px;">Add the ‘pi’ user to the <b style="font-family: 'Times New Roman'; line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b> group:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo adduser pi i2c</span><br />
<ul>
<li><span style="font-family: 'Open Sans', Arial, Helvetica, sans-serif; line-height: 18px;">Update the Pi to ensure that all the latest packages are installed:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo apt-get update</span><br />
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo apt-get upgrade</span><br />
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo apt-get dist-upgrade</span><br />
<ul>
<li><span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 18px;">Finally re-boot the Pi:</span></li>
</ul>
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;">sudo reboot</span><br />
<span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;"><br /></span>
<span style="background-color: #fcfcfc; font-size: 15px; line-height: 18px;"><span style="font-family: Arial, Helvetica, sans-serif;">The Pi will now automatically support </span></span><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><span style="background-color: #fcfcfc; font-size: 15px; line-height: 18px;"><span style="font-family: Arial, Helvetica, sans-serif;"> on startup.</span></span><br />
<span style="background-color: #fcfcfc; font-size: 15px; line-height: 18px;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span>
<br />
<h3>
<b><span style="font-family: Arial, Helvetica, sans-serif;">Interfacing the <span style="line-height: 18.3999996185303px;">MPU-6050</span></span></b></h3>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fcfcfc; line-height: 18px;">Make the connections as follows:</span></span><br />
<ul style="background-color: white; line-height: 19.6000003814697px; list-style-image: initial; list-style-position: initial; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Pin 1 - <b>3.3V</b> connect to <b>VCC</b> on the MPU-6050</span></li>
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Pin 3 - <b>SDA</b> connect to the MPU's <b>SDA</b></span></li>
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Pin 5 - <b>SCL</b> connect to the MPU's <b>SCL</b></span></li>
<li style="border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Pin 6 - Ground connect to <b>GND</b></span></li>
</ul>
<h3>
<b style="background-color: white;"><span style="font-family: Arial, Helvetica, sans-serif;"><br />Checking the </span></b><b style="background-color: white;"><span style="font-family: Arial, Helvetica, sans-serif;">Addresses of the </span></b><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><b style="background-color: white;"><span style="font-family: Arial, Helvetica, sans-serif;"> bus & the </span></b><b><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 18.3999996185303px;">MPU-6050</span></span></b><b style="background-color: white;"><span style="font-family: Arial, Helvetica, sans-serif;">'s Registers</span></b></h3>
<span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Using the command:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: #fcfcfc; line-height: 18px;"><br /></span></span>
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Courier New, Courier, monospace;"><b>i2cdetect -y 1</b></span></span><span style="background-color: #fcfcfc; font-family: 'Courier New', Courier, monospace; font-size: 15px; font-weight: bold; line-height: 18px;"> </span><span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; line-height: 18px;">(the 1 refers to Revision 2 or later Raspberry Pis)</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">the following output was printed on the terminal:</span><br />
<br />
<b><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;"> 0 1 2 3 4 5 6 7 8 9 a b c d e f</span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">00: -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">10: -- -- -- -- -- -- -- -- -- -- -- </span><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">--</span><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;"> -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- </span><br style="font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;" /><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">70: -- -- -- -- -- -- -- -- </span><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 12px; line-height: 15.210000038147px;"> </span></b><br />
<span style="background-color: #f7f7f9; color: #8b8b8b; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; font-size: 12px; line-height: 15.210000038147px;"><br /></span>
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;">The entry at the hexadecimal address </span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; font-weight: bold; line-height: 19.6000003814697px;">0x68</span><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> shows that an </span></span><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> device has been detected at that address. The </span></span><b><span style="background-color: #f7f7f9; font-family: Monaco, 'Andale Mono', 'Courier New', Courier, mono; line-height: 15.210000038147px;">UU</span></b><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> at </span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; font-weight: bold; line-height: 19.6000003814697px;">0x3b</span><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> appears to be reserved by the kernel for a driver.</span></span><br />
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span>
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;">These addresses allow us to examine their contents. For example, entering the command:</span></span><br />
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"><b>sudo i2cget -y 1 0x68 0x75</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"><b><br /></b></span>
<span style="background-color: white; line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif;">reads the contents of the address</span><span style="font-family: Arial, Helvetica, sans-serif; font-size: 14px;"> </span><span style="font-family: Courier New, Courier, monospace; font-size: 14px; font-weight: bold;">0x68</span><span style="font-family: Arial, Helvetica, sans-serif;"> of </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>I2CBUS 1</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> (the 1 refers to a Rev 2 or later Raspberry Pi) and retrieves the value in the register </span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; font-weight: bold; line-height: 19.6000003814697px;">0x75</span><span style="background-color: white; line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif;">, which has a default value the same as </span></span><span style="line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif;">the address (I think it is called the <b><i>WHO_AM_I register</i></b></span></span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 19.6000003814697px;"> - this is where the device itself 'knows' where it is on the </span><b style="line-height: 18.3999996185303px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">I<sup><span style="font-size: x-small;">2</span></sup>C</span></i></b><span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"> bus</span></span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 19.6000003814697px;">), and so it returns the value:</span><br />
<b style="font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"><br /></b>
<b style="font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;">0x68</b><br />
<b style="font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 19.6000003814697px;"><br /></b>
<span style="line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif;">This apparently indicates that everything is working properly. :)</span></span><br />
<span style="line-height: 19.6000003814697px;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span>
<br />
<h3>
<b style="background-color: white;"><span style="font-family: Arial, Helvetica, sans-serif;">The Test Programs</span></b></h3>
<span style="background-color: #fcfcfc; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">I don't pretend to fully understand these programs, which have been written in the C++ language by Richard G Hirst, and available at <a href="https://github.com/richardghirst/PiBits/tree/master/MPU6050-Pi-Demo" target="_blank">https://github.com/richardghirst/PiBits/tree/master/MPU6050-Pi-Demo</a>, but the first one, </span><span style="font-family: Arial, Helvetica, sans-serif;"><i style="font-weight: bold;">demo_dmp</i> outputs the 4 quaternion values, followed by the yaw, pitch and roll values corresponding to the position and movement of the </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>GY-521</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> breakout board.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The second program, </span><i style="font-family: Arial, Helvetica, sans-serif; font-weight: bold;">demo_raw</i><span style="font-family: Arial, Helvetica, sans-serif;"> outputs the values of accelerometer measurements in the x, y and z directions, followed by the </span><span style="font-family: Arial, Helvetica, sans-serif;">gyroscope measurements </span><span style="font-family: Arial, Helvetica, sans-serif;">in the </span><span style="font-family: Arial, Helvetica, sans-serif;">x, y and z directions</span><span style="font-family: Arial, Helvetica, sans-serif;">.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The third program, </span><i style="font-family: Arial, Helvetica, sans-serif; font-weight: bold;">demo_3d</i><span style="font-family: Arial, Helvetica, sans-serif;"> plots the 3D geometrical wireframe object's orientation in space, based on the calculated values mentioned above.</span><br />
<br />
<h3>
<b style="background-color: white;"><span style="font-family: Arial, Helvetica, sans-serif;">What Next?</span></b></h3>
<span style="font-family: Arial, Helvetica, sans-serif;">What I would like to do is use the calculated values to feed to a 2-servo combination to control a self-levelling platform.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I think this might be a bit ambitious, so if anyone out there has any ideas how I could do this, I would be very grateful for your suggestions.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"></span>
<span style="background-color: #f7f7f9; line-height: 15.210000038147px;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-1816088941581303762014-11-12T16:25:00.001+00:002014-12-23T08:49:08.492+00:0056. Exploring the Pi B+'s Ports II - Pulse Width Modulation<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">25,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In a previous post, <a href="http://smokespark.blogspot.co.uk/2013/04/15-programming-attiny85-with.html" target="_blank">http://smokespark.blogspot.co.uk/2013/04/15-programming-attiny85-with.html</a> I experimented with RGB LEDs and control of LED brightness using Pulse Width Modulation (PWM). That post includes explanations of how our human Persistence of Vision (POV) enables us to perceive a flashing LED as having less than maximum brightness. That was using the ATMega 328 (Arduino) chip to program an ATTiny85 microchip to produce Pulse Width Modulation.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
The difference here, of course, is that we are programming the Raspberry Pi in the Python language. Not only are there coding differences, but we are working with 3V3 from the Pi's GPIO logic levels instead of 5V.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
The circuit is a bit simpler than the last post at<br /><a href="http://smokespark.blogspot.co.uk/2014/10/55-exploring-pis-gpio-ports.html" target="_blank">http://smokespark.blogspot.co.uk/2014/10/55-exploring-pis-gpio-ports.html</a>. The switches have been removed as there are now no input GPIO ports, only outputs corresponding to the red, green and blue anodes of the RGB LED. So the RGB LED is wired exactly the same as before - with its common cathode going to GND through a </span><span style="font-family: Arial, Helvetica, sans-serif;">325</span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 18.3999996185303px;"><b>Ω</b></span><span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">resistor. You may have noticed that I still have wires running to GPIO ports 21, 22 and 23. These are not connected to anything on the breadboard - I just forgot to remove them when I took off the switches!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
What the experiment does is simply to increase the brightness of the red LED from zero to maximum, decrease it back to zero, move on the green LED, do the same, and then do this all over again for the blue LED. The routine is in an infinite loop, but can be terminated gracefully by pressing CTRL-C on the keyboard:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dyflfDS15zLcuNZyj2KjjQYmnxjALg94lD5Jf2Zuj9-1fwUoDdw93Tvf4R058ySqIBCT8abUyrm3kOrHaOClA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
For this video, I turned the ambient lighting down, as the LED colours all look white to the camera, in bright light. You can see that there is a little bit of flicker, and this is intentional. With a frequency of 40 hertz (40 Hz), my personal vision can detect flicker when the LEDs are in the dim part of their cycle. A higher frequency will easily remove this flicker. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvYYu5rxRMvWu7qN_3jrs4vL3owfQN62suObTSiUk63GAMO3iPSyEKECbAroflNMsdGT8K8GK3KQoO8d3PtSQkorAMbKXwZlEzwSaKhyphenhyphen3xFziMV3800fG00Sou_iJtQEK0HOiHPZUlc0cD/s1600/Untitled-1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="513" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvYYu5rxRMvWu7qN_3jrs4vL3owfQN62suObTSiUk63GAMO3iPSyEKECbAroflNMsdGT8K8GK3KQoO8d3PtSQkorAMbKXwZlEzwSaKhyphenhyphen3xFziMV3800fG00Sou_iJtQEK0HOiHPZUlc0cD/s640/Untitled-1.jpg" width="640" /></span></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />It's interesting that this looping program doesn't use much in the way of processor resources. You can see from the above image of the Pi's desktop, that the Raspberry Pi's CPU indicator is fairly activity-free, presumably because the code keeps the processor in the idle state for most of the time with the <b><i>sleep()</i></b> command. </span><br />
<script src="https://gist.github.com/kcranley1/ec8a7594d8ab9c1f23e3.js"></script><span style="font-family: Arial, Helvetica, sans-serif;">This experiment has been using software controlled PWM. There are some GPIO pins (<b><i>GPIO12</i></b>, <b><i>GPIO13</i></b> & <b><i>GPIO18</i></b> - although I have also seen <b><i>GPIO18</i></b> described as <b><i>the PWM pin<span style="color: red; font-size: large;">*</span></i></b>) which are labelled PWM and therefore seem to have a special role in pulse width modulation. When I find out how and when to use these, I'll post it up.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<b style="font-family: Arial, Helvetica, sans-serif;"><i><span style="color: red; font-size: large;">*</span></i></b><span style="font-family: Arial, Helvetica, sans-serif;"> servos require accurately timed pulses - which software alone cannot always provide, but </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>GPIO18</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> with special software can (not sure I understand the subtleties here).</span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-29394803146033513362014-10-31T17:20:00.002+00:002014-11-12T18:09:48.387+00:0055. Exploring the Pi B+'s GPIO Ports I - The J8 Header<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">24,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Before I start this blog post, I would like to acknowledge the great contribution to the subject by Alex Eames, of <a href="http://raspi.tv/">RasPi.TV</a>, who has blogged most of what I have done below. As usual I have described my take on the things that I learn, this time on the various lessons Alex has described. Much of what follows here has been taken from Alex's work. My record serves as a reference for myself, while hopefully being of possible use to other enthusiasts interested in exploring the Raspberry Pi. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">As my Raspberry Pi Model A is dedicated to my <a href="http://smokespark.blogspot.co.uk/2014/02/46-robotics-pibot-1-assembling-pibot.html" target="_blank">PiBot</a>, and my Model B is tied up with the <b><a href="http://smokespark.blogspot.co.uk/2014/09/raspberry-pi-set-up-to-continually.html" target="_blank">windguru</a></b> project (I have a duplicate system at home, as well as one at the yacht club), I had a good excuse to buy the latest Model B+ Pi (see description <a href="http://www.raspberrypi.org/products/model-b-plus/" target="_blank">HERE</a>). The detailed differences and improvements on this latest model are explained elsewhere, but basically, there are now 40 pins on the GPIO header, and these are summarised below:</span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizEuDHnfDHB9mTqVKfsef3K3ei_2kFEnPrwyBmvOoR2KpN4SWRxMG8wp8Kn6XQhdsg0LgVYr9LCNzsUmE6husR1Vdp_fyYlpeLfckE3_nfxHLTp4JuNXjE1UbUOwKgehWwm-UbKaW8M511/s1600/Pi_B+Pins.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizEuDHnfDHB9mTqVKfsef3K3ei_2kFEnPrwyBmvOoR2KpN4SWRxMG8wp8Kn6XQhdsg0LgVYr9LCNzsUmE6husR1Vdp_fyYlpeLfckE3_nfxHLTp4JuNXjE1UbUOwKgehWwm-UbKaW8M511/s1600/Pi_B+Pins.jpg" height="611" width="640" /></span></a><span style="font-family: Arial, Helvetica, sans-serif;"><br />I have added in the alternative functions of ports where they apply, to Alex's diagram. I took advantage of the opportunity to dress my Pi up in a swanky hot-chilli red Pibow Coupé case (available from Pimoroni <a href="http://shop.pimoroni.com/products/b-pibow-coupe" target="_blank">HERE</a>), which protects it from dust and other hazards like spilled tea, falling screwdrivers, curious cats, etc. The Pibow case has convenient openings for connections, and the opening for the 40 GPIO pins has the pin port numbers etched beside them:</span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc9Hb6RKPF8662z_MmqrLrIqWI05jOI-fCxQwboDCBvP4SRieV3wacZVw2PqG92UQlj1E2gY86pAWERg8c1mZKGty-7i_vGr9gPQ6XsodM6SyXe2cIPNKrHy4iX777Kgak4mnc7ZDLNIFi/s1600/PA302146.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc9Hb6RKPF8662z_MmqrLrIqWI05jOI-fCxQwboDCBvP4SRieV3wacZVw2PqG92UQlj1E2gY86pAWERg8c1mZKGty-7i_vGr9gPQ6XsodM6SyXe2cIPNKrHy4iX777Kgak4mnc7ZDLNIFi/s1600/PA302146.JPG" height="480" width="640" /></span></a><span style="font-family: Arial, Helvetica, sans-serif;"><br />I even went one step further and treated myself to a Cyntech B+ 40-way Paddle Board (<a href="http://shop.cyntech.co.uk/products/40-way-raspberry-pi-b-paddle-board" target="_blank">HERE</a>), which makes it easier to get access to the GPIO ports. This board allows connection of jumper wires, by pushing the orange tabs down, inserting the wire (which needs to be stripped at the end to a length of about 10mm). Pre-manufactured jumper wire connector ends are not long enough. However, when stripped wire is connected, a very reliable connection is achieved:</span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCXql8dc64NHPSvQXlbPSDSe1guxXiP74UnvQFuiycTeVDVFKIgJ0uEFtbuE10cQxYCqWblQCmFlm1hUlk2cnbE-d22mHcnlcHNp2azgW8Y_TtUyhEsXoRMOgfp5zxTLZ3T2WkmE6z6cb5/s1600/PA302149.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCXql8dc64NHPSvQXlbPSDSe1guxXiP74UnvQFuiycTeVDVFKIgJ0uEFtbuE10cQxYCqWblQCmFlm1hUlk2cnbE-d22mHcnlcHNp2azgW8Y_TtUyhEsXoRMOgfp5zxTLZ3T2WkmE6z6cb5/s1600/PA302149.JPG" height="480" width="640" /></span></a><span style="font-family: Arial, Helvetica, sans-serif;"><br />I have connected the rainbow ribbon cable to the Pi's J8 header "the wrong way round" as it makes the whole experiment's footprint smaller. I discovered that it is necessary to push the 40-pin connector onto the Paddle Board and through the Pibow case onto the Pi, very firmly, otherwise you can get a 'floating terminal', possibly made worse by an aerial effect from the ribbon cable.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h2>
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: large;"><b>What this Example Does:</b></span></h2>
<span style="font-family: Arial, Helvetica, sans-serif;">There are 4 buttons, referred to as <b><i>Button 0</i></b> (top) and <b><i>Buttons 1, 2</i></b> and <b><i>3</i></b> at the bottom. These buttons are wired to <b><i>GND</i></b> on one side, and on the other terminal, connections are made to <b><i>GPIO ports 20, 21, 22 and 23</i></b> respectively. The RGB LED's common cathode runs to <b><i>GND</i></b> via a 325<span style="line-height: 115%;"><b>Ω</b></span> resistor, so that not too much current is drawn from the Pi. The red, green and blue anodes are wired to the Pi's <b><i>GPIO ports 24, 25 and 26</i></b>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h3>
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif;"><b>The Code Explained:</b></span></h3>
<span style="font-family: Arial, Helvetica, sans-serif;">When the code runs, it firstly prints the message that it is waiting for <b><i>Button 0</i></b> to be pressed to terminate the program. If <b><i>Button 1</i></b> is pressed, the red LED lights up, <b><i>Button 2</i></b> illuminates the green LED and Button 3 switches the blue LED on. These 3 can be pressed randomly ad nauseum, lighting up the respective LEDs. When you get bored, you can press <b><i>Button 0</i></b> and the program will terminate. <b><i>CTRL-C</i></b> will also terminate the program.</span><br />
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
Rather than go through the Python programs as I came across them on Alex's blog, I will start with a fairly advanced example of my own and try to explain what the code means:</span><br />
<script src="https://gist.github.com/kcranley1/26e393c233cc57330292.js"></script><span style="font-family: Arial, Helvetica, sans-serif;">Firstly, let's see what circuit this code works with. The four buttons on the breadboard are Button 0 (at the top) then Button 1, Button 2 and Button 3 (at the bottom):</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC1_oN8oJHOEdCc1LVoXdjpFTJPU-H_o-HTGrWJekI1-i-iN2vcVdumrj7RX6a3iYp5CsupHnFVxxLILCwQ_Zb9z-bzX8_S0Y6KtuOPV5P_4sn1kKdMLupmYeeS_7oJbzWJeg9VYUVXTqt/s1600/PB022159.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC1_oN8oJHOEdCc1LVoXdjpFTJPU-H_o-HTGrWJekI1-i-iN2vcVdumrj7RX6a3iYp5CsupHnFVxxLILCwQ_Zb9z-bzX8_S0Y6KtuOPV5P_4sn1kKdMLupmYeeS_7oJbzWJeg9VYUVXTqt/s1600/PB022159.JPG" height="480" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
<br />
Let's look at the script in detail, so that all aspects of the code can be explained:</span><br />
<b><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b>
<b><span style="font-family: Arial, Helvetica, sans-serif;">Lines 1 & 2:</span></b><br />
<div class="line" id="file-kc3leds-py-LC2">
<span class="c"><span style="color: blue; font-family: Arial, Helvetica, sans-serif; white-space: pre;"><b>1 </b><i> #!/usr/bin/env python2.7</i></span></span><br />
<span class="c"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b>2</b><i> # script by Sparks N Smoke based on Alex Eames at http://RasPi.tv</i></span></span><br />
<span class="c"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><i><br /></i></span></span></div>
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: normal;">These two lines, beginning with a <b><i>#</i></b>, are descriptive comments. </span></span><span style="font-family: Arial, Helvetica, sans-serif;">These comments </span><span style="font-family: Arial, Helvetica, sans-serif;">are </span><span style="font-family: Arial, Helvetica, sans-serif;">always a good idea to indicate the language, acknowledgements etc. </span><span style="font-size: normal;">However there's a bit more to it than that. the characters <b style="font-family: Arial, Helvetica, sans-serif;">#</b><b><i>!</i></b> in Line 1 is what's known as a </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>shebang</i></b><span style="font-size: normal;"> (or a <b><i><span style="font-family: Arial, Helvetica, sans-serif;">hashbang</span></i></b>) - although it starts with a </span><b style="font-family: Arial, Helvetica, sans-serif;">#</b><span style="font-size: normal;">, the normal indicator for a comment, the program loading software uses this information to run the script with the specified version of Python. The Pi currently comes with 2 versions of Python, so the line beginning with the </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>shebang</i></b><span style="font-size: normal;"> identifies which version is to be used and where it is on the Pi's file system.</span><br />
<h4>
<b><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b></h4>
<h4>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Line 4:</b><span style="color: black; font-family: Arial, Helvetica, sans-serif; font-size: normal;"> </span></span></h4>
</div>
<div class="line" id="file-kc3leds-py-LC2" style="color: #333333;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="kn" style="color: blue; font-weight: bold; line-height: 16.7999992370605px;">4 import</span><span style="color: blue; line-height: 16.7999992370605px;"> </span><span class="nn" style="color: blue; line-height: 16.7999992370605px;">RPi.GPIO</span><span style="color: blue; line-height: 16.7999992370605px;"> </span><span class="kn" style="color: blue; font-weight: bold; line-height: 16.7999992370605px;">as</span><span style="color: blue; line-height: 16.7999992370605px;"> </span><span class="nn" style="color: blue; line-height: 16.7999992370605px;">GPIO</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="nn" style="color: blue; line-height: 16.7999992370605px;"><br /></span></span></div>
<div class="line" id="file-kc3leds-py-LC2">
<div>
<span class="c"><span style="color: black; font-family: Arial, Helvetica, sans-serif; font-size: normal;">This line imports the Python module <b><i>RPi.GPIO</i></b> and calls it <b><i>GPIO</i></b> for future reference in the script.</span></span></div>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;"><br /></b></span></h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Line 5:</b></span></h4>
<h4 style="color: #333333;">
<div class="line" id="file-kc3leds-py-LC2" style="font-weight: normal;">
</div>
<div class="line" id="file-kc3leds-py-LC2" style="font-weight: normal;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="kn" style="color: blue; font-weight: bold; line-height: 16.7999992370605px;">5 from</span><span style="color: blue; line-height: 16.7999992370605px;"> </span><span class="nn" style="color: blue; line-height: 16.7999992370605px;">time</span><span style="color: blue; line-height: 16.7999992370605px;"> </span><span class="kn" style="color: blue; font-weight: bold; line-height: 16.7999992370605px;">import</span><span style="color: blue; line-height: 16.7999992370605px;"> </span><span class="n" style="color: blue; line-height: 16.7999992370605px;">sleep</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="n" style="color: blue; line-height: 16.7999992370605px;"><br /></span></span></div>
<div class="line" id="file-kc3leds-py-LC2" style="font-weight: normal;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal;">This is an instruction to the Python interpreter to go to the Python module </span><b style="color: black;"><i>time</i></b><span style="color: black; font-size: normal;"> and load the </span><b style="color: black;"><i>sleep</i></b><span style="color: black; font-size: normal;"> part of it, for use later on.</span></span></div>
</h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;"><br /></b></span></h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Line 6:</b></span></h4>
<h4 style="color: #333333;">
<span class="kn" style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">6 GPIO.setmode(GPIO.BCM)</span></h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal;"><span style="font-weight: normal;">There are two possible modes of referencing the GPIO pins - </span><i>GPIO.BOARD</i><span style="font-weight: normal;"> for pin numbering (see the pin chart above), and </span><i>GPIO.BCM</i><span style="font-weight: normal;"> for Broadcom GPIO numbering</span></span><span style="color: black; font-size: normal; font-weight: normal;">. <span style="font-weight: normal;">The choice of numbering mode is usually a personal preference, but as I needed to refer to the GPIO numbers, I have used the </span></span><span style="color: black; font-size: normal;"><i>GPIO.BCM</i></span><span style="color: black; font-size: normal; font-weight: normal;"> <span style="font-weight: normal;">mode.</span></span></span></div>
</div>
</h4>
<h4 style="color: #333333;">
<span class="kn" style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;"></span></h4>
<h4 style="color: #333333;">
</h4>
<div style="color: #333333;">
<h4>
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;"><br /></b></span></h4>
<h4>
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Lines 8 to 11:</b></span></h4>
<h4>
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="kn" style="color: blue; line-height: 16.7999992370605px;">8 GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP) # Button 0<br />etc</span><span class="kn" style="background-color: white; color: blue; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;"> </span></span></h4>
<h4>
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4>
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal;"><span style="font-weight: normal;">This line sets up the </span><i>GPIO20</i><span style="font-weight: normal;"> pin as an input, and invokes the in-built pull-up resistor</span></span><span style="color: black; font-size: normal; font-weight: normal;">. <span style="font-weight: normal;"> In a similar way, lines 9, 10 and 11 do exactly the same thing for</span> </span><span style="color: black; font-size: normal;"><i>GPIO21</i></span><span style="color: black; font-size: normal; font-weight: normal;">, </span><span style="color: black; font-size: normal;"><i>GPIO22</i></span><span style="color: black; font-size: normal; font-weight: normal;"> <span style="font-weight: normal;">and</span> </span><span style="color: black; font-size: normal;"><i>GPIO23</i></span><span style="color: black; font-size: normal; font-weight: normal;">. <span style="font-weight: normal;">These pins are where the 4 physical buttons are connected.</span></span></span></div>
</div>
</h4>
</div>
<h4 style="color: #333333;">
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
</h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Lines 13 to 15:</b></span></h4>
<h4 style="color: #333333;">
<span class="kn" style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">13 GPIO.setup(24, GPIO.OUT) # LED Red<br />etc</span></h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal;"><span style="font-weight: normal;">This line sets up the </span><i>GPIO24</i><span style="font-weight: normal;"> pin as an output</span></span><span style="color: black; font-size: normal; font-weight: normal;">. <span style="font-weight: normal;">In a similar way, lines 14 and 15 do exactly the same thing for </span></span><span style="color: black; font-size: normal;"><i>GPIO25</i></span><span style="color: black; font-size: normal; font-weight: normal;"> <span style="font-weight: normal;">and</span> </span><span style="color: black; font-size: normal;"><i>GPIO26</i></span><span style="color: black; font-size: normal; font-weight: normal;">. <span style="font-weight: normal;">These pins are where the respective anodes of the RGB LED are connected.</span></span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal; font-weight: normal;"><br /></span></span></div>
</div>
</h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Lines 17 to 21:</b></span></h4>
<h4>
<span class="kn" style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">17 def my_callback1(GPIO24):<br /><span style="line-height: 16.7999992370605px;">18 GPIO.output(24, 1) # Red ON<br /><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">19 sleep(0.5)</span></span></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;"><br />20 GPIO.output(24, 0) </span><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;"># Red OFF</span><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">21 print "</span><span style="background-color: white; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.7999992370605px; white-space: pre;"><span style="color: blue;">BUTTON 1 PRESSED - main thread interrupted by another thread</span></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">"</span></h4>
<h4 style="color: #333333;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal;"><span style="font-weight: normal;">These lines define a function called </span><i>my_callback1</i><span style="font-weight: normal;"> which puts the </span><i>GPIO24</i><span style="font-weight: normal;"> pin in a HIGH state, thus switching on the RED element of the RGB LED</span></span><span style="color: black; font-size: normal; font-weight: normal;"><span style="font-weight: normal;">. I have specified the argument (in the brackets) as the GPIO port, although the word "channel" which Alex uses, also works. Presumably the dummy value satisfies the need to have something there. </span><span style="font-weight: normal;">Line 18 keeps the state the same for half a second, Line 20 then puts </span></span><i style="color: black;">GPIO24</i><span style="color: black; font-size: normal; font-weight: normal;"> <span style="font-weight: normal;">in a LOW state, turning off the RED element and Line 21 puts the message on the screen to indicate that a particular button has been pressed. </span></span></span></h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal; font-weight: normal;"><br /></span>
<span style="color: black; font-size: normal; font-weight: normal;">Similarly, lines 23 to 27 and 29 to 33 do the same for </span><span style="color: black; font-size: normal;"><i>GPIO25</i></span><span style="color: black; font-size: normal; font-weight: normal;"> <span style="font-weight: normal;">and </span></span><span style="color: black; font-size: normal;"><i>GPIO26</i></span><span style="color: black; font-size: normal; font-weight: normal;">. <span style="font-weight: normal;">The functions</span> </span><span style="color: black; font-size: normal;"><i>my_callback1, </i></span><span style="color: black;"><i>my_callback2 </i><span style="font-weight: normal;">and</span><i> </i></span><i style="color: black;">my_callback3 </i><span style="color: black; font-weight: normal;">are only executed when other lines of code call for them by name. However, when they are executed, they run in a different thread. This means that two things are running at the same time.</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
</h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Lines 35 to 37:</b></span></h4>
<h4 style="color: #333333;">
<span class="kn" style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">35 GPIO.add_event_detect(21, GPIO.FALLING, callback = my_callback1, bouncetime = 300)<br />etc</span></h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line">
</div>
</div>
</h4>
<h4 style="color: #333333;">
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal;"><span style="font-weight: normal;">This line sets up the ability to detect an event on pin </span><i>GPIO21</i><span style="font-weight: normal;"> - Button 1, </span><span style="font-weight: normal;">that event being the fall from a HIGH state to a LOW state, of </span></span><span style="font-weight: normal;">pin </span><i>GPIO21</i><span style="color: black; font-size: normal; font-weight: normal;"><span style="font-weight: normal;">. This is where the callback function </span></span><i>my_callback1</i><span style="color: black; font-family: Arial, Helvetica, sans-serif; font-size: normal; font-weight: normal;"><span style="font-weight: normal;"> is invoked. A further interesting argument is </span><i>bouncetime = 300</i><span style="font-weight: normal;">. What this does is to compensate for switch bounce, where the switch actually makes contact more than the intended once per press. If there are any bounces within 300 milliseconds (in this case), they will be ignored.</span></span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; font-size: normal; font-weight: normal;"><span style="font-weight: normal;"><br /></span></span>
<span style="color: black; font-size: normal; font-weight: normal;"><span style="font-weight: normal;">Lines 36 and 37 set up event detection for </span></span><span style="color: black; font-size: normal;"><i>GPIO22</i></span><span style="color: black; font-size: normal; font-weight: normal;"><span style="font-weight: normal;">, (Button2) </span><span style="font-weight: normal;">and</span> </span><span style="color: black; font-size: normal;"><i>GPIO23</i></span></span><span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;"> </span><span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;">(Button 3)</span><span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;">. </span><br />
<br /></div>
</div>
</h4>
<h4 style="color: #333333;">
<span class="c" style="color: #999988; font-family: Arial, Helvetica, sans-serif;"><b style="color: black;">Lines 39 to 48:</b></span></h4>
<h4>
<span class="kn" style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;">39 </span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="k" style="line-height: inherit;">try</span><span class="p" style="line-height: inherit;">:</span></span></h4>
<h4>
<b style="line-height: inherit;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="k">40 print</span> <span class="s">"Main thread waiting for falling edge on port 20 - ie BUTTON 0"</span></span></b></h4>
<h4>
<b style="line-height: inherit;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="n">41 GPIO</span><span class="o">.</span><span class="n">wait_for_edge</span> <span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="n">GPIO</span><span class="o">.</span><span class="n">FALLING</span><span class="p">)</span></span></b></h4>
<h4>
<b style="color: #333333; line-height: inherit;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="k">42 print</span> <span class="s">"Falling edge on port 20 detected. BUTTON 0 PRESSED"</span></span></b><span style="color: blue; font-family: Arial, Helvetica, sans-serif; line-height: 16.7999992370605px;"> </span></h4>
<h4>
<b style="color: #333333; line-height: inherit;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="k">44 except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span></span></b></h4>
<h4>
<b style="color: #333333;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;">45 <span class="n">GPIO</span><span class="o">.</span><span class="n">cleanup</span><span class="p">()</span> <span class="c"><i># Reset ports on CTRL-C</i></span></span></b></h4>
<div>
<b style="color: #333333;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="c"><i><br /></i></span></span></b></div>
<h4>
<b style="color: #333333;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><span class="k">47 finally</span><span class="p">:</span></span></b></h4>
<h4>
<b style="color: #333333;"><span style="color: blue; font-family: Arial, Helvetica, sans-serif;">48 <span class="n">GPIO</span><span class="o">.</span><span class="n">cleanup</span><span class="p">()</span> <span class="c" style="font-style: italic;"># Reset on normal exit</span></span></b></h4>
<pre class="line-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: initial !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; line-height: inherit !important; padding: 0px !important;"><div class="line" id="file-kc3leds-py-LC48">
<h4 style="color: #333333; white-space: normal;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal; line-height: inherit;">This is the main "thread" of the program, where the Pi's processor is in a relatively idle state, just waiting for something to happen. The event it is waiting for is when pin </span><i style="line-height: inherit;">GPIO20</i><span style="font-weight: normal; line-height: inherit;"> - Button 0, </span><span style="font-weight: normal; line-height: inherit;">falls from its initial HIGH state to the LOW state, that is, when the button is pressed.</span></span></h4>
<h4 style="color: #333333; white-space: normal;">
<span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;">When Button 0 is pressed, the execution of the code jumps to Line 47 and 48, where all the GPIO ports are reset to an initial LOW state, ready for other programs to be executed without receiving a message stating that the port it wants to use is already in use.</span></h4>
<h4 style="color: #333333; white-space: normal;">
<span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;">There is an exception to this flow - when </span><i style="font-family: Arial, Helvetica, sans-serif;">CTRL-C</i><span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;"> is pressed on the keyboard. This is called a keyboard interrupt and it will terminate the program, but only after Line 45 is executed - cleaning up the GPIO ports.</span></h4>
<h4 style="color: #333333; white-space: normal;">
<span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;">The program uses the method known as </span><i style="font-family: Arial, Helvetica, sans-serif;">Threaded Callback Interrupts</i><span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;"> where the callback functions run in a separate thread from the main program. This is less demanding on the processor as most of the activity is in a fairly idle state.</span></h4>
<h4 style="color: #333333; white-space: normal;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;">An alternative and simpler method is to use </span><i>Polling</i><span style="font-weight: normal;">, where a </span><i>while True</i><span style="font-weight: normal;"> loop keeps running until an event happens like a button press. The CPU activity is shown in the bottom right of the Pi's desktop. The image below shows the desktop for the current </span></span><i style="font-family: Arial, Helvetica, sans-serif;">Threaded Callback Interrupts</i><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;">. </span></span></h4>
</div>
</pre>
<h4 style="color: #333333;">
<div class="line">
<div class="line" id="file-kc3leds-py-LC2">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifA_Bq-gvIrqoxozKjSD6NxbNaL5rmB0f8mV3zKOTAh_l71bdCak4KEvcvEQHMpdQ_XZtM5X5bEoQszK6VWfnBosGna8vxr875Z1WgytrkMNEVvCPDompPrkXj43XH2CTy6GUEoT3htJvo/s1600/KC3LEDS.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifA_Bq-gvIrqoxozKjSD6NxbNaL5rmB0f8mV3zKOTAh_l71bdCak4KEvcvEQHMpdQ_XZtM5X5bEoQszK6VWfnBosGna8vxr875Z1WgytrkMNEVvCPDompPrkXj43XH2CTy6GUEoT3htJvo/s1600/KC3LEDS.jpg" height="514" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;">Compare the CPU indicator with that for an earlier one-button </span></span><i style="font-family: Arial, Helvetica, sans-serif;">Polling</i><span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;"> program:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif; font-weight: normal;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD9yZtjtXKCWRWAieTR_tSUEVwENzrUpVzWY6gXMnQVWBAnSifY77866X4oHkZMn3viowCG0CoRa7SktPy5m0i83-Izkp9BYNlx1iMuOzBM7uWcGetSjSOmhm-By_cCk6YLUSnkcQCXmuV/s1600/ScreenCapture1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD9yZtjtXKCWRWAieTR_tSUEVwENzrUpVzWY6gXMnQVWBAnSifY77866X4oHkZMn3viowCG0CoRa7SktPy5m0i83-Izkp9BYNlx1iMuOzBM7uWcGetSjSOmhm-By_cCk6YLUSnkcQCXmuV/s1600/ScreenCapture1.jpg" height="514" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;"><br /></span></span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;">This heavy use of the processor would presumably consume more power - a point that is important when using batteries.</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;"><br /></span></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-weight: normal;">Thanks Alex !</span></span></div>
</div>
</h4>
<h4 style="color: #333333;">
</h4>
</div>
</div>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-50570020204866375102014-09-23T09:43:00.001+01:002018-11-18T14:55:33.473+00:0054. Raspberry Pi set up to continually display a dynamic web page<div class="MsoNormal" style="background: white; margin: 0cm 6pt 0.0001pt 0cm; text-align: left;">
<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">23,000 page views!!</b><br />
<span style="color: #333333; font-family: "helvetica" , sans-serif; font-size: 12pt;">The task is to have
a screen displaying a web page continually.
The web page contains the ‘live’ data from a specific sailing club </span><b style="color: #333333; font-family: Helvetica, sans-serif; font-size: 12pt;">windguru</b><span style="color: #333333; font-family: "helvetica" , sans-serif; font-size: 12pt;"> station. This data is displayed in graphical form and
is updated every minute:</span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<iframe align="center" height="560" src="https://www.windguru.cz/station/164" width="640"></iframe>
<span style="color: #333333; font-family: "helvetica" , sans-serif; font-size: 12pt;">The </span><b style="color: #333333; font-family: Helvetica, sans-serif; font-size: 12pt;">windguru</b><span style="color: #333333; font-family: "helvetica" , sans-serif; font-size: 12pt;"> station is an
anemometer which has been positioned at the top of a 10 metre flag pole, to
measure wind speed and direction. A temperature
probe is included. The device is
positioned so that its calibrated direction is pointing to true north. The signals from the anemometer are
transmitted wirelessly from a battery-powered transmitter beside the anemometer, to a unit
in the club house which is wired to the wi-fi router. Information is sent to the </span><b style="color: #333333; font-family: Helvetica, sans-serif; font-size: 12pt;">windguru</b><span style="color: #333333; font-family: "helvetica" , sans-serif; font-size: 12pt;"> server which delivers the above information to the web.</span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The <b>Raspberry Pi</b> and
associated cables, WiFi dongle, case and ultra mini wireless keyboard and
trackpad were purchased from Pimoroni for less than £100. It’s a Model B+ which has a 700MHz CPU, 512MB
RAM, micro SD slot, 4 USB ports and a full size HDMI port. The NOOBS software allows a choice of Linux
operating systems and resides on an 8 GB micro SD card. I chose the Raspbian Debian
Wheezy version of Linux. The Pi is
powered via USB connection to the TV to which it is connected. The video signals are sent to the TV via an
HDMI connection. The VESA mount allows
the Pi in its case to be mounted at the back of a TV, thereby being totally
concealed.<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">Normally the Pi will boot up to the command line prompt, requiring a
username and password to be entered, followed by a command like <b><i>startx</i></b>
to start a Windows-like desktop, or other application. To display web pages, the on-board
lightweight web browser, Midori, would normally have to be started manually and
prompted with the required web address.<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The requirement here is to by-pass the login process and the manual
starting of Midori.<o:p></o:p></span></div>
<div style="border-bottom: dotted windowtext 3.0pt; border: none; mso-element: para-border-div; padding: 0cm 0cm 1.0pt 0cm;">
<h1 style="border: none; mso-border-bottom-alt: dotted windowtext 3.0pt; mso-padding-alt: 0cm 0cm 1.0pt 0cm; padding: 0cm;">
<span style="font-family: "helvetica" , "sans-serif";">Steps
to take are as follows:<o:p></o:p></span></h1>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<!--[if !supportLists]--><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">a.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">Download and
install programs using the following commands:<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "consolas"; font-size: 10.5pt;">sudo apt-get install matchbox<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "consolas"; font-size: 10.5pt;">matchbox is </span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">a “very lightweight fullscreen-only
kiosk-specialized window manager” which is needed to ensure that the Midori web
browser displays in full screen.</span><span style="color: #333333; font-family: "consolas"; font-size: 10.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "consolas"; font-size: 10.5pt;">sudo apt-get install x11-xserver-utils<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">This contains useful utilities which can be invoked, as shown below.<o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: dotted windowtext 3.0pt; border: none; mso-element: para-border-div; padding: 0cm 0cm 1.0pt 0cm;">
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<br /></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraphCxSpFirst" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<!--[if !supportLists]--><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">b.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">Edit existing
system files (using </span><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">nano</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">):</span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraphCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<!--[if !supportLists]--><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">1.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">/etc/network/interfaces<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<!--[if !supportLists]--><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">2.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">/etc/profile/<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<!--[if !supportLists]--><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">3.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">/etc/inittab<o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">c.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">Write a script:<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The
script I wrote is called </span><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">autowindguru</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> and it can be executed with
the command line<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">xinit
./autowindguru<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">which
is executed within the </span><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">profile</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> file.<o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: double windowtext 2.25pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-element: para-border-div; padding: 0cm 0cm 1.0pt 0cm;">
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "courier new"; font-size: 12pt; text-indent: -18pt;">1.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><span style="color: #333333; font-family: "courier new"; font-size: 12pt; text-indent: -18pt;">interfaces</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12pt; text-indent: -18pt;"> contains the
Wireless network/SSID and the wireless key.</span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">An example of the content of this file is:<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<br /></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">auto lo<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">iface lo inet
loopback<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">iface eth0 inet
dhcp<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<br /></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">allow-hotplug wlan0<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">auto wlan0<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<br /></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">iface wlan0 inet
dhcp<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">wpa-ssid ###########<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">wpa-psk ##########</span></b><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;"> </span></b><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">(actual codes are
hidden here)<o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">2.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">profile <o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">I
added, at the last line of this (quite long) file, <o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">xinit
./autowindguru<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">to
run the </span><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">autowindguru</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">
script (see below) which I wrote to run the web page.<o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">3.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">inittab</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The
following link was where I got the instructions to modify the </span><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">inittab</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> file:<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"><a href="http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html">http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html</a><o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm 12pt 18pt; padding: 0cm; text-indent: -18pt;">
<span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">4.<span style="font-family: "times new roman"; font-size: 7pt;"> </span></span><!--[endif]--><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">autowindguru</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"><o:p></o:p></span></div>
</div>
<div style="background: white; border-bottom: solid #EEEEEE 1.0pt; border: none; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-element: para-border-div; padding: 0cm 0cm 4.0pt 0cm;">
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">I
created a script which I named </span><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">autowindguru</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> </span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">as follows:</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"><o:p></o:p></span></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">#!/bin/sh<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">xset –dpms<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">xset s off<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">#unclutter &<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">matchbox-window-manager
&<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">while true; do<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">midori –e
Fullscreen –a http://www.clyc.info/wp-content/uploads/windguruPageLarge.htm<o:p></o:p></span></b></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 10.5pt;">done<o:p></o:p></span></b></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<br /></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The url included above points to the web page </span><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">windguruPageLarge.htm</span></b><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> which I developed and uploaded to the </span><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">www.clyc.info</span></b><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> server.<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The </span><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">xset</span></b><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> lines invoke the </span><span style="color: #333333; font-family: "consolas"; font-size: 10.5pt;">x11-xserver-utils</span><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> utility which was downloaded and installed earlier. They prevent screen blanking due to
inactivity.<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">unclutter</span></b><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"> has been commented
out, but could be used to remove the mouse cursor if it became a nuisance.<o:p></o:p></span></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The </span><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">while true; do………done
</span></b><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">code opens the browser in a loop, so that “it will re-start itself if
something crashes”.<o:p></o:p></span></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , sans-serif; font-size: 12pt;">Some of these tips came from the
following link:</span></div>
<div class="MsoNormalCxSpMiddle" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin: 12pt 0cm; padding: 0cm;">
<span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;"><a href="https://github.com/MobilityLab/TransitScreen/wiki/Raspberry-Pi">https://github.com/MobilityLab/TransitScreen/wiki/Raspberry-Pi</a></span></div>
</div>
<h1>
<span style="font-family: "helvetica" , "sans-serif";">The Web Page<o:p></o:p></span></h1>
<div class="MsoNoSpacing">
<span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The
web page to be displayed consists of a 2 x 2 table, with the top row containing
the basic <b>windguru</b> web page on the
left, and the specific <b>windguru</b>
8-day forecast on the right.<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">The
bottom row includes Javascript for current moon phase (from <b>MoonConnection</b>) on the left and local
tide times from <b>tidetimes</b> on the
right.<o:p></o:p></span></div>
<div class="MsoNoSpacing" style="margin-top: 12.0pt;">
<span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">There are 2 versions of the web page: <o:p></o:p></span></div>
<div class="MsoNoSpacing" style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 12.0pt; mso-list: l1 level1 lfo4; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">1.<span style="font-family: "times new roman"; font-size: 7pt;">
</span></span><!--[endif]--><span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">one
for 1366 x 768 pixel screens (</span><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">windguruPage.htm</span></b><span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">), and <o:p></o:p></span></div>
<div style="border-bottom: dotted windowtext 3.0pt; border: none; margin-left: 18.0pt; margin-right: 0cm; mso-element: para-border-div; padding: 0cm 0cm 1.0pt 0cm;">
<div class="MsoNoSpacing" style="border: none; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 12.0pt; mso-border-bottom-alt: dotted windowtext 3.0pt; mso-list: l1 level1 lfo4; mso-padding-alt: 0cm 0cm 1.0pt 0cm; padding: 0cm; text-indent: -18.0pt;">
<!--[if !supportLists]--><span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">2.<span style="font-family: "times new roman"; font-size: 7pt;">
</span></span><!--[endif]--><span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">one
for 1920 x 1080 screens (</span><b><span style="color: #333333; font-family: "courier new"; font-size: 12.0pt;">windguruPageLarge.htm</span></b><span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt;">) – shown below:<o:p></o:p></span></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWPXpmqLWnRkyuzVntAaW5X8boCPCqu1f2YhB6m44YJjNLGtiiUVvBpYtwiPI6J8xVlrcZsvUdkL9q1ibgYr0K_Dt1I08gC4ixIUtdp3ZBapyHF8WSOCA0GP0GqVSi_UY-pCoqVmOgEOeH/s1600/wg3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="348" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWPXpmqLWnRkyuzVntAaW5X8boCPCqu1f2YhB6m44YJjNLGtiiUVvBpYtwiPI6J8xVlrcZsvUdkL9q1ibgYr0K_Dt1I08gC4ixIUtdp3ZBapyHF8WSOCA0GP0GqVSi_UY-pCoqVmOgEOeH/s1600/wg3.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "helvetica" , sans-serif; font-size: 12pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "helvetica" , sans-serif; font-size: 12pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "helvetica" , sans-serif; font-size: 12pt;">The panels on the
left hand side of this page are dynamic (live), while those on the right need to
be refreshed daily. </span><span style="font-family: "helvetica" , sans-serif; font-size: 12pt;">Daily refreshing can
be done by switching the TV off and on, to re-boot the Pi.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "helvetica" , sans-serif; font-size: 12pt;"><br /></span></div>
<h1 style="background: white; margin-top: 0cm; mso-add-space: auto;">
<span style="font-family: "helvetica" , "sans-serif"; font-size: 12.0pt; font-weight: normal;">Here is a photo of the Raspberry Pi in its PiBow case,
with optional VESA mounting plate (right), and the </span><span class="a-size-large"><span style="font-family: "helvetica" , sans-serif; font-size: 12pt; font-weight: normal;">Rii Portable 2.4GHz ultra
mini handheld rechargeable keyboard with touchpad (it even includes a laser
pointer!)</span></span><span class="a-size-large"><span style="color: #333333; font-family: "helvetica" , "sans-serif"; font-size: 12.0pt; font-weight: normal;">:</span></span></h1>
<h1 style="background: white; margin-top: 0cm; mso-add-space: auto;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1CeqrDzzejn_g9X_ILihykFzq06dAQYL9A7Pltyv4k1aV8DzcsElIIjm3eFZBDMxbRlg26Ta7AQ7JSiLgrPXvXxRFw2gfT-DTcGIHX33S9MxvgXvPAPjccKS95bQQ68deEDoNEnD5wzkY/s1600/P9232052.jpg" imageanchor="1" style="background-color: transparent; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1CeqrDzzejn_g9X_ILihykFzq06dAQYL9A7Pltyv4k1aV8DzcsElIIjm3eFZBDMxbRlg26Ta7AQ7JSiLgrPXvXxRFw2gfT-DTcGIHX33S9MxvgXvPAPjccKS95bQQ68deEDoNEnD5wzkY/s1600/P9232052.jpg" width="640" /></a></h1>
<h1 style="background: white; margin-top: 0cm; mso-add-space: auto;">
</h1>
<div style="background: white; border-bottom: double windowtext 6.75pt; border: none; mso-border-bottom-alt: thin-thick-thin-medium-gap windowtext 6.75pt; mso-element: para-border-div; padding: 0cm 0cm 1.0pt 0cm;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijIaw3lA_msofFI8x_jXHkdP-bXnBlGV2A0yxAwmmdJvAZbhCYJC7kCCJ8OW2PGf4O2S9kOrA8YGw_rlY-y5o5EqYrxCR4lvV5_j6GuTg4enDvVkUXBgpPE-rqz2PK9G-45IL7-yDdW58K/s1600/P9232054.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="448" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijIaw3lA_msofFI8x_jXHkdP-bXnBlGV2A0yxAwmmdJvAZbhCYJC7kCCJ8OW2PGf4O2S9kOrA8YGw_rlY-y5o5EqYrxCR4lvV5_j6GuTg4enDvVkUXBgpPE-rqz2PK9G-45IL7-yDdW58K/s1600/P9232054.jpg" width="640" /></a></div>
<h1 style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin-top: 0cm; padding: 0cm; text-align: center;">
<span style="font-family: "arial" , sans-serif; font-size: small; font-weight: normal;">The Pi Model B+ looks great in it's PiBow case</span></h1>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj2PVnr70GJK3KpY3JvlgD_sfJYGRw9hXMPNlXR-93tC_ngSOjZyWQUGztX16SIlRNvtWWx45vBm6A5wihKexJNWvAO_tOqigY1JDxnufMPgQOGiDMLuezYXW7jm6ZRrFLk2XLM4AifiXi/s1600/P9232055.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj2PVnr70GJK3KpY3JvlgD_sfJYGRw9hXMPNlXR-93tC_ngSOjZyWQUGztX16SIlRNvtWWx45vBm6A5wihKexJNWvAO_tOqigY1JDxnufMPgQOGiDMLuezYXW7jm6ZRrFLk2XLM4AifiXi/s1600/P9232055.jpg" width="640" /></a></div>
<h1 style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin-top: 0cm; padding: 0cm; text-align: center;">
<span style="font-family: "arial" , "sans-serif";"><span style="font-size: small;"><span style="font-weight: normal;">The wireless mini keyboard - a brilliant piece of kit - only 6 inches long!</span></span></span></h1>
<h1 style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; margin-top: 0cm; padding: 0cm;">
<span style="font-family: "arial" , "sans-serif";"><span style="font-size: small;"><span style="font-weight: normal;">PS - this all runs beautifully, but if you need to get in to the command line (LXTerminal), you have to enter </span><i>Ctrl-Alt-F3</i><span style="font-weight: normal;">, and then log in as usual, and run </span><i>startx</i><span style="font-weight: normal;">.</span></span></span></h1>
</div>
<br />
<h1 style="background: white; margin-top: 0cm; mso-add-space: auto;">
<span style="color: #333333; font-family: "arial" , "sans-serif"; font-weight: normal;"> </span></h1>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-2087967785033891372014-05-12T16:28:00.001+01:002014-11-21T10:08:22.266+00:0053. Robotics - Gyroscope & Accelerometer<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">20,000 page views!!</b><span style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's another fantastic piece of technology - the gismo I will describe is a combination of 3-axis Gyroscope, 3-axis Accelerometer - and ... more!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This is it, mounted on the GY-521 breakout board, available from Amazon:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><img src="http://ecx.images-amazon.com/images/I/517YN1H8zCL._SX385_.jpg" height="320" width="310" /><img src="http://ecx.images-amazon.com/images/I/51Mo-JVcSZL._SX385_.jpg" height="195" width="200" /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The whole board is about 20 mm by about 15 mm, and it cost £3.10 including delivery!! It comes with an 8-pin header which needs to be soldered on. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The black chip in the centre is the InvenSense MPU-6050 which contains a MEMS (Microelectromechanical System) gyroscope and MEMS accelerometer, all in one chip, called an Inertial Measurement Unit (IMU). Because each has 3 DOF [3 degrees of freedom (X, Y and Z outputs)], the IMU is said to have 6 </span><span style="font-family: Arial, Helvetica, sans-serif;">degrees of freedom</span><span style="font-family: Arial, Helvetica, sans-serif;">. </span><span style="font-family: Arial, Helvetica, sans-serif;">The IMU also contains a microprocessor [embedded Digital Motion Processor (DMP)] which carries out some basic calculations involving <b><i>quaternions</i></b>. (That's where the maths become difficult).</span><span style="font-family: Arial, Helvetica, sans-serif;"> It even monitors its own chip temperature (and this can be read out) for real-time data correction.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">However, apart from its very impressive performance, which is simple to understand, getting it to work is not easy, and understanding the extensive mathematics and the lengthy code is far from easy.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h2>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Gyroscope</span></h2>
<span style="font-family: Arial, Helvetica, sans-serif;">Let me first explain what a gyroscope (or gyro) is: The early types of gyroscope included a spinning wheel of some kind. Because of the angular momentum involved, the device tries to maintain its position in space, and will resist forces which try to turn it away from its present position. One kind of electronic gyroscope uses a piezoelectric vibrating crystal which will also resist external forces. The device will generate an electrical signal when it detects such a <b><i>Coriolis</i></b> force and this signal can be processed to give information about the angular velocity, or rate of rotation </span><span style="font-family: Arial, Helvetica, sans-serif;">about each of its axes</span><span style="font-family: Arial, Helvetica, sans-serif;">. However, gyro readings 'creep' over time and so on its own, a gyro would not be useful for controlling orientation.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h2>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Accelerometer</span></h2>
<span style="font-family: Arial, Helvetica, sans-serif;">An accelerometer is a bit different. This device, also with micro-mechanical components, if falling freely, will generate no signal. On the other hand, an accelerometer at rest on the surface of the Earth will experience the acceleration due to gravity. If the device rotates on an axis other than the vertical, its resulting acceleration in the vertical direction will be an angular component of gravity. It could be moving fast, but if it's free falling or rotating freely, its output will say 'no acceleration'. So the accelerometer on its own would also not be enough to maintain orientation.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<h2>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Quaternions</span></h2>
<span style="font-family: Arial, Helvetica, sans-serif;">The outputs from both the gyro and the accelerometer can be combined using a <b><i>complementary filter</i></b> or more accurately, using a <i><b>Kalman filter</b></i>. Geek Mom Debra at <a href="http://www.geekmomprojects.com/gyroscopes-and-accelerometers-on-a-chip/" target="_blank">http://www.geekmomprojects.com/gyroscopes-and-accelerometers-on-a-chip/</a> gives a great explanation of how the complementary filter can combine the gyro and accelerometer data. Using <b><i>quaternions,</i></b> </span><span style="font-family: Arial, Helvetica, sans-serif;">allowing angles of greater than 180 degrees to be calculated, </span><span style="font-family: Arial, Helvetica, sans-serif;">provides an alternative to the </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>Euler angle </i></b><span style="font-family: Arial, Helvetica, sans-serif;">co-ordinate system which overcomes a problem</span><span style="font-family: Arial, Helvetica, sans-serif;"> known as <b><i>gymbal lock.</i></b> Gymbal lock occurs when two of the rotational axes come into alignment, thus reducing the number of degrees of freedom.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Quaternions were conceived by Irish mathematician William Rowan Hamilton in 1843 as he crossed the Broom Bridge over Dublin's Royal Canal. Today they are fundamental to space ship, robotic and many other control systems as they give a means of avoiding a fourth gymbal in a gyroscope which would be necessary to overcome gymbal lock.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">The in-built microprocessor (DMP) calculates the <i><b>quaternions</b></i>, and the Arduino sketch can output a stream of numbers representing rotations in all directions.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">However, the Arduino Integrated Development Environment (IDE) doesn't have a graphical capability, so if a graphical representation is required, it's necessary to use a further coding IDE called the "<b><i>Processing</i></b>" IDE. The code, like Java, is quite similar to the Arduino sketch code.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<h2>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Arduino code</span></h2>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the Arduino code:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><style type="text/css">
.gist {width:900px !important;}
.gist-file
.gist-data {max-height: 900px;max-width: 900px;}
</style><script src="https://gist.github.com/kcranley1/9e9a935b488c017827a1.js"></script>
<br />
<h2>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Processing code</span></h2>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">and here's the Processing code which reads the Arduino data and performs some neat 3D drawing:</span><br />
<script src="https://gist.github.com/kcranley1/9e74e456632342b0d0f7.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Here's the setup for power and the </span><b><span style="font-family: Arial, Helvetica, sans-serif;"><i>I <sup>2</sup>C</i></span></b><span style="font-family: Arial, Helvetica, sans-serif;"> connections: </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GY 521 <b>VCC</b> to Arduino <b>3.3V</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GY 521 <b>GND</b> to Arduino <b>GND</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GY 521 <b>SCL</b> to Arduino Analog pin 5, <b>A5</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GY 521 <b>SDA</b> to Arduino Analog pin 4, <b>A4</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GY 521<b> INT</b> (interrupt) to Arduino Digital pin <b>2</b></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYtONZe1Ot7pjIPlDzg9C14Nv5tgIhS87Et6OuVO9n_edYLWgAOY1DYMsV8MEQI_cdq1IBuFjZo0Oa366F6fJlRkez_qIIasuHcFSS0tW2GNXsQA39wAobOsxdEHNqaZVheqQ25KgmNc4e/s1600/P5131333.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYtONZe1Ot7pjIPlDzg9C14Nv5tgIhS87Et6OuVO9n_edYLWgAOY1DYMsV8MEQI_cdq1IBuFjZo0Oa366F6fJlRkez_qIIasuHcFSS0tW2GNXsQA39wAobOsxdEHNqaZVheqQ25KgmNc4e/s1600/P5131333.JPG" height="480" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the video: The window on the right shows the Processing IDE.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dxtfVs1lj-mfmqxsz_dkcKhS1HwrBWi9Vs7T1w3QlKOxTSAdYiOT19tRB7KQ2_13MvRgqwCNH2ruPQwd3my7Q' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the demo up close:
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dxE-_c994SvbRA65baJQlIj1IS6k3dH-Prrx4UFcoEElAheNhErSe3MCfnMW4xBpT8velpDbRmBDirQjw_L7w' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Until about 20 seconds into the 2nd video (10 s into the first video), the chip seems to go through a calibration routine, so that it 'gets its bearings' and it appears to monitor the degree of gyro creep, after which presumably a correction is applied to remove that creep. The vagueness in the above statement is because the manufacturers have not divulged the exact details about how this calibration is achieved. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">After this stage in the video, the movement in 3 dimensions is caused by me rotating the mini breadboard containing the </span><span style="font-family: Arial, Helvetica, sans-serif;">GY-521</span><span style="font-family: Arial, Helvetica, sans-serif;"> and then moving it about so that it rotates about its X, Y and Z axes.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">I must acknowledge Geek Mom Debra once more. Her excellent blog at <a href="http://www.geekmomprojects.com/mpu-6050-dmp-data-from-i2cdevlib/" target="_blank">http://www.geekmomprojects.com/mpu-6050-dmp-data-from-i2cdevlib/</a> is where I got her tweaked code, and I'm looking forward to seeing her "side-by-side comparison" between the embedded Digital Motion Processor and complementary filter data when it appears. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Note that the option I have chosen in the Arduino sketch is (lines 84 to 87):</span></div>
<pre class="line-pre" style="background-attachment: initial !important; background-clip: initial !important; background-color: white; background-image: initial !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: 0px !important; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; font-size: 12px; line-height: 16.7999992370605px; padding: 0px !important;"><div class="line" id="file-mpu6050_dmp6kc-LC83">
</div>
<div class="line" id="file-mpu6050_dmp6kc-LC84">
// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
</div>
<div class="line" id="file-mpu6050_dmp6kc-LC85">
// quaternion components in a [w, x, y, z] format (not best for parsing
</div>
<div class="line" id="file-mpu6050_dmp6kc-LC86">
// on a remote host such as Processing or something though)
</div>
<div class="line" id="file-mpu6050_dmp6kc-LC87">
#define OUTPUT_READABLE_QUATERNION</div>
</pre>
<pre class="line-pre" style="background-color: ghostwhite; border: none !important; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 15px; line-height: 7px; padding: 0px !important;"></pre>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">The quaternion option is immune from </span><b style="font-family: Arial, Helvetica, sans-serif;"><i>gymbal lock</i></b><span style="font-family: Arial, Helvetica, sans-serif;">. I found that the baud rate of 57600, which must be set the same on both Arduino and Processing code, worked best for me.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">The aeroplane no longer, if turned through certain large angles, makes sudden 'flips' or simply freezes or even goes into what can only be described as 'the jitters'. The reference <b><a href="http://en.wikipedia.org/wiki/Gimbal_lock" target="_blank">HERE</a></b> tells the story about the Apollo 11 Moon mission on 20-Jul-69 when the IMU (Inertial Measurement Unit) froze due to <b><i>gymbal lock</i></b>.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Mmmmmmmm..... I wonder what this little device could be used for....</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">What's all this stuff about a teapot?? Well apparently the original demonstration used a 3-dimensional teapot which rotated. Now it's just a primitive plane, but it's still called a teapot!!</span></div>
<br />S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-86981999914532766952014-04-16T17:45:00.000+01:002014-05-20T10:53:58.611+01:0052. Robotics with PiBot. VII - The Robot's View, Live on PC Monitor<div style="text-align: center;">
<span style="color: white; font-family: Verdana, sans-serif; font-size: x-large;"><b><i style="background-color: red;">23-Apr-14 Sparks N Smoke is one year old</i></b></span></div>
<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;"><br /></b>
<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">16,000 page views!!</b><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">And here she is:</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dylqSnrEATDcGYQxWJC5uFa3F36CHaWTGsy_ftw-rxMifjj_1t9stWHbJ5ibT_UsW_j5LXITcwh5kXIwljiVQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Yes - that's Poppy - being a little spooked by the PiBot! - Isn't she cute?</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The last post showed how video could be recorded from the RasPiCam as the PiBot went about its travels. The <b><i>.h264</i></b> video file was recorded onto the PiBot's SD card, and later was processed on the Pi, to be 'wrapped' as a<b><i> .mp4</i></b> file. This more common file type was then transferred to the PC using <b>WinSCP</b>, and could be viewed on <b>Windows Media Player</b> or on <b>YouTube</b>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This time, we are running a series of <b><i>JPEG</i></b> images, taken every 100 ms, and transmitting them 'live' to the PC over the WiFi network.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's an example of what was seen on my PC monitor, recorded by <b>Microsoft Expression Encoder 4</b>:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dzp8i9_-zCNs2q-LkGVvgSPb_Q_xnG10xsMm12Mnm4Zu2C7Jh08WPW8yFSl2m_WW8vnyZ-abIQ57ddez6aECw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;">I have left a little bit of margin on the left hand side and at the top so that you can see that this has been captured from my PC screen.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;"><b>Installing MJPG-Streamer:</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The following steps are required to achieve this. We will be using <b>MJPG-Streamer</b>, not <b>picamera</b> as before, so I followed the instructions of <a href="http://blog.miguelgrinberg.com/post/stream-video-from-the-raspberry-pi-camera-to-web-browsers-even-on-ios-and-android" target="_blank">Miguel Grinberg</a> as follows:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px; margin-bottom: 20px;">
To install three libraries which are required by <b>MJPG-Streamer</b>:</div>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ sudo apt</span><span class="pun" style="color: #4d4d4c;">-</span><span class="kwd" style="color: #8959a8;">get</span><span class="pln" style="color: #4d4d4c;"> install libjpeg8</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">dev imagemagick libv4l</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">dev</span></code></pre>
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px; margin-bottom: 20px;">
<b>MJPG-Streamer</b> also requires a header file to be linked:</div>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ sudo ln </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">s </span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">usr</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">include</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">linux</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">videodev2</span><span class="pun" style="color: #4d4d4c;">.</span><span class="pln" style="color: #4d4d4c;">h </span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">usr</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">include</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">linux</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">videodev</span><span class="pun" style="color: #4d4d4c;">.</span><span class="pln" style="color: #4d4d4c;">h</span></code></pre>
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px; margin-bottom: 20px;">
The <b>MJPG-Streamer</b> source code <b>zip</b> file is downloaded from <b>sourceforge</b>:</div>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ wget http</span><span class="pun" style="color: #4d4d4c;">:</span><span class="com" style="color: #8e908c;">//sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip</span></code></pre>
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px; margin-bottom: 20px;">
The source code files are extracted:</div>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ unzip mjpg</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">streamer</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">code</span><span class="pun" style="color: #4d4d4c;">-</span><span class="lit" style="color: #f5871f;">182.zip</span></code></pre>
<h2 style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 25px; line-height: 40px; margin: 16px 0px 10px; text-rendering: optimizelegibility;">
<span style="font-size: 17px; line-height: 25.19999885559082px;">MJPG-Streamer<span style="font-weight: normal;"> is built using some plugins, which are needed to stream video </span></span><span style="font-size: 17px; font-weight: normal; line-height: 25.19999885559082px;">:</span></h2>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ cd mjpg</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">streamer</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">code</span><span class="pun" style="color: #4d4d4c;">-</span><span class="lit" style="color: #f5871f;">182</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">mjpg</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">streamer
$ make mjpg_streamer input_file</span><span class="pun" style="color: #4d4d4c;">.</span><span class="pln" style="color: #4d4d4c;">so output_http</span><span class="pun" style="color: #4d4d4c;">.</span><span class="pln" style="color: #4d4d4c;">so</span></code></pre>
<h2 style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 25px; font-weight: normal; line-height: 40px; margin: 16px 0px 10px; text-rendering: optimizelegibility;">
<span style="font-size: 17px; line-height: 25.19999885559082px;">The required files are put in the right directories:</span></h2>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ sudo cp mjpg_streamer </span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">usr</span><span class="pun" style="color: #4d4d4c;">/</span><span class="kwd" style="color: #8959a8;">local</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">bin
$ sudo cp output_http</span><span class="pun" style="color: #4d4d4c;">.</span><span class="pln" style="color: #4d4d4c;">so input_file</span><span class="pun" style="color: #4d4d4c;">.</span><span class="pln" style="color: #4d4d4c;">so </span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">usr</span><span class="pun" style="color: #4d4d4c;">/</span><span class="kwd" style="color: #8959a8;">local</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">lib</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">
$ sudo cp </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">R www </span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">usr</span><span class="pun" style="color: #4d4d4c;">/</span><span class="kwd" style="color: #8959a8;">local</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">www</span></code></pre>
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 25.19999885559082px; margin-bottom: 20px;">
<b><span style="font-size: x-large;">Running the PiCam:</span></b><br />
<div style="font-size: 17px;">
The camera module is started:</div>
</div>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ mkdir </span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">tmp</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">stream
$ raspistill </span><span class="pun" style="color: #4d4d4c;">--</span><span class="pln" style="color: #4d4d4c;">nopreview </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">w </span><span class="lit" style="color: #f5871f;">640</span><span class="pln" style="color: #4d4d4c;"> </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">h </span><span class="lit" style="color: #f5871f;">480 <span class="pun" style="background-color: transparent; color: #4d4d4c; line-height: 1.5;">-vf -hf</span></span></code><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;"> </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">-</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">q </span><span class="lit" style="background-color: transparent; color: #f5871f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">5</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;"> </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">-</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">o </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">/</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">tmp</span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">/</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">stream</span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">/</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">pic</span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">.</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">jpg </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">-</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">tl </span><span class="lit" style="background-color: transparent; color: #f5871f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">100</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;"> </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">-</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">t </span><span class="lit" style="background-color: transparent; color: #f5871f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">9999999</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;"> </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">-</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">th </span><span class="lit" style="background-color: transparent; color: #f5871f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">0</span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">:</span><span class="lit" style="background-color: transparent; color: #f5871f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">0</span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">:</span><span class="lit" style="background-color: transparent; color: #f5871f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">0</span><span class="pln" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;"> </span><span class="pun" style="background-color: transparent; color: #4d4d4c; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; line-height: 1.5;">&</span></pre>
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px; margin-bottom: 20px;">
making sure the picture is not upside-down, as the PiCam itself is. The first command is needed each time this is run, as the directories made are only kept temporarily. Miguel points out that different options of <b><i>raspistill</i></b> could have been used here. <br />
<br />
I found that the only way to proceed from here was to start a duplicate session in <b>PuTTY</b>, logging in to the Pi in a second <b>PuTTY</b> window:</div>
<h2 style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 40px; margin: 16px 0px 10px; text-rendering: optimizelegibility;">
<span style="font-size: x-large; line-height: 25.19999885559082px;">Running MJPG-Streamer:</span></h2>
<h2 style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 40px; margin: 16px 0px 10px; text-rendering: optimizelegibility;">
<span style="font-size: 17px; line-height: 25.19999885559082px;">MJPG-Streamer</span><span style="font-size: 17px; font-weight: normal; line-height: 25.19999885559082px;"> is started using:</span></h2>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">LD_LIBRARY_PATH</span><span class="pun" style="color: #4d4d4c;">=</span><span class="str" style="color: #718c00;">/usr/</span><span class="kwd" style="color: #8959a8;">local</span><span class="pun" style="color: #4d4d4c;">/</span><span class="pln" style="color: #4d4d4c;">lib mjpg_streamer </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">i </span><span class="str" style="color: #718c00;">"input_file.so -f /tmp/stream -n pic.jpg"</span><span class="pln" style="color: #4d4d4c;"> </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">o </span><span class="str" style="color: #718c00;">"output_http.so -w /usr/local/www"</span></code></pre>
<div style="background-color: white; margin-bottom: 20px;">
<span style="color: #333333; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 17px; line-height: 25.19999885559082px;">Now, using a web browser, I can watch the stream live at the address <a href="http://192.168.1.68:8080/stream_simple.html">http://192.168.1.68:8080/stream_simple.html</a>, where <b>192.168.1.68</b> is my Pi's IP address. Please note that this link will only work from within my own personal wireless network, not on the wider internet.</span></span></div>
<div style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px; margin-bottom: 20px;">
Miguel also recommends cleaning up by removing the source code, after it has been verified that everything is working:</div>
<pre class="prettyprint" style="background-color: #f8f8f8; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; margin-bottom: 20px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="pln" style="color: #4d4d4c;">$ cd </span><span class="pun" style="color: #4d4d4c;">../../</span><span class="pln" style="color: #4d4d4c;">
$ rm </span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">rf mjpg</span><span class="pun" style="color: #4d4d4c;">-</span><span class="pln" style="color: #4d4d4c;">streamer</span><span class="pun" style="color: #4d4d4c;">-</span><span class="lit" style="color: #f5871f;">182</span></code></pre>
<div>
<code style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; padding: 0px;"><span class="lit" style="color: #f5871f;"><span style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 17px; line-height: 25.19999885559082px;">To get the PiBot going, I used the same procedure as before, necessitating a third <b>PuTTY</b> session to be run - connected to <b>TightVNC tvnviewer. </b>Then I ran <b>Geany</b> on the Pi's desktop, and then the python program which is the same as that in the last post, only with all references to <b>picam</b> removed:</span></span></code></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><script src="https://gist.github.com/kcranley1/10264723.js"></script><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;"><b>Capturing the Video on the PC screen:</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Finally, to capture what's being seen on the PC's monitor while the PiBot is roaming around, as I mentioned above, I used </span><b style="font-family: Arial, Helvetica, sans-serif;">Microsoft Expression Encoder 4.</b><span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This free program can be downloaded from <b><a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CDcQFjAB&url=http%3A%2F%2Fwww.microsoft.com%2Fen-gb%2Fdownload%2Fdetails.aspx%3Fid%3D18974&ei=8pNPU7f_JYG-O52bgTA&usg=AFQjCNGl8d4Iosn3TQ8vbw5sMVHDGRmG2g&sig2=1HDqjCk-lG8ZJ_slGfBeSQ&bvm=bv.64764171,d.ZWU" target="_blank">HERE</a></b> and there is an option to upgrade to a paid version which of course, has more options. To install the free version, just skip the part where a product key is required. The free version will only produce <b><i>.wmv</i></b> files, but these are useful and can be uploaded to <b>YouTube</b>. A couple of program files are downloaded - </span><b style="font-family: Arial, Helvetica, sans-serif;">Microsoft Expression Encoder 4 Screen Capture</b><span style="font-family: Arial, Helvetica, sans-serif;"> and </span><b style="font-family: Arial, Helvetica, sans-serif;">Microsoft Expression Encoder 4</b><span style="font-family: Arial, Helvetica, sans-serif;">. To start up, go to </span><b style="font-family: Arial, Helvetica, sans-serif;">Microsoft Expression Encoder 4 Screen Capture</b><span style="font-family: Arial, Helvetica, sans-serif;">, and the following screen window opens up:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9somxnx4i1NwQtT2rL9X5_HBcaPrqpq5NCZ_a5Nm-3bU1ziCYf9fAKcSCjZaOwVP7UbqUmDvelAxGTGg4ndyB-Vqk7cmVcsK48_ncDQ7S9YWBO-sQKKR9WJGUL61Uns47Fxm1eUrhVnN_/s1600/Untitled-1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9somxnx4i1NwQtT2rL9X5_HBcaPrqpq5NCZ_a5Nm-3bU1ziCYf9fAKcSCjZaOwVP7UbqUmDvelAxGTGg4ndyB-Vqk7cmVcsK48_ncDQ7S9YWBO-sQKKR9WJGUL61Uns47Fxm1eUrhVnN_/s1600/Untitled-1.jpg" height="66" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Click on the red <b>Record</b> button on the right, and a rectangle surrounded by a thick red line is placed on the screen. This rectangle can be moved around and re-sized until you're happy with the area of the screen that will be recorded. Press <b>Record</b>, and a countdown <b>3, 2, 1, 0</b> is superimposed and the recording starts. To stop the recording, press <b>Stop</b>. The following window opens:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2z8JK54AfXeqx5oq7VPHyvmdBPdF-Z358Gpo_p6noSuHOuceDK2hkj1JUpWqlCuAe3x-LaKHBhGr7pthTAXunCWj4uvOroTu5oYZnkc6KtH_HEX7uGILjTj2U1omlMf75ldYMbwiUQOY9/s1600/Untitled-2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2z8JK54AfXeqx5oq7VPHyvmdBPdF-Z358Gpo_p6noSuHOuceDK2hkj1JUpWqlCuAe3x-LaKHBhGr7pthTAXunCWj4uvOroTu5oYZnkc6KtH_HEX7uGILjTj2U1omlMf75ldYMbwiUQOY9/s1600/Untitled-2.jpg" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">showing a list of recent recordings, the most recent being at the top. Select the most recent and press <b>Send to Encoder</b>. Animations show the encoder working, and the following screen comes up:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Vbhyphenhyphen0TXrg415JgU5_x7oOH_NOLLKFgYJ4bdaR-3_H7QIlHlZ7nPu5Kjx9CgzQFfNa0l3kGi3b87fUEeFIuqP3luzu-ZLy49goAVOOVNyf-M25RTeq8C7qPoqjm6UMGbsCwaiplhqJr5O/s1600/Untitled-3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Vbhyphenhyphen0TXrg415JgU5_x7oOH_NOLLKFgYJ4bdaR-3_H7QIlHlZ7nPu5Kjx9CgzQFfNa0l3kGi3b87fUEeFIuqP3luzu-ZLy49goAVOOVNyf-M25RTeq8C7qPoqjm6UMGbsCwaiplhqJr5O/s1600/Untitled-3.jpg" height="385" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">The video, in the top left section, can be played and even edited at this point. When the <b>Encode</b> button at the bottom is pressed, the edited version is saved in <b>.wmv</b> format - a <b>Windows Media Audio/Video</b> file. Navigate to this file, and clicking on it will play it on the <b>Windows Media Player</b>.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">I should say that there are lots of options available including selecting the quality, frame rate, adding audio and selecting destinations to save the files in.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">I should also say that I did this in this manner because I couldn't get <b><i>picamera</i></b> python code to control the camera while transmitting images, and that running three <b>PuTTY</b> sessions at the same time is very clumsy. It also seems to interfere with the running of the python program as some funny things happen.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">If there is anybody out there who knows how to make <b><i>picamera</i></b> work with this - please let me know!!</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;"><b>Voil</b>à </span><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-large;"><b>!! </b></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-65275021074202723062014-03-25T12:50:00.000+00:002014-04-15T14:54:33.265+01:0051. Robotics with PiBot. VI - From the Robot's Point of View<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">15,000 page views!!</b><br />
<span style="font-family: Arial, Helvetica, sans-serif;">I got the camera working with the PiBot! I came across a fantastic python library for the RasPiCam, written by Dave Hughes (or is it Davy Jones?) <a href="http://www.raspberrypi.org/archives/5672" target="_blank">HERE</a>. This is an extensive and well-documented (see <a href="https://media.readthedocs.org/pdf/picamera/latest/picamera.pdf" target="_blank">HERE</a>) library called simply <b>picamera</b>, and it allows RasPiCam control to be conveniently incorporated into python programs.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">To install <b>picamera</b>, I did the following on the Pi:</span><br />
<pre style="box-sizing: border-box; color: #404040; font-family: Incosolata, Consolata, Monaco, monospace; font-size: 12px; line-height: 1.5; overflow: auto; padding: 12px;">$ sudo apt-get install python3-picamera</pre>
<span style="background-color: #fcfcfc; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; font-size: 16px; line-height: 24px;">To update the <b><i>operating system</i></b> when new releases of <b>picamera</b> (and other software) are made, use the following:</span><br />
<pre style="box-sizing: border-box; color: #404040; font-family: Incosolata, Consolata, Monaco, monospace; font-size: 12px; line-height: 1.5; overflow: auto; padding: 12px;">$ sudo apt-get update && sudo apt-get upgrade</pre>
<pre style="box-sizing: border-box; color: #404040; font-family: Incosolata, Consolata, Monaco, monospace; font-size: 12px; line-height: 1.5; overflow: auto; padding: 12px;"><span style="background-color: #fcfcfc; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; font-size: 16px; line-height: 24px; white-space: normal;">and to update the Raspberry Pi's <b><i>firmware</i></b>, use</span></pre>
<pre style="box-sizing: border-box; color: #404040; font-family: Incosolata, Consolata, Monaco, monospace; font-size: 12px; line-height: 1.5; overflow: auto; padding: 12px;">$ sudo rpi-update</pre>
<span style="font-family: Arial, Helvetica, sans-serif;">I normally do the last two commands together at regular intervals. Incidentally, there has recently been a PiCam update, enabling more modes of use of the RasPi Cam. See <a href="http://www.raspberrypi.org/archives/6475" target="_blank">HERE</a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the very first movie attempt:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dyF4JTiu9oAUzA_KM4tAbstDWntSMCzfHNRwCVOip0cwCDlH2Dpr7CioWKFhjg3zPpF_EFTxHWFwGq1BS2wvQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<span style="font-family: Arial, Helvetica, sans-serif;">You can see what the robot sees as it's moving around our dining room floor, trying to avoid obstacles like chair legs, table legs and my feet, using its new ultrasonic guidance system. There's no microphone on the PiBot yet, so unfortunately you miss the lovely sounds it makes - but they're exactly the same as the last blog post (see <a href="http://smokespark.blogspot.co.uk/2014/03/50-robotics-with-pibot-v-decision.html" target="_blank">HERE</a>).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's the code which is simply a modification of the previous program - ie using the ultrasonic transducer to navigate without bashing into obstacles and mangling my SD card:</span><br />
<script src="https://gist.github.com/kcranley1/9761331.js"></script>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The <b>picamera</b> library is imported at <i>line 12</i>, the <b>camera</b> object is created at<i> line 39</i>, and <i>line 41</i> sets the pixel values for the video's resolution. The camera <b>preview</b> is started at <i>line 42</i>, and it starts recording at <i>line 43</i>, making a video file called <b><i>foo.h264</i></b>. The orientation of the PiCam is such that the image is upside-down when looking forward, so the vertical and horizontal flips are required at<i> lines 44</i> and <i>45</i>. The <b>camera</b> stops recording at <i>line 64</i> and is shut down at <i>line 65</i>. Dave's advice is always to use the <b><i>picamera.PiCamera.close()</i></b> method on the <b>PiCamera</b> object - as in <i>line 66</i> - to 'clean up resources'. And that's it - the video runs for as long as the movement part of the program executes - about 45 seconds at the moment.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This then produces a video file named </span><i style="font-family: Arial, Helvetica, sans-serif;"><b>foo.h264</b></i><span style="font-family: Arial, Helvetica, sans-serif;">, of the type that we came across in earlier blog posts. A convenient way of 'wrapping' this file as an <b><i>.mp4</i></b> file is to first go to the directory where the </span><i style="font-family: Arial, Helvetica, sans-serif;"><b>foo.h264</b></i><span style="font-family: Arial, Helvetica, sans-serif;"> file lives, ie</span><br />
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b><i>cd python-spi/bot-command/examples</i></b></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;">and </span><span style="font-family: Arial, Helvetica, sans-serif;">use the raspberry pi line command</span><br />
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b><i>MP4Box -add filename.h264 filename.mp4</i></b></span></div>
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b><i><br /></i></b></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;">I got this tip from RasPiTV at the following web page: </span><a href="http://raspi.tv/2013/another-way-to-convert-raspberry-pi-camera-h264-output-to-mp4" style="font-family: Arial, Helvetica, sans-serif;" target="_blank">HERE</a><br />
<span style="font-family: Arial, Helvetica, sans-serif;">for which it's necessary to install the <b>gpac </b>package on the RasPi.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Then, to transfer the<b><i> foo.mp4</i></b> file to the PC for playing on any one of a number of movie players, or for uploading to the web, I used the <b>WinSCP</b> program, which I introduced in an earlier blog post (see <a href="http://smokespark.blogspot.co.uk/2013/06/23-making-time-lapse-sequences-with-pi.html" target="_blank">HERE</a>), running on the PC, and which works just like an FTP program, allowing you to drag 'n drop files from one computer to another. The <b><i>foo.mp4</i></b> file is 11,322 kB in size.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here's another video, processed with <b>VideoPad</b> and saved as a <b><i>.avi</i></b> file - with music!!:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dwX8liSFV1gGutucWpkBHSPBBH-MSpn77QvMLixFbe21OBsNf8LLESdV13T7A-ncAD56aw9bqMHslT57rqlaw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">I must try to get our cat in the picture, some time when she's not sleeping... </span><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;">What's next? I will have to try a bit of panning and tilting!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-450766984419344342014-03-20T16:46:00.000+00:002014-03-25T16:19:15.722+00:0050. Robotics with PiBot. V - Decision Making based on Ultrasound<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">This is hopefully the first in a series of coding exploits where I get to make the PiBot do what I want it to do!</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='640' height='532' src='https://www.blogger.com/video.g?token=AD6v5dylOEI-sUj6xVWx3Vwjur4Tge5rK6Pd7o3HLEgiOADKttQT25QXtn8amoR_9ip4U6UhtCQHsuW7c_8A74fg4w' class='b-hbp-video b-uploaded' frameborder='0'></iframe></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">I was so excited that the PiBot actually started doing what I wanted, that I just had to make a video and publish it. I will replace this one with a better one when I get an improved version.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Here's how the distance sensor works:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHgjozY9yYqhTtpnIsqVIHf3HX8ScRN57itBcuOGVexLvNT8a5f70EorAZFRCY4wGc97qHeZfHMvQR1X63l6ntBB11yh_fBPybkBIaFPxpVnyuigI8wIXhk2BbmgkEpCc7_zW8HM-E19fV/s1600/P3211209.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHgjozY9yYqhTtpnIsqVIHf3HX8ScRN57itBcuOGVexLvNT8a5f70EorAZFRCY4wGc97qHeZfHMvQR1X63l6ntBB11yh_fBPybkBIaFPxpVnyuigI8wIXhk2BbmgkEpCc7_zW8HM-E19fV/s1600/P3211209.JPG" height="480" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">In the above picture, you can see the <b><i>Elec-Freaks HC-SR04 Ultrasonic Ranging module</i></b> at the font of the PiBot. There are two cylindrical eye-like components, the one on the left being the transmitter and the one on the right is the receiver. Think of these as being a speaker and a microphone respectively. The transmitter emits sound in a conical shape, </span><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;">±</span><span style="font-family: Arial, Helvetica, sans-serif;">30</span>⁰<span style="font-family: Arial, Helvetica, sans-serif;"> wide:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWR5YRmMEmK9umVQixxwRFVtUgJF8SMkddrcJbXrpSvm08dxlGQnRzQOWN-i17TpkxTnp1QiQ3D9EYtkItosOAUg_2bSHeq0ak2UJ4_OoPSd33dUmWh70nTW4s4Msv6_zrRHTHX4ODUVBt/s1600/687474703a2f2f617263626f746963732e636f6d2f686f7374696e672f6c742f696d616765732f5475746f7269616c732f4843535230342f4843535230345f537072656164322e706e67.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWR5YRmMEmK9umVQixxwRFVtUgJF8SMkddrcJbXrpSvm08dxlGQnRzQOWN-i17TpkxTnp1QiQ3D9EYtkItosOAUg_2bSHeq0ak2UJ4_OoPSd33dUmWh70nTW4s4Msv6_zrRHTHX4ODUVBt/s1600/687474703a2f2f617263626f746963732e636f6d2f686f7374696e672f6c742f696d616765732f5475746f7269616c732f4843535230342f4843535230345f537072656164322e706e67.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">The specification of the </span><b style="font-family: Arial, Helvetica, sans-serif;">HC-SR04</b><span style="font-family: Arial, Helvetica, sans-serif;"> claims that distances can be measured with an accuracy of up to 3mm from 2cm to 300cm.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">There are 4 pins, <b>Vcc</b>, <b>Trig</b>, <b>Echo</b></span><span style="font-family: Arial, Helvetica, sans-serif;"> and </span><b style="font-family: Arial, Helvetica, sans-serif;">Gnd</b><span style="font-family: Arial, Helvetica, sans-serif;">. The timing chart below shows that when a 10</span>µ<span style="font-family: Arial, Helvetica, sans-serif;">s, 5V pulse is sent to the <b>Trig</b> pin, this initiates a trail of 8 pulses (generated by the piezoelectric crystal, the shiny oblong component between the two 'eyes') allowing the transmitter to emit this signal in a burst of sound pulses. The pulses are emitted with a frequency of 40kHz, making the duration of each '<b>high</b>', 400</span>µ<span style="font-family: Arial, Helvetica, sans-serif;">s. This frequency is classed as<b><i> ultrasound</i></b> as the human ear can only hear frequencies between 20Hz and 20kHz (my personal upper limit is more like 10kHz). See <a href="http://www.youtube.com/watch?v=qNf9nzvnd1k" target="_blank">HERE</a> for a rough test.</span><span style="font-family: Arial, Helvetica, sans-serif;"> This train of pulses causes the </span><b style="font-family: Arial, Helvetica, sans-serif;">Echo</b><span style="font-family: Arial, Helvetica, sans-serif;"> pin to go from <b>low</b> to <b>high</b>.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTSsVnU9ZJ5WoIphs6A2QI1aCYT6cEkaWYDXpRh4597BAOdy57QtoUewqncFF3HK429OZN-3WYVCRzlMw7eanvtfJLtY62C87Viv4eRBpiodaJ7_5_ehx7sYZL9gDVy0j7SM8LAPF4Z8TG/s1600/hc-sr04-timing-chart.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTSsVnU9ZJ5WoIphs6A2QI1aCYT6cEkaWYDXpRh4597BAOdy57QtoUewqncFF3HK429OZN-3WYVCRzlMw7eanvtfJLtY62C87Viv4eRBpiodaJ7_5_ehx7sYZL9gDVy0j7SM8LAPF4Z8TG/s1600/hc-sr04-timing-chart.png" height="280" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">The 40kHz sound signal will of course travel at the speed of sound, in a conical shaped beam, and any reflective object in its path will cause the sound to be reflected back towards the <b>HC-SR04</b>. When the sensor 'eye' detects the reflected sound wave, the<b> Echo</b> pin will return to<b> low</b>. If there is no object to reflect the sound, the <b>Echo</b> pin will return to<b> low</b> after 38ms. The time for which the <b>Echo</b> pin is <b>high</b> is an indicator of the distance to the reflective object:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b><i>distance</i></b> <b> = <i>s.t/2</i></b></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">where <b><i>s</i></b> is the velocity of sound in air (343ms</span><span style="vertical-align: super;">-1 </span><span style="font-family: Arial, Helvetica, sans-serif;">or 1234 kmh</span><span style="vertical-align: super;">-1</span><span style="font-family: Arial, Helvetica, sans-serif;"> in dry air at 20</span>⁰<span style="font-family: Arial, Helvetica, sans-serif;">C) and</span><b style="font-family: Arial, Helvetica, sans-serif;"><i> t</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> is the TTL (time to live) of the </span><b style="font-family: Arial, Helvetica, sans-serif;">high</b><span style="font-family: Arial, Helvetica, sans-serif;"> signal on the </span><b style="font-family: Arial, Helvetica, sans-serif;">Echo</b><span style="font-family: Arial, Helvetica, sans-serif;"> pin. The distance is divided by 2 because the object distance is half of the total round-trip distance covered by the sound pulse.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">After the initial </span><span style="font-family: Arial, Helvetica, sans-serif;">10</span>µ<span style="font-family: Arial, Helvetica, sans-serif;">s, 5V pulse, we wait for at least 100ms before it is repeated. The resulting distance can be calculated every 500 milliseconds or so, keeping the PiBot up-to-date on its distance from obstacles in its path.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">After struggling with the Python code a bit, and getting some help from the PiBot Team, I finally understand that the<b><i> <span class="n" style="background-color: white; color: #333333; line-height: 16.799999237060547px; white-space: pre;">bot</span><span class="o" style="background-color: white; line-height: 16.799999237060547px; white-space: pre;">.</span><span class="n" style="background-color: white; color: #333333; line-height: 16.799999237060547px; white-space: pre;">getUltrasonicDistance</span><span class="p" style="background-color: white; line-height: 16.799999237060547px; white-space: pre;">()</span></i></b></span><span class="p" style="background-color: white; line-height: 16.799999237060547px; white-space: pre;"><span style="font-family: Arial, Helvetica, sans-serif;"> quantity I was reading was in fact of the data type <b>list</b>. On making my variable <b><i>dist</i></b> equal this quantity (making this variable also a<b> list</b>) I then used the first element of the list, <b><i>dist[0]</i></b> in the program, which is of the data type <b>int</b>.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span class="p" style="background-color: white; line-height: 16.799999237060547px; white-space: pre;"><span style="font-family: Arial, Helvetica, sans-serif;">Here's the script:</span></span></div>
<script src="https://gist.github.com/kcranley1/9531810.js"></script>
<br />
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">The problem area had been between lines 41 and 53. This sets up a loop of 300 iterations to read the ultrasound transceiver's distance, and I set it up so that if the distance to any obstacle is 15cm or more, the green lights come on and it's full steam ahead (192, 192). If the distance is less than 15cm, the red lights come on, and the left hand wheel reverses direction (-192, 192), turning the bot through an angle and away from the obstacle - then it's back to full steam ahead with the green tail lights.</span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">After this loops 300 times (this doesn't take very long), the wheels stop and the blue lights come on, in reverse order, to indicate the end of the movement.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Lines 44 and 45 have been split from one long line which wouldn't all fit into the width allowed above. This combined statement removes the square brackets which were enclosing the value of distance displayed on the terminal, by converting </span><b style="background-color: white; font-family: Arial, Helvetica, sans-serif; line-height: 16.799999237060547px; white-space: pre;"><i>dist[0]</i></b><span style="font-family: Arial, Helvetica, sans-serif;"> to a string, and using the string method<b><i> .replace</i></b> to change firstly the <b>[</b> to a space, and then the<b> ] </b>to a space.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The </span><b><i><span style="font-family: Arial, Helvetica, sans-serif;"><span class="n" style="background-color: ghostwhite; line-height: 21.559999465942383px; white-space: pre;">time</span><span class="o" style="background-color: ghostwhite; line-height: 21.559999465942383px; white-space: pre;">.</span><span class="n" style="background-color: ghostwhite; line-height: 21.559999465942383px; white-space: pre;">sleep</span><span class="p" style="background-color: ghostwhite; line-height: 21.559999465942383px; white-space: pre;">(</span><span class="mf" style="background-color: ghostwhite; color: #009999; line-height: 21.559999465942383px; white-space: pre;">0.1</span><span class="p" style="background-color: ghostwhite; line-height: 21.559999465942383px; white-space: pre;">)</span></span></i></b><span style="font-family: Arial, Helvetica, sans-serif;"> statement is quite important as it regulates the speed at which things happen within the loop, in this case, it introduces a delay of 0.1 seconds each time.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">And - it works! So now my SD card won't be getting as much of a bashing as it was!</span></div>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0tag:blogger.com,1999:blog-7808036965409718927.post-14714487289780101092014-03-12T11:36:00.002+00:002014-03-19T09:32:59.466+00:0049. Robotics with PiBot. IV - The PiCam Assembly<div class="separator" style="clear: both;">
<b style="background-color: #fff9ee; color: magenta; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21px;">13,000 page views!!</b></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">You may remember a few blog posts back, I had been advised to skip assembly of Parts 6 and 7 of the PiBot kit, to allow any problems there may have been with the PiBot so far, to be attended to.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">Here are the bits:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyQQONb6HwAZTYrVSOX2FywFQLazx5-kJUU6PJR7rwYYXSFz9rqqe4XGU4M5q4cIK0Pao-0by3XQmwPVhxCIcBCp_UToIILrT1ZQCjo1u21-wXBqN8Ai86tsT2-iUk6Jddg9vcrupRhyphenhyphenBO/s1600/P2071126.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<table border="1"><tbody>
<tr><td><div align="center">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9H4U17l-YfFhOQL4chdlceNDuMH0bn-QO9W_XIBGZSvjBK0vpP61YhtLLQBNPkJ1YXvqQCR1ArirEN19ygkPdy3JY-v-PTr6MI71V7dauqtRC_pCjr9vZsi-pA4RXGJXe9BstTEzI5lFo/s1600/P2071125.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9H4U17l-YfFhOQL4chdlceNDuMH0bn-QO9W_XIBGZSvjBK0vpP61YhtLLQBNPkJ1YXvqQCR1ArirEN19ygkPdy3JY-v-PTr6MI71V7dauqtRC_pCjr9vZsi-pA4RXGJXe9BstTEzI5lFo/s1600/P2071125.JPG" height="240" width="320" /></span></a></div>
</td><td><div align="center">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyQQONb6HwAZTYrVSOX2FywFQLazx5-kJUU6PJR7rwYYXSFz9rqqe4XGU4M5q4cIK0Pao-0by3XQmwPVhxCIcBCp_UToIILrT1ZQCjo1u21-wXBqN8Ai86tsT2-iUk6Jddg9vcrupRhyphenhyphenBO/s1600/P2071126.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyQQONb6HwAZTYrVSOX2FywFQLazx5-kJUU6PJR7rwYYXSFz9rqqe4XGU4M5q4cIK0Pao-0by3XQmwPVhxCIcBCp_UToIILrT1ZQCjo1u21-wXBqN8Ai86tsT2-iUk6Jddg9vcrupRhyphenhyphenBO/s1600/P2071126.JPG" height="240" width="320" /></span></a></div>
</td></tr>
<tr><td><div align="center" class="separator" style="clear: both; text-align: center;">
</div>
<div align="center" class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Part 6. The stepper motor (to pan the PiCam)</span></div>
</td><td><div align="center">
<span style="font-family: Arial, Helvetica, sans-serif;">Part 7. The servo (to tilt the PiCam)</span></div>
</td></tr>
</tbody></table>
</div>
<div class="separator" style="clear: both;">
<span style="font-family: Arial, Helvetica, sans-serif;">I started assembling these, without any instructions, but after a bit of head scratching, I managed to get to the following stage:</span></div>
<table border="1"><tbody>
<tr><td><div align="center">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitHH4mkAlOeW5261-Q7O8vBTyUyFFvF6KaJy60CslDdKUbc27VrtM7_rm1iKiu883wNwBcp0BYFEU32QBrfOlL962Mh72P-yuOmh_a0SGUbvSO4z9naDaCn6mEEf8wlxFVCbmzjqtnbS9A/s1600/P3121181.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitHH4mkAlOeW5261-Q7O8vBTyUyFFvF6KaJy60CslDdKUbc27VrtM7_rm1iKiu883wNwBcp0BYFEU32QBrfOlL962Mh72P-yuOmh_a0SGUbvSO4z9naDaCn6mEEf8wlxFVCbmzjqtnbS9A/s1600/P3121181.JPG" height="240" width="320" /></a></div>
</td><td><div align="center">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBOxtjw5KgS9iVzlhTWKuSx4dhfqOwBVmCa44E-djHvc5M-QqydpXITEvAuOysYWuHTcbOGdqU77maFj34mysr_csBUAYupXyjywfLjCGNkW3EWAwpVcDGlONVmwYGXhPY17ZyMrhJrp-s/s1600/P3121182.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBOxtjw5KgS9iVzlhTWKuSx4dhfqOwBVmCa44E-djHvc5M-QqydpXITEvAuOysYWuHTcbOGdqU77maFj34mysr_csBUAYupXyjywfLjCGNkW3EWAwpVcDGlONVmwYGXhPY17ZyMrhJrp-s/s1600/P3121182.JPG" height="240" width="320" /></a></div>
</div>
</td></tr>
<tr><td><div align="center" class="separator" style="clear: both; text-align: center;">
</div>
<div align="center" class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Part 6. Stepper assembly (to pan the PiCam)</span></div>
</td><td><div align="center">
<span style="font-family: Arial, Helvetica, sans-serif;">Part 6. The stepper motor underneath</span></div>
</td></tr>
</tbody></table>
<span style="font-family: Arial, Helvetica, sans-serif;">Then Part 7:</span><br />
<div>
<table border="1"><tbody>
<tr><td><div align="center">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHrrrP9yMsSrQy8IBW00Qs5uQu-B4D11NrfExyKDWDM36XY5V-bhsmrsvmubHWAe8e4MeP_NwGhPeyTc10ncHcGLaQ_2Tv0qj1_CC2BaeG1lWXhLe_Q9UMYXkc1czx47ET3rohl9xPDB6l/s1600/P3121183.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHrrrP9yMsSrQy8IBW00Qs5uQu-B4D11NrfExyKDWDM36XY5V-bhsmrsvmubHWAe8e4MeP_NwGhPeyTc10ncHcGLaQ_2Tv0qj1_CC2BaeG1lWXhLe_Q9UMYXkc1czx47ET3rohl9xPDB6l/s1600/P3121183.JPG" height="240" width="320" /></a></div>
</div>
</td><td><div align="center">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhZ4I2yNM-o8N9Ts8FJ4DOC7t_5jHWadF6eCgKVvsuvZNr0WAuOCklF7v1eqMhlAMz-nalDZewyAdYtbGc_dJO2548RSbZ2pcNiHXdkFYbntKGHOix1epHRWFFwh79RFkxh19FqN5rR7GN/s1600/P3121184.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhZ4I2yNM-o8N9Ts8FJ4DOC7t_5jHWadF6eCgKVvsuvZNr0WAuOCklF7v1eqMhlAMz-nalDZewyAdYtbGc_dJO2548RSbZ2pcNiHXdkFYbntKGHOix1epHRWFFwh79RFkxh19FqN5rR7GN/s1600/P3121184.JPG" height="240" width="320" /></a></div>
<div class="separator" style="clear: both;">
</div>
</div>
</td></tr>
<tr><td><div align="center" class="separator" style="clear: both; text-align: center;">
</div>
<div align="center" class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">Part 7. Servo tilting assembly (with PiCam)</span></div>
</td><td><div align="center">
<span style="font-family: Arial, Helvetica, sans-serif;">Part 7. View of the servo</span></div>
</td></tr>
</tbody></table>
<span style="font-family: Arial, Helvetica, sans-serif;">Now the combined assembly mounted on PiBot (I had to extend the power and GND wires to the voltage regulator to get the PiCam's ribbon cable connected to the Pi):</span><span style="font-family: Arial, Helvetica, sans-serif;"></span></div>
<table border="1"><tbody>
<tr><td><div align="center">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhck5HF7r3pwqzztTjpVADUzsI5CyRFVRy9KzrXGxq4miwTpLs8f6VCI5vlV5JL81neGzzuAXUkDrBfDFMEaULLw8ldvVkyOKTxy7ry5FgEi7uxos8gIj-vSimA6qPh4Fa7YLwqcsBrlaq1/s1600/P3121185.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhck5HF7r3pwqzztTjpVADUzsI5CyRFVRy9KzrXGxq4miwTpLs8f6VCI5vlV5JL81neGzzuAXUkDrBfDFMEaULLw8ldvVkyOKTxy7ry5FgEi7uxos8gIj-vSimA6qPh4Fa7YLwqcsBrlaq1/s1600/P3121185.JPG" height="240" width="320" /></a></div>
</div>
</td><td><div align="center">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx7C18kSRXXkQAqPpkM6ot87sYbC_U3_CUHxzuzUyKsVPxCXZx3MxkOBNL7fjnjvCGkkDOL9R7sft7FgicKQcZrq_stgAMDmjARP_i5vRb4cPvHkYBZk-qYz92NR53u18n_FhonQmqqu_1/s1600/P3121186.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx7C18kSRXXkQAqPpkM6ot87sYbC_U3_CUHxzuzUyKsVPxCXZx3MxkOBNL7fjnjvCGkkDOL9R7sft7FgicKQcZrq_stgAMDmjARP_i5vRb4cPvHkYBZk-qYz92NR53u18n_FhonQmqqu_1/s1600/P3121186.JPG" height="240" width="320" /></a></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
</div>
</div>
</td></tr>
<tr><td><div align="center" class="separator" style="clear: both; text-align: center;">
</div>
<div align="center" class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">PiBot with full PiCam assembly and PiCam</span></div>
</td><td><div align="center">
<span style="font-family: Arial, Helvetica, sans-serif;">Rear view of PiBot</span></div>
</td></tr>
</tbody></table>
<div>
<span style="font-family: Arial, Helvetica, sans-serif; text-align: center;">And here's the </span><b style="background-color: #fff9ee; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 21.559999465942383px;"><i>test_pibot_hardware.py</i></b><span style="font-family: Arial, Helvetica, sans-serif; text-align: center;"> program running:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='720' height='600' src='https://www.blogger.com/video.g?token=AD6v5dw0PqZ9Uw_YlPVMoS7F3KZu0NgRNajhDJkj6usn0xVGyTf2f1cl51Pr89DMP39qANXXwvdabiwPZUSAXm8kMw' class='b-hbp-video b-uploaded' frameborder='0'></iframe>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">You can see the previous functions going through their paces - wheel motors turning, neopixels illuminating, and the ultrasound transducer working as usual, and in addition, the stepper motor is turning and the servo is rotating. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Brilliant! W</span><span style="font-family: Arial, Helvetica, sans-serif;">e're another step forward!!</span></div>
<br />
<div>
<span style="font-family: Arial, Helvetica, sans-serif; text-align: center;"><br /></span></div>
<div>
<br /></div>
S 'n Shttp://www.blogger.com/profile/09839761336375447790noreply@blogger.com0