Open Source Hardware, Vol 1


 

So I picked up the Arduino not too long ago, since all the cool kids were doing it. Being a total noob to the world of electronics and open source gadgets, I tried to be a good student and take a bunch of notes.

 

I figured there were a lot of people just like me trying to learn this too, and could probably benefit from some of these projects. There’s kind of an order to when to do each project so that it builds on what you’ve already done- and by the end, I felt like I had a pretty good grasp of things.

 

Source code and other handy files are included on a CD in the back.

 

Well, I only got a few copies printed over at Lulu.com and had a couple extra lying around, so feel free to pick one up and let me know what you think. And hopefully I can help someone else get started the way others helped me!

 

Purchase the hard copy from Liquidware

 


 

Foreword.

 

Introduction.

 

What_is_open_source_hardware?

 

Hardware and software are the basic concepts of modern digital computing and device design. They are the bricks and mortar of the digital age. Hardware is physical circuitry and moving devices, while software is purely electronic instructions that tell the physical hardware what to do. Just as building a house requires blueprints, software requires source code, or instructions that are converted into a program. Software source code is readable by humans, while compiled software programs consist of 1’s and 0’s and can only be understood by computer hardware.

Likewise, hardware too requires blueprints. These blueprints can take many forms; everything from drawings of circuit diagrams, to descriptions of circuit behaviors, to detailed files that enable others to rebuild the printed circuit boards. While software is typically expressed in a text-based form that reads like a series of logical or mathematical expressions, hardware diagrams and circuit description files are more like engineering blueprints or architectural diagrams. They are far more closely linked with the physical world, and so physical proximity and layout are important in hardware design.

Open source software is a movement that became mainstream sometime in the mid-1990’s. Prior to the mid-1990’s, most software was distributed only as compiled programs of 1’s and 0’s that only computers could understand. Open source software referred to the practice of distributing the source code along with the compiled program. This meant that anyone else could pick up the source code, make modifications, fix bugs, add features, and redistribute those changes to others.

Open source hardware, by extension of the software definition, is the practice of distributing along with physical electronic hardware, the set of blueprints or behavioral descriptions that allow others to understand, modify, and even recreate the original hardware. This means that hardware is now more approachable, easier to tinker with, and easier to customize to individual needs.

There are no specific guidelines on what needs to be distributed along with a piece of hardware to make it “open source,” mostly because there are very few standards in hardware design. Unlike software, where there is usually an underlying computer language shared across programs (i.e. Linux is built on the standards set by the C programming language), hardware is so broadly defined that it is extremely difficult to establish such narrow, shared standards or design rules.

In the absence of shared standards, therefore, here’s a proposal for several criteria that all “open source hardware” devices should aspire to meet:

* Allow reverse engineering, and promote tinkering
* Contain a degree of high level modularity
* Provide a way to understand inner workings of the device
* Provide guidelines for changing device behavior
* Promote transparency of component costs

The first two guidelines relate to the technical nature of the device. They suggest a device should be technically approachable, and easily understandable. Modularity is important, because it promotes reverse engineering and modular additions (by comparison, a tightly integrated device is quite difficult to change or extend). The next two guidelines relate to the cognitive process of understanding a device, and changing its behavior. As device and product designers, this typically means providing either documents or access to the creators of a device, to help users adapt the device to their own needs. Finally, the last guideline – and perhaps the most controversial – relates to the economic nature of open source hardware. This rule suggests that, like open source software, the economics of production are closely linked to the distribution and adoption of the product. This feels largely counter-cultural to many product design institutions today, who are used to making between 50-100% retail margins on their products. By exposing this, device users can select and buy hardware that really is worth the price (e.g. based on the device’s adherence to open source hardware principles).

 

 

What_is_physical_computing?

 

