<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>blog - monostable.co.uk</title>
    <description>Code &amp; Electronics</description>
    <link>https://blog.monostable.co.uk</link>
    <atom:link href="https://blog.monostable.co.uk/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Etching Oscillators in Zurich</title>
        <description>&lt;p&gt;&lt;a href=&quot;http://mechatronicart.ch&quot;&gt;The Swiss Mechatronic Art Society&lt;/a&gt; (SGMK) and ANORG hosted a KitSprint in Zurich last weekend which was an effort to bring the local electronics community together, encourage people to document existing electronics kit ideas, create new ones and put them all up on &lt;a href=&quot;https://kitspace.org&quot;&gt;Kitspace&lt;/a&gt;.
This was also part of the closing down celebrations of the ANORG Atelier that has been, for almost a decade, a co-working/co-living space for artists, architects, musicians, bio and electronics hackers — pretty much anyone with an artistic bent and a desire to create.&lt;/p&gt;

&lt;p&gt;A group of about 15 electronics geeks descended on the ANORG space. Our energy was focused on meeting, talking with each other, eating and drinking together, soldering (my &lt;a href=&quot;https://kitspace.org/jelly&quot;&gt;jellyfish bristle-bot kit&lt;/a&gt; was popular with adults and kids alike), but also getting things “Shenzhen Ready!” a phrase coined by Marc Dusseiller, the event’s main organizer, for getting your design into a state to be fabricated — most likely through an order from Shenzhen, China. Calls for making it “Shenzhen Ready!” and to “send it off to China!” would frequently echo the halls interspersed with the noise of the tesla coil Chris Vernon had set up and Heinzme’s experiments with explosives. Some funding was provided by &lt;a href=&quot;https://www.migros-kulturprozent.ch&quot;&gt;Migros Kulturprozent&lt;/a&gt; for travel costs, food and drinks but also to cover the cost of ordering printed circuit boards (PCBs) for those that had brought their projects into a Shenzhen Ready state by Sunday evening.&lt;/p&gt;

&lt;p&gt;The SGMK community had originally been founded by a group of DIY synthesizer geeks so noise makers featured prominently in the projects that were chosen. Oli Jäggi chose to re-make a circuit dubbed the &lt;a href=&quot;https://kitspace.org/boards/github.com/sgmk/solarbird_shenzen_rdy/&quot;&gt;Solar Bird&lt;/a&gt; which had been the first project he etched and soldered after joining the SGMK. This little oscillator is completely solar powered and gives out a cricket-like chirp when it is given enough light. His idea was to take a known working circuit but give it a more interesting, pleasant shape.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/solar_bird_progress.png&quot; alt=&quot;Solar Bird Collage&quot; /&gt;
&lt;em&gt;images: Left and middle, CC-BY-SA, &lt;a href=&quot;https://www.flickr.com/photos/tamberg/&quot;&gt;Thomas Amberg&lt;/a&gt;. Right, &lt;a href=&quot;https://twitter.com/andreaskopp&quot;&gt;Andreas Kopp&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Oli’s method consists of drawing traces by hand to scale, scanning, printing onto a transparency and using that to expose a copper clad board that has a thin layer of photo-sensitive ink. Where the ink has been covered it will remain when bathed in a developer solution and the final bath in an etching solution will remove the copper except for those bits. For the &lt;a href=&quot;https://kitspace.org/boards/github.com/sgmk/solarbird_shenzen_rdy/&quot;&gt;Shenzhen ready version&lt;/a&gt; he converted to format required by the manufacturers by use of KiCad’s Bitmap2Component tool.&lt;/p&gt;

&lt;p&gt;A similar more approachable method, but maybe more laboursome on the part of a workshop instructor, has been developed by Marc. Something he calls &lt;a href=&quot;https://www.hackteria.org/wiki/Diy-CAD&quot;&gt;DIY CAD&lt;/a&gt; (Do It Yourself Children Aided Design) where component footprints are prepared as laminated paper drawings in a scaled up form. People are instructed to draw the outline and tracks of their circuit layout, using pencil on paper first and then then markers on projector transparencies. The drawings are scanned and scaled-down before exposing and etching.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/diy_cad.png&quot; alt=&quot;DIY CAD session&quot; /&gt;
&lt;em&gt;image: &lt;a href=&quot;https://twitter.com/andreaskopp&quot;&gt;Andreas Kopp&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I took two runs at this process and felt I had good success on my second run where I managed to layout a squeaking &lt;a href=&quot;https://kitspace.org/boards/github.com/kasbah/maulwurf&quot;&gt;Maulwurf&lt;/a&gt; (German for mole) from a battery-powered tri nand gate oscillator schematic Marc had provided. I am very happy with the result as it fits neatly into your hand but it also feels natural to stick into a plant pot and leave it there where it will squeak and blink depending on the soil moisture.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/maulwurf_hand.png&quot; alt=&quot;Maulwurf between fingers&quot; /&gt;
&lt;img src=&quot;/images/entry5/maulwurf_plant.png&quot; alt=&quot;Maulwurf in a plant pot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On the whole the community seems to enjoy pushing the boundaries of what the copper plated fiber glass allows. This is paired with a cultivated and shared skill of home-etching which allows you to hold a board in your hands almost immediately after designing it. Some folks at SGMK have even been experimenting with a coating solution which allowed me to make the tips of the mole’s paws silver.&lt;/p&gt;

&lt;p&gt;Home etching is slowly becoming a bit of a lost art in the electronics hobbyist community with PCB batching services for industrial fabrication now being extremely affordable. The immediate feedback and the intution it gives you for the manufacturing process still make it a must for any PCB designer to try though. Using alternative approaches to layout, such as the DIY CAD method, make it a much more fun, artistic process that is a far cry from the frustrations of using your typical PCB layout software.&lt;/p&gt;

&lt;p&gt;But at SGMK there is also much excitement for exploring what can be done with the added layers and processes that come with &lt;em&gt;industrial&lt;/em&gt; manufacture and &lt;em&gt;this&lt;/em&gt; event was about sending them off to China after all! When transferring these designs to the Gerber format, an oft repeated feature is to free all traces of the solder mask which gives the board a home-etched look and contrasts nicely with the solder mask colours in the surrounding space.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/neococo_unagi.png&quot; alt=&quot;NeoCoco and Unagi&quot; /&gt;
&lt;em&gt;Left &lt;a href=&quot;https://kitspace.org/boards/github.com/kimitobo/neocococat/&quot;&gt;NeoCoco Cat PCB&lt;/a&gt; by Tuomo Tamenpää, co-designed with Marc Dusseiller in Taipei (Re-design of the &lt;a href=&quot;https://kitspace.org/boards/github.com/8bitmixtape/8bitmixtapeneo_shenzhenready/&quot;&gt;8Bit Mixtape&lt;/a&gt;).&lt;/em&gt;
&lt;em&gt;Right &lt;a href=&quot;https://kitspace.org/boards/github.com/genericlab/unagi_gar-lampli/&quot;&gt;Unagi (Fish) PCB&lt;/a&gt; by Masato Takemura, Take-Space, Fablab Hamamatsu&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When making my Maulwurf design Shenzhen Ready (!) I chose to expose most of the tracks but keep the solder mask in places where it would make it easier to solder. I also drew the mask, back copper and the front silkscreen with the DIY CAD method. Drawing some fiduciary markers helped to align all the layers in post processing but of course the alignment is still a little rough.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/maulwurf_preview.png&quot; alt=&quot;Maulwurf Shenzhen&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Urs Gaudenz chose to “productize” a circuit he had built up in several hand-made versions already: the &lt;a href=&quot;https://kitspace.org/boards/github.com/gaudilabs/chaoslooper/&quot;&gt;Chaos Looper&lt;/a&gt;. Here an older audio delay chip (PT2399) is tortured into making new and interesting sounds through adjustment of feedback loops. This design is a more mainstream approach: schematic and layout was done in KiCad. The look and feel though was physically mocked up and one side of the PCB copper layer was drafted on paper, with a neuron inspired graphic, as well. Bringing these more creative elements onto the circuit board makes this design stand out and feel complete without an external case.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/chaoslooper.png&quot; alt=&quot;Chaos Looper front&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Marc took on the task of making some other people’s designs Shenzhen Ready (!) while also experimenting with some new class-D amplifier circuits. One of the most striking results is the Shenzhen Ready version of &lt;a href=&quot;http://paperpcb.dernulleffekt.de/doku.php?id=pop_neuron:pop_neuron_main&quot;&gt;Wolfgang Spahn’s Pop Neuron&lt;/a&gt;, an analog neuron simulation. These are usually completely hand-soldered onto prototyping boards during Wolfgang’s workshops. Marc turned the graphic, that is normally printed on paper as a wiring guide, into actual connections on the top copper layers. On the bottom copper we have the typical connections of a prototyping board. Wolfgang joined via video chat as well to better explain the functioning of these circuits and their design.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry5/popneuron.png&quot; alt=&quot;Pop Neuron&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Properly documenting the bill of materials for these projects, so people anywhere in the world can better replicate them, is often still an after thought. In the days leading up the event I pushed myself to put up an &lt;a href=&quot;https://bom-builder.kitspace.org&quot;&gt;alpha version of my BOM builder tool&lt;/a&gt; that could help people with this task. I received good feedback as people started to make use of it though this version can only download/upload BOMs in the Kitspace “native” &lt;a href=&quot;https://github.com/monostable/1clickBOM#usage&quot;&gt;1-click BOM TSV format&lt;/a&gt;.  Over the coming months I plan to expand this and integrate it into &lt;a href=&quot;https://kitspace.org&quot;&gt;Kitspace proper&lt;/a&gt; and hopefully the designers will take the time to document these amazing creations in full.&lt;/p&gt;

</description>
        <pubDate>Sun, 04 Mar 2018 00:00:00 +0000</pubDate>
        <link>https://blog.monostable.co.uk/posts/etching-oscillators-in-zurich</link>
        <guid isPermaLink="true">https://blog.monostable.co.uk/posts/etching-oscillators-in-zurich</guid>
      </item>
    
      <item>
        <title>Growing Your Code With Arduino</title>
        <description>&lt;p&gt;Over the past few years I have been using the Arduino ecosystem more and more for prototyping in a professional setting.&lt;/p&gt;

&lt;p&gt;I have been working on software for the Braille e-book reader prototypes for &lt;a href=&quot;http://bristolbraille.co.uk&quot;&gt;Bristol Braille Technology&lt;/a&gt; and I have finalised the firmware of the inital Kickstarter batch of the &lt;a href=&quot;http://vrgochair.com&quot;&gt;VRGO Chair&lt;/a&gt; virtual reality controller.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry4/vrgo-braille-3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There was a time when I would dismiss Arduino code and as unprofessional and “just for hobby projects” but it has some strong points in its favour that made me abandon these preconceptions long ago:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A packaged development environment that even a mechanical engineer can install and use.&lt;/li&gt;
  &lt;li&gt;A vast selection of re-usable code: any particular module that you think may be suitable for your prototype likely has an open source library or example project for Arduino.&lt;/li&gt;
  &lt;li&gt;Abstractions that save time on looking up documentation and writing boilerplate code.&lt;/li&gt;
  &lt;li&gt;The abstractions also help portability. Code that makes use of the Arduino libraries can be used over a wide range of processors (from 8-bit low clock-speed &lt;a href=&quot;http://energia.nu/&quot;&gt;MSP430&lt;/a&gt; and AVR to powerful ARM Cortex M4 in the form of the Arduino Due and &lt;a href=&quot;https://www.pjrc.com/teensy/index.html&quot;&gt;Teensy&lt;/a&gt; boards).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are downsides of course:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A packaged development environment that anyone that cares the least bit about code formatting will perceive as torture.&lt;/li&gt;
  &lt;li&gt;You lose some control and performance and the abstraction layer can become a source of confusion (e.g. PIN2 on DDRD on your AVR, as it is in the schematic becomes pin number 0 in the Arduino world, but it depends on your processor)&lt;/li&gt;
  &lt;li&gt;While your code is potentially portable it isn’t guaranteed. The devil is in the details of what hardware and processor specific things your code, or your libraries code, makes use of.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are ways to mitigate these issues though and I want to outline some of the coping mechanisms I have been using that have let me use Arduino in a professional setting.&lt;/p&gt;

&lt;p&gt;These techniques have, so far, let me not abandon my code as we move from prototypes to products but let me extend it and let me keep using the flexibility and development speed of the “Arduino way” to my advantage.&lt;/p&gt;

&lt;h2 id=&quot;a-sensible-environment&quot;&gt;A sensible environment&lt;/h2&gt;

&lt;p&gt;If you spend a lot of time writing code you should spend a lot of time getting to know your text-editor. The one embedded inside the cute Arduino IDE is not a good one and you should abandon it with haste. &lt;a href=&quot;http://www.vim.org/&quot;&gt;Vim&lt;/a&gt; and &lt;a href=&quot;https://www.gnu.org/software/emacs/&quot;&gt;Emacs&lt;/a&gt; are the grumpy old men, &lt;a href=&quot;https://atom.io/&quot;&gt;Atom&lt;/a&gt; and &lt;a href=&quot;https://code.visualstudio.com/&quot;&gt;VSCode&lt;/a&gt; are the new kids on the block, but there are millions of good ones, why would you use the Arduino IDE to edit code?&lt;/p&gt;

&lt;p&gt;There is a little preference that I always tick when I install the Arduino IDE. It’s called “Use external editor” and it makes the area with the code go grey and un-editable and refresh whenever the file is saved by something else. I simply use the IDE to compile and upload the code and edit the code itself with Vim.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry4/use_external_editor.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As you code grows even this limited use of the IDE may become annoying in which case I thoroughly recommend switching the project over to &lt;a href=&quot;http://platformio.org/&quot;&gt;PlatformIO&lt;/a&gt;. Ejecting your Arduino project from the IDE to PlatformIO should be straightforward. If you are using the Uno for instance running &lt;code class=&quot;highlighter-rouge&quot;&gt;pio init --board uno&lt;/code&gt; and moving all the source code into the &lt;code class=&quot;highlighter-rouge&quot;&gt;src/&lt;/code&gt; directory should get you there.&lt;/p&gt;

&lt;h2 id=&quot;lets-make-it-modular&quot;&gt;Let’s make it modular&lt;/h2&gt;

&lt;p&gt;Often people seem to be unaware that Arduino is just C++. More accurately you are using C++ and the Arduino C++ framework.&lt;/p&gt;

&lt;p&gt;C++ was designed with huge collaborative software projects in mind and some of its features can seem cumbersome when working on small embedded systems and daunting if you have been learning to code by playing with Arduino.&lt;/p&gt;

&lt;p&gt;C++ also has a &lt;code class=&quot;highlighter-rouge&quot;&gt;class&lt;/code&gt; hammer and too often I come across code that has &lt;code class=&quot;highlighter-rouge&quot;&gt;class&lt;/code&gt;ed all the things for no particular reason other than that seems to be what you are supposed to do in C++. In my experience code like this easily looses sight of the relationships it’s trying to express.&lt;/p&gt;

&lt;p&gt;Classes are a language feature for expressing something that exists more than once. A class is really good &lt;a href=&quot;https://youtu.be/J-zFQ9fOTSU?t=35s&quot;&gt;when you want two thousand of something&lt;/a&gt; and many consider a singleton class, a class with a single instance, to be something to avoid.&lt;/p&gt;

&lt;p&gt;In embedded systems you are often building abstractions around resources, say the internal EEPROM or a motor controller or LED attached to particular pins, where it is &lt;em&gt;dictated by the real world&lt;/em&gt; that there only ever is one thing and there could never possibly be a possibility to instantiate another.&lt;/p&gt;

&lt;p&gt;I don’t quite think singleton classes should be avoided at all costs. Classes provide other benefits such as bound methods and encapsulation but I don’t introduce a class to my code unless there is a really good reason to. What I use instead are namespaced modules.&lt;/p&gt;

&lt;p&gt;Most higher level languages have adopted module systems where you can split your code into files and &lt;code class=&quot;highlighter-rouge&quot;&gt;import&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;require&lt;/code&gt; your files as desired. C++ has inherited a two file system from C.  &lt;code class=&quot;highlighter-rouge&quot;&gt;.cpp&lt;/code&gt; is the main source file and &lt;code class=&quot;highlighter-rouge&quot;&gt;.h&lt;/code&gt; is the header file.&lt;/p&gt;

&lt;p&gt;You can declare prototypes, re-confirming the types from your function declarations, in your header files so that you can use them in your &lt;code class=&quot;highlighter-rouge&quot;&gt;.cpp&lt;/code&gt; file in any order you like. I find that the repetition in &lt;code class=&quot;highlighter-rouge&quot;&gt;.h&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;.cpp&lt;/code&gt; become cumbersome and slows me down so I opt for single &lt;code class=&quot;highlighter-rouge&quot;&gt;.h&lt;/code&gt; file modules and namespaces for encapsulation within the modules.&lt;/p&gt;

&lt;p&gt;The one module name that has become common in all my projects is pins.h where all the pins used on my Arduino compatible board are mapped out.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// pins.h
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Pins&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;LED&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;BATTERY_LEVEL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// ...
&lt;/span&gt;    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;As things are added to you main &lt;code class=&quot;highlighter-rouge&quot;&gt;.ino&lt;/code&gt; file often simply moving things out of &lt;code class=&quot;highlighter-rouge&quot;&gt;setup&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;loop&lt;/code&gt; can be a natural start to a new module.&lt;/p&gt;

&lt;p&gt;A contrived example:&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// example.ino
&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;#include &quot;pins.h&quot;
#include &quot;led.h&quot;
#include &quot;some_other_thing.h&quot;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Led&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;SomeOtherThing&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;// ...
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Led&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;SomeOtherThing&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;// ...
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// led.h
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Led&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pinMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OUTPUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;digitalWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HIGH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;digitalWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LOW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The caveat here is you need to pay attention to your imports and the order your functions are declared in within your &lt;code class=&quot;highlighter-rouge&quot;&gt;.h&lt;/code&gt; files. It’s not quite like module systems of more higher level languages but it’s pretty damn close.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Too often do I see Arduino being disparaged as “not professional” when it is just a convenient way to compile your C++ code and upload it to a variety of development boards. Often people use it as an excuse to re-write everything from scratch, and more often than not &lt;a href=&quot;https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/&quot;&gt;that’s a really bad idea&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can adapt you development environment to be more pleasant and adopt development practices that helps you write clean and modular code. This lets you grow your Arduino prototypes into production ready products rather than throwing everything away and starting over.&lt;/p&gt;
</description>
        <pubDate>Wed, 09 Aug 2017 00:00:00 +0000</pubDate>
        <link>https://blog.monostable.co.uk/posts/growing-your-code-with-arduino</link>
        <guid isPermaLink="true">https://blog.monostable.co.uk/posts/growing-your-code-with-arduino</guid>
      </item>
    
      <item>
        <title>Kitnic.it, 1-click BOM and the CPL</title>
        <description>&lt;p&gt;&lt;em&gt;This is a guest blog post for Octopart and first &lt;a href=&quot;https://blog.octopart.com/archives/2016/11/kitnic-1-click-bom-cpl&quot;&gt;appeared on their blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://kitnic.it/&quot;&gt;Kitnic.it&lt;/a&gt; is a site to share electronics projects. If a project is on Kitnic, you can download the Gerbers and put parts into a retailer shopping cart with a single click.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/gQoxO6l.png&quot; alt=&quot;kitnic_screenshot.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;These are early days for Kitnic: our submission process currently involves &lt;a href=&quot;https://github.com/monostable/kitnic#submitting-your-project&quot;&gt;opening a pull-request on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In an effort to encourage people to give it a go, I often look over open source hardware projects that I come across to see if I can get them into a state that is ready to be put up on the site. The challenge is almost always in sorting out the bill of materials (BOM). Really, this is the issue that Kitnic is trying to address: there is no standard way to record a BOM.&lt;/p&gt;

&lt;p&gt;Whether you are looking at someone else’s project or your own work months after it’s creation, trying to find the right parts can be a tedious exercise. The main culprits are often generic components, like resistors and capacitors, where you care about the basic values and specification but not about the exact manufacturer or retailer part.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://1clickbom.com/&quot;&gt;1-click BOM browser extension&lt;/a&gt; that goes along with Kitnic makes the process of adding items to shopping carts a seamless experience. In its first few iterations, this only worked if you specified exact retailer or manufacturer part numbers. In an effort to reduce the tedium of creating BOMs I added a smart, semantic match of surface mount resistors and capacitors to those in the &lt;a href=&quot;http://octopart.com/common-parts-library&quot;&gt;Common Parts Library (CPL)&lt;/a&gt;. This was only possible thanks to Octopart providing the &lt;a href=&quot;https://github.com/Octopart/CPL-data&quot;&gt;CPL data in an easily parse-able format with a Creative Commons license&lt;/a&gt;. The result is best illustrated with the GIF below and should save many engineers a lot of frustration and time.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/monostable/1clickBOM/master/readme_images/demo.gif&quot; alt=&quot;demo.gif&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Everything mentioned here is free and open source, and is available on GitHub so if you spot any issues or have ideas for new features don’t hesitate to &lt;a href=&quot;https://github.com/monostable/kitnic#get-in-touch&quot;&gt;get in touch&lt;/a&gt;&lt;a href=&quot;https://github.com/monostable/kitnic#get-in-touch&quot;&gt; &lt;/a&gt;— and maybe even dig in and make improvements yourself. We are also currently running a promotion for Kitnic for early adopters: you get free PCB manufacturing for &lt;a href=&quot;https://github.com/monostable/kitnic#submitting-your-project&quot;&gt;registering your project&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Wed, 30 Nov 2016 00:00:00 +0000</pubDate>
        <link>https://blog.monostable.co.uk/posts/kitnic.it,-1-click-BOM-and-the-CPL</link>
        <guid isPermaLink="true">https://blog.monostable.co.uk/posts/kitnic.it,-1-click-BOM-and-the-CPL</guid>
      </item>
    
      <item>
        <title>Beginner FPGA Programming Using Open Source Tools #2: Setup</title>
        <description>&lt;p&gt;This tutorial is for the &lt;a href=&quot;http://www.latticesemi.com/icestick&quot;&gt;iCEstick Evaluation Kit&lt;/a&gt; which you can get for about $25 &lt;a href=&quot;http://uk.farnell.com/lattice-semiconductor/ice40hx1k-stick-evn/ice40-hx1k-icestick-eval-kit/dp/2355207?ost=icestick&amp;amp;selectedCategoryId=&amp;amp;categoryNameResp=All%2BCategories&amp;amp;iscrfnonsku=false&quot;&gt;from&lt;/a&gt; &lt;a href=&quot;http://www.mouser.com/ProductDetail/Lattice/ICE40HX1K-STICK-EVN/?qs=%2fha2pyFaduiOEqlsaiRfBulNsZFFFJWzq2a0PhVAJbo%3d&quot;&gt;various&lt;/a&gt; &lt;a href=&quot;http://www.digikey.com/product-search/en?keywords=%20icestick&quot;&gt;places&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We want to spend as little time as possible on the setup. If you are already comfortable with Bash and compilation and have your system set up for that you can follow &lt;a href=&quot;http://www.clifford.at/icestorm/&quot;&gt;the instructions&lt;/a&gt; from the Ice Storm project but below is an easier route using Vagrant.&lt;/p&gt;

&lt;p&gt;Vagrant will set up a virtual machine for you, install all the right tools and make sure the USB connection to the iCEstick is passed through. This should work on any machine be it Linux, Windows or OSX.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.virtualbox.org/wiki/Downloads&quot;&gt;Install Virtualbox&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.vagrantup.com/&quot;&gt;Install Vagrant&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://git-scm.com/download/&quot;&gt;Install Git&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Open a terminal (use Git Bash on Windows) and clone the icestorm-vagrant repository.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/monostable/icestorm-vagrant
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;(The code-block above indicates this is a bash command to be typed into your terminal.)&lt;/p&gt;

&lt;p&gt;We now create the Vagrant machine.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd icestorm-vagrant
vagrant up
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The above will set up a 64-bit Ubuntu 14.04 virtual machine with all the required tools installed. The compilation steps can take a while so go grab a coffee or something.&lt;/p&gt;

&lt;p&gt;After it completes you can login to your newly created virtual machine.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vagrant ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This should say “Welcome to Ubuntu…” and present you with a prompt that looks like this:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vagrant@vagrant-ubuntu-trusty-64:~$
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We are now all on the same page and have the same system with the same tools installed.&lt;/p&gt;

&lt;p&gt;Next we will run a simple example through the entire toolchain workflow to end up with some hardware set on your iCE40 FPGA.&lt;/p&gt;

</description>
        <pubDate>Tue, 14 Jun 2016 00:00:00 +0000</pubDate>
        <link>https://blog.monostable.co.uk/posts/beginner-fpga-programming-using-open-source-tools-2-setup</link>
        <guid isPermaLink="true">https://blog.monostable.co.uk/posts/beginner-fpga-programming-using-open-source-tools-2-setup</guid>
      </item>
    
      <item>
        <title>Beginner FPGA Programming Using Open Source Tools #1: Introduction</title>
        <description>&lt;p&gt;In this blog series I will document my adventure in learning how to program iCE40 FPGAs using only open source tools. I have no prior experience using Verilog or any of the software involved so the aim is a tutorial suitable for beginners.&lt;/p&gt;

&lt;p&gt;Field programmable gate arrays (FPGAs) are reconfigurable hardware. When you program an FPGA you define hardware logic blocks and connections between them allowing for high speed parallel execution of digital logic designs.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry1/fpga.png&quot; alt=&quot;FPGA&quot; /&gt;&lt;/p&gt;

&lt;p&gt;image credit: &lt;a href=&quot;http://www.vision.caltech.edu/CNS248/Fpga/fpga1a.gif&quot;&gt;W.T.Freeman&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;FPGAs are how new processor designs are prototyped and they have niche applications where high speed and parallel processing and a large number of IO (inputs and outputs) are a distinct advantage.&lt;/p&gt;

&lt;p&gt;Their major downsides are their cost and the complexity and license restrictions of the vendor specific toolchains. Most of the time you don’t want to use an FPGA, but when you do, oh boy are you in for a treat.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry1/xilinx.jpg&quot; alt=&quot;Xilinx ISE&quot; /&gt;
image credit: &lt;a href=&quot;https://www.youtube.com/watch?v=VIHSe2dsFvE&quot;&gt;Paolo Santinelli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vendors provide heavy bloated IDEs that are gigabytes big, slow and seem to include everything but the kitchen sink. These are the only way to program their devices. They restrict you in what features you are allowed to use and even which of their devices you are allowed to program depending on what licensing fees you pay.&lt;/p&gt;

&lt;p&gt;Even more annoyingly it takes considerable time investment to learn the work flows and quirks of a toolchain that will tie you to a certain product line of a certain vendor.&lt;/p&gt;

&lt;p&gt;The reason vendors get away with this is that they keep a tight grasp on their bitstream formats, an encrypted communication protocol that allows you to re-program and reconfigure the FPGA.&lt;/p&gt;

&lt;p&gt;I last used FPGAs in University and, though I was fascinated by the technology, it was not a pleasant experience. Since then, while mostly programming microcontrollers and embedded Linux applications, I have become accustomed to a work-flow involving fast, single-purpose programs executed from the bash command-line. I use &lt;code class=&quot;highlighter-rouge&quot;&gt;vim&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;gcc&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;make&lt;/code&gt; in my day to day and I rely on the shell’s repeatability (Ctrl-R is your friend!), configurability and scriptability as a productivity boon.&lt;/p&gt;

&lt;p&gt;I had pretty much written off FPGA work as “not my thing” until about a year ago when &lt;a href=&quot;http://youtu.be/u1ZHcSNDQMM&quot;&gt;an announcement&lt;/a&gt; was made that some friendly hackers (Clifford Wolf and Mathias Lasser) had reverse engineered the Lattice iCE40 bitstream and one is now able to program them completely from the command-line using only open source tools.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry1/make.png&quot; alt=&quot;Verilog with Make&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.clifford.at/icestorm/&quot;&gt;Documentation&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=9rYiGDDUIzg&quot;&gt;presentations&lt;/a&gt; followed and one of the most interesting revelations was that these efforts could enable on-the-fly reconfiguration of hardware from a software program. This is a new way to do computing that could be a revolutionary solution for some problems.&lt;/p&gt;

&lt;p&gt;The easiest way to come to grasps with new way of thinking is to imagine an add-on board for a Raspberry Pi (a shield or hat, if you will) and the software running on the embedded Linux platform could re-configure its attached hardware when it needed to to accelerate a certain computation or access the vast inputs and outputs (144 in the case of the iCE40s) available from the FPGA.&lt;/p&gt;

&lt;p&gt;Plans for exactly this are already under way. Clifford Wolf himself has been working on the &lt;a href=&quot;http://icoboard.org&quot;&gt;Ico Board&lt;/a&gt; (pictured) which is currently in a beta release phase and the &lt;a href=&quot;https://hackaday.io/project/7982-cat-board&quot;&gt;CAT board&lt;/a&gt; is another notable project attempting to provide something similar.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/entry1/ico-board_cropped.jpg&quot; alt=&quot;Ico Board&quot; /&gt;
image credit: &lt;a href=&quot;http://icoboard.org&quot;&gt;OnSite Broadcast eU&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The excitement around these advancements is tangible with comparisons to the beginnings of the GNU Compiler Collection being thrown around. It really remains to be seen what the true value of an open source reconfigurable toolchain is and what a community of free acting hackers will build with this.&lt;/p&gt;

&lt;p&gt;This is a venture strictly for fun and not for profit as the currently the marketability of the skills of using this particular workflow is questionable at best. Join me in exploration of this frontier of open source.&lt;/p&gt;

&lt;p&gt;Let’s set up our tools in &lt;a href=&quot;/posts/beginner-fpga-programming-using-open-source-tools-2-setup&quot;&gt;part 2&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Mon, 13 Jun 2016 00:00:00 +0000</pubDate>
        <link>https://blog.monostable.co.uk/posts/beginner-fpga-programming-using-open-source-tools-1-introduction</link>
        <guid isPermaLink="true">https://blog.monostable.co.uk/posts/beginner-fpga-programming-using-open-source-tools-1-introduction</guid>
      </item>
    
  </channel>
</rss>
