{"id":150,"date":"2017-06-05T20:24:55","date_gmt":"2017-06-05T20:24:55","guid":{"rendered":"http:\/\/r.jander.me.uk\/?p=150"},"modified":"2017-06-06T18:19:31","modified_gmt":"2017-06-06T18:19:31","slug":"ev3-text-plotting","status":"publish","type":"post","link":"https:\/\/r.jander.me.uk\/index.php\/2017\/06\/05\/ev3-text-plotting\/","title":{"rendered":"EV3 Text Plotting"},"content":{"rendered":"<p>Okay, so I&#8217;ve been rather quiet on the blogging front for a few weeks &#8211; that&#8217;s because I&#8217;ve been working on getting my <a href=\"http:\/\/www.jander.me.uk\/LEGO\/plott3r.html\">Plott3r<\/a>\u00a0to write out text:<\/p>\n<figure id=\"attachment_156\" aria-describedby=\"caption-attachment-156\" style=\"width: 169px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201752595.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-156\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201752595-169x300.jpg\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201752595-169x300.jpg 169w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201752595-768x1365.jpg 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201752595-576x1024.jpg 576w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201752595-1200x2133.jpg 1200w\" sizes=\"auto, (max-width: 169px) 85vw, 169px\" \/><\/a><figcaption id=\"caption-attachment-156\" class=\"wp-caption-text\">ASCII Text<\/figcaption><\/figure>\n<p>Here&#8217;s a video of it taken a little while ago (prior to some of the improvements I&#8217;ve made):<\/p>\n<p><iframe loading=\"lazy\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/_Plz1rC4O9s?feature=oembed\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>This has been rather a journey of discovery. I&#8217;ve blogged <a href=\"http:\/\/r.jander.me.uk\/index.php\/2016\/09\/04\/ev3-mailbox-messaging\/\">previously<\/a>\u00a0about getting a bluetooth message to the EV3 and how I needed to work out a font.<\/p>\n<h3>Font<\/h3>\n<p>The font itself didn&#8217;t prove to be that tricky to work out; it&#8217;s mainly been planned out on 5mm graph paper and simply converted into coordinates. I&#8217;ve tried to have it write the letters as a Left-&gt;Right writer would, so starting on the left side of each character and probably ending on the right. This way moving the the next letter doesn&#8217;t involve a lot of travelling.<\/p>\n<h3>Backlash Correction<\/h3>\n<p>One thing my Plott3r has, is an effort to manage backlash. Since the paper and pen change direction regularly I have a system that pre-moves the paper\/pen a little prior to any change in direction. One thing I hadn&#8217;t realised before is that if I want to move a really small amount I could overshoot where I wanted to be just in my backlash correction. This would cause some oscillation around the correct location in some cases. For example, look at the centre of the spiral below:<\/p>\n<figure id=\"attachment_154\" aria-describedby=\"caption-attachment-154\" style=\"width: 169px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160802113.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-154 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160802113-169x300.jpg\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160802113-169x300.jpg 169w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160802113-768x1365.jpg 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160802113-576x1024.jpg 576w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160802113-1200x2133.jpg 1200w\" sizes=\"auto, (max-width: 169px) 85vw, 169px\" \/><\/a><figcaption id=\"caption-attachment-154\" class=\"wp-caption-text\">Backlash over-compensation<\/figcaption><\/figure>\n<p>The centre of the spiral is crooked due to the pen &#8220;seeking&#8221; around the correct location. My solution to this was to measure where I was before the backlash correction, and after. If I had overshot, then I did not move that particular axis. The results of this improvement on the spiral are below:<\/p>\n<figure id=\"attachment_155\" aria-describedby=\"caption-attachment-155\" style=\"width: 169px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160822179.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-155 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160822179-169x300.jpg\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160822179-169x300.jpg 169w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160822179-768x1365.jpg 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160822179-576x1024.jpg 576w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170506_160822179-1200x2133.jpg 1200w\" sizes=\"auto, (max-width: 169px) 85vw, 169px\" \/><\/a><figcaption id=\"caption-attachment-155\" class=\"wp-caption-text\">Overshoot corrected backlash<\/figcaption><\/figure>\n<h3>Android App<\/h3>\n<p>I wanted to be able to send a message from a spare Android phone to the EV3. Here&#8217;s where <a href=\"http:\/\/ai2.appinventor.mit.edu\/\">App Inventor 2<\/a>\u00a0came in. I had to learn how it worked, along with learning its Scratch-like language, and implementing some fundamental routines, such as storing an IEE754 float. The current instance of the application looks like:<\/p>\n<figure id=\"attachment_152\" aria-describedby=\"caption-attachment-152\" style=\"width: 169px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screenshot_20170605-202431.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-152 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screenshot_20170605-202431-169x300.png\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screenshot_20170605-202431-169x300.png 169w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screenshot_20170605-202431-576x1024.png 576w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screenshot_20170605-202431.png 720w\" sizes=\"auto, (max-width: 169px) 85vw, 169px\" \/><\/a><figcaption id=\"caption-attachment-152\" class=\"wp-caption-text\">EV3 Messenger<\/figcaption><\/figure>\n<p>The user can simply choose between 3 text sizes, and then write their message and press &#8220;Print&#8221;. The BT button is used to set up the Bluetooth connection and the name of the sending device; this is needed so that the EV3 can acknowledge message it receives. I found that if I didn&#8217;t ACK the messages there was a race condition whereby I&#8217;d get duplicate values with the second &#8220;overwriting&#8221; what the first should have been. The core code of the messaging app is below:<\/p>\n<figure id=\"attachment_151\" aria-describedby=\"caption-attachment-151\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/EV3Message.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-151 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/EV3Message-300x279.png\" alt=\"\" width=\"300\" height=\"279\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/EV3Message-300x279.png 300w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/EV3Message-768x713.png 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/EV3Message-1024x951.png 1024w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/EV3Message.png 1067w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-151\" class=\"wp-caption-text\">AI2 Core Code<\/figcaption><\/figure>\n<p>At the start of the block you can see it send its name, and towards the end of the block it waiting for a bluetooth message. It doesn&#8217;t care about the contents of the message, simply that it got one. The EV3G side of the code is as below:<\/p>\n<figure id=\"attachment_159\" aria-describedby=\"caption-attachment-159\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-159 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03-300x103.png\" alt=\"\" width=\"300\" height=\"103\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03-300x103.png 300w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03-768x265.png 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03-1024x353.png 1024w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03-1200x413.png 1200w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/Screen-Shot-2017-06-05-at-20.54.03.png 1414w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-159\" class=\"wp-caption-text\">EV3G Messenger<\/figcaption><\/figure>\n<p>What&#8217;s not shown is the plotting code as that&#8217;s quite complex. It keeps a tally of the location of the last plotted character and works out if the next one will fit; performing &lt;cr&gt;&lt;nl&gt; if needed. The font is variable width, and has a small amount of &#8220;kerning&#8221;, so that letters such as &#8216;j&#8217; and &#8216;q&#8217; can overlap the inter-character space.<\/p>\n<h3>Letter\u00a0Sizes<\/h3>\n<p>I originally was only going to have one letter size, but this would allow for only around 11 characters per line, which isn&#8217;t a lot. Shrinking the letters will result in more artefacts, which I&#8217;ll come on to later, but I think it has a certain &#8220;hand writing&#8221; charm:<\/p>\n<figure id=\"attachment_157\" aria-describedby=\"caption-attachment-157\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201739449-e1496691111980.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-157 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201739449-e1496691111980-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201739449-e1496691111980-300x169.jpg 300w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201739449-e1496691111980-768x432.jpg 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201739449-e1496691111980-1024x576.jpg 1024w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201739449-e1496691111980-1200x675.jpg 1200w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-157\" class=\"wp-caption-text\">Three letter sizes<\/figcaption><\/figure>\n<h3 class=\"mceTemp\">Artefacts<\/h3>\n<p>There are a few artefacts that I&#8217;ve tried and tried to remove. I now think I&#8217;m simply fighting with the simple fact that it&#8217;s made from LEGO bricks and I can only realistically get a certain level of accuracy in the way I&#8217;ve built it. The main artefact left is as below:<\/p>\n<figure id=\"attachment_153\" aria-describedby=\"caption-attachment-153\" style=\"width: 169px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_202213429-e1496691135891.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-153 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_202213429-e1496691135891-169x300.jpg\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_202213429-e1496691135891-169x300.jpg 169w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_202213429-e1496691135891-768x1365.jpg 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_202213429-e1496691135891-576x1024.jpg 576w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_202213429-e1496691135891-1200x2133.jpg 1200w\" sizes=\"auto, (max-width: 169px) 85vw, 169px\" \/><\/a><figcaption id=\"caption-attachment-153\" class=\"wp-caption-text\">Artefacts on 0, G, Q et al<\/figcaption><\/figure>\n<p>If you look at the top and bottom of the 0 (zero), G and Q, there are small overshoots on one side of the diagonal. I think this is down to using Tank Move and the Y axis motor overshooting the target before moving back a little &#8211; a result of the internal PID controller.<\/p>\n<h3>Signing Off<\/h3>\n<p>I&#8217;ll be showing this off again at <a href=\"http:\/\/www.bricktastic.org\/\">Bricktastic<\/a>\u00a0this year, hence all this work. I&#8217;m pleased that, due to my desire to plot text, that the backlash control is better. I figured that I&#8217;d have the Plott3r do one more thing. It now &#8220;signs&#8221; its plots with the URL to this blog \ud83d\ude42<\/p>\n<figure id=\"attachment_158\" aria-describedby=\"caption-attachment-158\" style=\"width: 169px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201803747.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-158 size-medium\" src=\"http:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201803747-169x300.jpg\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201803747-169x300.jpg 169w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201803747-768x1365.jpg 768w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201803747-576x1024.jpg 576w, https:\/\/r.jander.me.uk\/wp-content\/uploads\/2017\/06\/IMG_20170605_201803747-1200x2133.jpg 1200w\" sizes=\"auto, (max-width: 169px) 85vw, 169px\" \/><\/a><figcaption id=\"caption-attachment-158\" class=\"wp-caption-text\">Signing off<\/figcaption><\/figure>\n<p>I now need to put this to bed for a bit whilst I check that all the other models still work. Then I need to get back on with my Loom &#8211; I need to do a little bit of programming for that ready for it to be shown off too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay, so I&#8217;ve been rather quiet on the blogging front for a few weeks &#8211; that&#8217;s because I&#8217;ve been working on getting my Plott3r\u00a0to write out text: Here&#8217;s a video of it taken a little while ago (prior to some of the improvements I&#8217;ve made): This has been rather a journey of discovery. I&#8217;ve blogged &hellip; <a href=\"https:\/\/r.jander.me.uk\/index.php\/2017\/06\/05\/ev3-text-plotting\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;EV3 Text Plotting&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[17,9,16],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-lego","category-mindstorms","tag-ai2","tag-bluetooth","tag-text"],"_links":{"self":[{"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":6,"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/150\/revisions\/165"}],"wp:attachment":[{"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/r.jander.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}