Electrical engineering is difficult. These days, most engineers attend years of formal training at colleges and universities, while amateur hobbyists can spend a decade mastering the skills, knowledge, and ability to assemble physical devices, like robots, computers, calculators, or music players. A large portion of this difficulty comes from the fact that electrical engineering requires the manipulation of electrons, which are non-obvious, invisible, and often times difficult to predict. After this hurdle is overcome, another hurdle involves the fact that most electronic tinkering involves components (e.g. IC’s, or integrated circuits) that require large instruction manuals and circuit diagrams to understand.

This wasn’t always the case. In the 1970’s and 1980’s, during the dawn of personal computing, discrete electrical components, otherwise known as those little black “chips” that sit on circuit boards, were the most popular way to assemble complex circuits. These components had simple functions, like checking whether 2 input wires were high (+5) voltage, or low (0 ground) voltage. Hobbyists would connect several discrete components together with wire, solder a few connections, and a circuit was born.

Today, the field of electrical engineering has largely outgrown the average hobbyist. As the number of transistors per square inch increases, discrete electrical components shrink in size, or become far more complex. While a 1 inch by .25 inch black chip once fit only a single comparator or logic gate, that same chip space may now contain megabytes of memory space, thousands of lines of code, ethernet and WiFi connections, and MP3 decoding functions. This is great for the end consumer, because it results in smaller, more powerful, and generally more useful devices. However, it is obvious to see that reverse engineering these devices is now next to impossible for the hobbyist.

Physical computing is a movement that seeks to return the modern digital age of electronics to the same ease of use and approachability that existed in the 1970’s and 1980’s. It does this by making complex circuitry accessible to same individual equipped only with wire cutters and wire. All wires, components, and connections on circuits are clearly labeled. Project cases are transparent and encourage users to peer inside. If a circuit is “physically approachable”, its functionality can be easily reverse engineered by merely looking at it, its behavior is easy to modify or extend using nothing more than wire, cutters, solder, an iron, and another circuit.

Physical computing is about encouraging users of devices to tinker, experiment, extend functionality, and modify the devices around them to accommodate personal needs.


What_are_modular_electronics?

 

Modular electronics are like Legos™, Lincoln Logs™, Connectix™, popsicle sticks, and even bricks. Electronic circuits are packaged into little modules that can be snapped together easily to build more advanced, more complex devices and circuits. Most importantly, circuits may be connected without solder or advanced connectors that typically require a high degree of skill to use.

Most electronics are “integrally” designed. That is, all the components are placed onto a single circuit board (PCB, or printed circuit board) that sits inside an electronic device. The discrete components are soldered onto the circuit board, and the wire connections between discrete components is drawn and then baked into the layers of the circuit board. Soldering is difficult, and requires time, patience, and a steady hand – like surgery. Most device users and hobbyists aren’t steady-handed surgeons, and so it is next to impossible for most people to tinker, extend, or alter an existing circuit. An example of altering a circuit could include trying to link a portable music player (like an iPod) to a portable gaming machine (like a Sony PSP), in order to share music files between the two devices. Another example could include trying to add a digital projector to a cell phone in order to project video clips onto the wall for others to enjoy.

Electronics modules typically embody one or a few related actions. For instance, a display module might be a screen that would serve as an output device, while an input module might contain buttons, touch-sensitive surfaces, or analog joysticks. Other modules might include music players, wireless communications devices, motors, or storage devices like USB drives. Often times, there is a central processing module that contains the primary program, and interacts with the other modules. The central module usually contains the CPU (central processing unit) or microprocessor, and runs the software that takes input from the input modules, and provides instructions to the output modules.


What_is_the_Arduino?

 

The Arduino is a microprocessor, neatly packaged into a nice modular form factor, clearly labeled for physical computing, and open source so that anyone can tinker, extend, or modify the circuit. It is the ideal platform for open source modular and physical electronics. A far simpler way of saying the same thing is, combining the Arduino with a few other modules is the easiest way to make cool things.

The Arduino form factor is perfect for starting projects and making devices because it is easy to program using only a laptop or desktop, a compiler application, and a USB cable. It’s also cheaper than most other platforms available, like the Basic STAMP, PICmicro, Rabbit, and other platforms. Furthermore, programming the Arduino can be done in a much higher level programming language, called Processing, unlike the other platforms which require in depth knowledge of C, C++ and oftentimes assembly code. It’s not unrealistic for the average Arduino hobbyist to produce a complete working device in 2-3 hours time that would have taken 4-5 days or even a week to create on other platforms.


Finally, the Arduino is a lively, vibrant, and modern online community offering endless support, knowledge, and ideas. Gone are the days of stodgy, lone, gray-haired electronics gurus bickering about circuits on chat rooms. The Arduino community is young, hip, stylistic, and encouraging to new hobbyists. For more information on online resources, just flip through the rest of the book and look out for the URL links to pages, communities, and discussions. Welcome to the exciting world of open source, modular electronics!


How_to_use_this_book

 

This book is divided into project chapters. The goal of each project is to create a fully-functional, working prototype electronics device. Some devices are more useful than others (and that’s for you to decide!), but all devices can be extended further beyond the scope of this book, to create even more interesting devices. In this sense, each project is structured to be a foundation for your own device creations.

Each project chapter contains 5 parts:

# List of required modules, and additional parts if needed
# Description of the basic functionality of the completed device
# Block or circuit diagrams to assist you in assembling the device
# Source code for a compiler to upload to the modules
# Pictures of the unassembled, and assembled device

The book is organized by modules, so you can quickly navigate to the section containing the modules they have, and build whatever device they wish. As your collection of modules increases, you can turn to other chapters and build differentor more complex devices with time.

As with most technical books, it’s always a good idea to start with an easy project to familiarize yourself with the basics of the modules and programming. The chapters are therefore assigned a star rating, where a 1 star project is generally easier than a 3 or 4 star project. That’s not to say you couldn’t do a 4 star project from the start, but be prepared with plenty of patience!


Getting_to_know_your_Arduino

 

The Arduino is a simple little device that looks like this:



Despite the fact that it fits nicely in one hand, don’t be fooled—there’s quite a bit of functionality crammed into that small space. On the left side, there’s a USB port that allows the Arduino to communicate with your laptop or desktop computer. Just plug it the USB cable into the Arduino and plug the other end into your computer. Most computers will auto-recognize any USB device, and the Arduino is no exception.


Landmarks_on_the_Arduino_Diecimila_board

 

Beside the USB port, also on the left side of the Arduino, is a black power outlet socket. Although the Arduino draws its power from the USB port when it’s plugged in, it can also be powered through any AC adapter, which plugs into the wall outlet socket, and outputs +5 volts of DC power. Moving from left to right, you’ll notice there are a number of discrete components, and then a series of small LED lights. These are connected to some of the more commonly-used features on the board, including two connected to pins 0 and 1 to show serial communications (to show when the Arduino is transmitting data to and from the computer), and another LED connected to pin 13 (usually used to debug circuits, but more on that later).

In the middle of the Arduino is a large black integrated circuit (IC). This is the ATmega 168 chip that runs the Arduino. The ATmega 168 is the “brains” of the microcontroller board, and it communicates with the rest of the board. Next to this chip is a reset switch. When this switch is pressed, the Arduino temporarily resets itself, and then restarts whatever program is loaded onto it at the time.

Finally, and perhaps most importantly, are two rows of black “headers”. These tall, elevated headers are digital input and ouputs signal pins. Some of the pins are also connected to analog inputs, and to power and ground signals. These headers serve two purposes. First, they are the perfect size for wires, which can connect the Arduino to other circuits. For the purposes of this book, and most of its projects, however, these headers are where other modules (sometimes called “shields”) are inserted onto the Arduino. By inserting a module on top of the Arduino, the Arduino’s functionality is expanded.

 

Installing the Arduino programs on your desktop

 

Navigating the Arduino programming environment

Introduction_to_the_modules

 

This section provides a quick overview of the electronic modules used throughout the rest of the book. Each of the modules is available through online stores. We have only listed below those modules that are directly compatible with each other.



Arduino

The main microprocessor, which runs applications and source code programs.



Breadboards

Filled with sockets and small holes to insert other electronic components and wires.



TouchShield

Touchscreen, OLED (organic light emitting diode) screen, with 128 by 128 resolution, 8 megabit memory, and an onboard graphics processor.




ExtenderShield

Used to replicate the pins from the Arduino out, provide additional circuit-building space.



Lithium Backpack

Provides +5 or +3.3 volt power to a circuit. Also contains a marked ground wire, and voltage divider pin to measure the charge level of the battery.




Light Emitting Diodes (LEDs)

Source of light, often measured by brightness in lumens.



Buttons and Switches

Sources of input, mechanically driven, and often with different characteristics that dictate how the switch behaves (e.g. does it complete the circuit when depressed, or released, and does the circuit remain closed until another click, or is it on-then-off).



Analog Input

Often a potentiometer or voltage divider, these act as resistors.



GPS (Global Positioning System) Receiver

Serially controlled, able to detect GPS signals from GPS satellites. This one is from Libelium.



Accelerometer

Measures acceleration and movement in 2 or 3 axis dimensions.



Motion Detector

Sensor that measures motion by triggering a signal when light patterns in front of the lens change.



Sonar

Measures the distance to a flat object by sending out small, high frequency sound blips, and measuring how long it takes to receive them back. This one is made by Parallax.



WaveShield

Takes in digital audio files and plays back audio. Designed by LadyAda, and available from Adafruit Industries.



MotorShield

Controls a set of up to 4 motors. Designed by LadyAda, and available from Adafruit industries.



ProtoShield

Designed by LadyAda and used to assist with prototyping. It provides a handy prototyping space on top of the Arduino.



Solid Core Wires

Typically gauge 24 AWG, wire is essential for connecting components like switches and LEDs to your gadget.



USB Cables

A type B USB cable is the same shape as a USB printer cable, and connects to the Arduino. A type B-mini can be used to charge the Lithium Backpack.


Terms used throughout the book

 

Core Files


The grouping of low level files that support an embedded processors base firmware environment. A core is typically composed of source (.c) files, header (.h) files, and a C++ (.cpp) file.

Shield


A module that plugs into the headers of a device like the Arduino. This module typically adds a unique ability to the base device such as motor controls, wireless communication, prototyping or even an OLED.


Backpack


A module that attaches to the back of a device like the Arduino. This module typically adds a unique support feature to the base device.


Module


A device that has a unique functionality and is easily attached to other devices to expand the functionality and features of the base unit. An example of this is a mouse (module) can attach to a computer (base unit).


Compiler


A program (computer application) that translates code written at a high level to a more basic low level code. A typical application of this is code written in C++ (easy language for humans to understand) getting compiled (translated) into Assembly (an efficient language to upload to an embedded controller).


Processor Core


The base of the processing unit usually defined by the operation size (bits), processing speed (MHz), program memory size (KB) and the amount of flash memory (KB).


The Arduino

 

Hello_world_program
Communicating_between_the_Arduino_and_PC_over_serial

Blinking_the_onboard_LED_on_pin_13


Arduino + Breadboard + LEDs

Knight Rider with LEDs


Arduino + Digital input switches

 

Arduino + Analog inputs

Battery Tester


Arduino + Lithium Backpack

Portable LED blinker


Arduino + TouchShield

How to Program the TouchShield


Basic Squares

 

TouchShield Hello World


Reaction Time Game


Stoplight.


Countdown Timer


Battery Life Monitor


Arduino + ProtoShield + GPS

Serial GPS reader


Arduino + ProtoShield + Accelerometer

Gravity Tester: Basic input and output over serial

 

Arduino + ProtoShield + Ping Sensor

Burglar Alarm

 

Arduino + Motor board + Motor

Basic control of a motor

 

Arduino + Lithium Backpack + TouchShield

Pin Visualizer


BitDJ


Arduino + ExtenderShield + ProtoShield + TouchShield + BackPack + Accelerometer

Acceleration meter

 

An open source project


Additional resources


My Own Device (I)


My Own Device (II)