Oop 2014 embedded systems with open source hardware v2
Upcoming SlideShare
Loading in...5
×
 

Oop 2014 embedded systems with open source hardware v2

on

  • 1,167 views

 

Statistics

Views

Total Views
1,167
Views on SlideShare
1,166
Embed Views
1

Actions

Likes
1
Downloads
46
Comments
0

1 Embed 1

https://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Oop 2014 embedded systems with open source hardware v2 Oop 2014 embedded systems with open source hardware v2 Presentation Transcript

  • Developing Software for Open Source Hardware © Prof. Dr. Michael Stal, 2014
  • Engineers never fail I have not failed. I've just found 10,000 ways that won't work. [Thomas A. Edison]
  • The Rise of Physical Computing Definition: Building interactive physical systems by the use of software and hardware that can sense and respond to the analog world […] In practical use, the term most often describes handmade art, design or DIY hobby projects that use sensors and microcontrollers to translate analog input to a software system, Arduino-based Laser Harp: visit and/or control electro-mechanical http://makezine.com/projects/laserharp/ for detailed instructions devices such as motors, servos, lighting or other hardware. View slide
  • Maker Movement Modern version of DIY (DoIt-Yourself) extends the idea of open source software build things with free hardware and donate the design to the community FabLabs* for tinkerers who share tools as opposed to owning them Increasing number of s * FabLab = Fabrication Laboratory View slide
  • Portals with Public Domain Projects Examples Thingiverse http://www.thingiverse.com Instructables http://www.instructables.com
  • Instructions and Design Documents Includes Design CAD files Part list Instructions how to assemble the parts
  • Useful Things – well, not always that useful Design provided as STL (Standard Triangulation Format) documents in verbose ASCII or in compact binary format Example: solid name facet normal n1 n2 n3 outer loop vertex p1x p1y p1z vertex p2x p2y p2z vertex p3x p3y p3z endloop endfacet endsolid name
  • Production of 3D Objects How? Either yourself using a 3D printer (from under 1000 € to 10.000s of €) Or by cheap commercial fabrication companies (on-demand production) Main benefit: feasible even for small amounts of items Liability: may make piracy easier
  • So, What? Increasing number of open source microcontroller boards Excellent and cheap tools for prototyping Useful to learn basics of software development for embedded systems Scope are systems w/o stringent realtime/dependability requirements
  • Intel goes Arduino Even large companies support Arduino: headline on October, 3rd, 2013: Intel launches Galileo, an Arduino-compatible development board with x86 CPU
  • Open Source Hardware Boards The most important ones: Arduino (microcontroller board) Raspberry Pi (controller plus a Linux PC) NetDuino (layout compatible with Arduino but .NET based) BeagleBone (microcontroller board, Embedded Linux) Typical price range from 20€ to around 50€ Main focus of this talk
  • Prerequisites Which prerequisites are necessary for building such systems? Small Systems, Medium Systems with Low Complexity: For implementing existing designs, only basic knowledge of electronics/mechatronics Some rather inexpensive tools Sets like the Arduino Starter Kit Hint: many open source projects available in the Internet and in books Larger and/or complex systems: Knowledge about electrical engineering/mechatronics Soldering skills and Soldering station (except if only prototyping on breadboards) Electronic test instruments (oscilloscope, frequence analyzer, power generator, voltmeters...) A collection of components and ICs Tools, Cables, Breadboard, Hansaplast, ... David L. Jones publishes excellent videos on electronics in his blog: EEVBlog (Electronics Engineering Video Blog)
  • Arduino & Friends HAL (powered by Arduino)
  • Back to the Future 2005: Started as project at the Interaction Design Institute Ivrea, Italy 2006: Won a price at Prix Ars Electronica in 2006 Name taken from Arduino d'Ivrea (King of Italy around 1002 AC) * Goal: up-to-date board for students as an alternative to BASIC Stamp & Wiring framework „Processing for Hardware“ Creative Common License Watch documentary on http://vimeo.com/18539129 * well, that‘s the romantic version. Actually, it was named after a local pub Arduino Web Site http://arduino.cc Creators of Arduino with Massimo Banzi (to the right): First prototype board, made in 2005
  • The Arduino Family Arduino comes in a lot of flavors, e.g., LilyPad Arduino (Arduino for your clothes) Arduino Uno Rev. 3 (the „reference model“) Arduino Yun and Arduino Tre (microcontroller + separate Linux system on one board) Commercial companies sell their own implementations: e.g., SainSmart, Seed, AdaFruit BYO: You can even build your own Arduino board
  • Arduino Board Design Analog Reference USB Used to load programs (=sketches) to the board, to power the board, and for serial communication Digital Ground CPU with 16MHz Digital I/O Pins 2-13 (9, 10, 11with PWM = Pulse Width Modulation) Pins 1 & 2: Digital I/O. When used for communication then Serial In/Out, TX/RX Jumpers: Toggling between USB power and external power (jumpers) Boards (i.e., their pins) have a maximum current they can handle. Most Arduino boards define a maximum of 40 mA. Higher values will cause damage. In-Circuit Serial Programmer: if you need to upload another bootloader Reset Button: on reset the bootloader restarts External Power Supply Power Connectors connected with your board. Not all boards use 5V! Analog In: 0-5
  • I2C* – The Low-Speed Bus LowMulti-master serial single-ended computer bus invented by Philips Semiconductors Used in most open source hardware boards for attaching low-speed peripherals (speed 10 Kb/s-100Kb/s; newer versions even up to 3.6 Mb/s) Two bidirectional open-drain lines: Serial Data Line (SDA) und Serial Clock (SCL) Pull-up resistors to prevent data floating Wire library available (for accessing I2C) Master generates the clock and initiates communication Slave receives clock and responds when addressed by master Master sends only if it detects no start or stop bit sent by another master Single Message or Multi Message License free; only slave addresses must be bought * I2C = Inter-Integrated Circuit, invented by Philips Semiconductor Division, now NXP
  • Processors Newer boards (Due): ARM with Cortex-M3 (32 Bit Architecture) Previous Boards (Uno, Mega. Leonardo, Duemillenova, ...): based on Atmel‘s chip family ATMega xxx, 8 Bit Architecture A bridge connects both worlds Arduino Yun and Tre: additional but separate on-board unit (Atheros resp. ARM Cortex A8) running Linux (OpenWRT) Arduino Yun Architecture
  • Solderless Breadboards Connecting the Arduino to a breadboard is very useful for designing circuits without soldering When finished you may use a PCB (Printed Circuit Board) instead Breadboards consist of pin holes to place components (terminal strip) as well as bus strips: Terminal strip: all pin holes Bus strips for power supply (red = voltage, blue = ground) Notch in the middle (where mostly ICs such as DIPs are placed)
  • Standard Components You‘ll need a basic set of components: WRONG Resistors, Potis, Capacitors Transistors, Diodes, LEDs Buttons, Switches Relays,Transformators Motors Standard ICs such as OpAmps, L298 bridges App for looking up resistor color codes Wires, wires, wires A 9V block battery with a connector BETTER
  • Sensor & Actuator Components Pressure Sensor Ultrasonic Gyro Hall Sensor Temperature Sensor Developers needs to add specific code for reading or writing actuator/sensor values Usually attached through an analog port Specification of chip/component explains how to map between sensor values and physical units PWM (Pulse Width Modulation) often used in digital outputs to vary intensity of speed, volume, brightness, ...
  • Shields, Shields, Shields Arduino shields (incl. program libraries) add advanced logic Built to fit on top of an Arduino board Typically, provide the same pins like the Arduino (stacking of boards) Examples: Motor Shield (Arduino) LCD Shield (Sparkfun) Proto Shield (Seeed Studio) GPS Shield (Adafruit) WiFi Shield (AsyncLabs) See http://shieldlist.org/
  • Circuit Design with Fritzing Fritzing, an open source editor for circuit design developed by University of Applied Sciences, Potsdam Fritzing.org: nonprofit organization Supports, Mac OS X, Windows, Linux You can directly order a PCB board from within the editor
  • Programming an Arduino When coding a sketch (= program) for microcontroller boards like Arduino, two steps are necessary: Initialization Controlling & Monitoring 1. 2. Initialization phase executed once at start-up time: definitions and initialization of ports, connections, ... Controlling & Monitoring happens in an „endless“ loop. Sketch can monitor and control the board Application may terminate itself on specific events start Initialization Controlling & Monitoring exit
  • The Arduino IDE* Available for MacOS X, Windows, Linux at no cost Based on Processing, built with Java Subset of C/C++, (implementation of Wiring) Uses gcc & avr-gcc libraries in the build process C/C++ Libraries import You may use gcc directly or within Eclipse for C++ Other languages such as Java can remotely connect to Arduino using a wrapper on top of a RxTx native library * Free guide available at http://www.me.umn.edu/courses/me2011/arduino/arduinoGuide.pdf
  • „Hello World“ I respect the old tradition and present the embedded cousine of „Hello, World“... ... which results in a blinking LED Language based on C/C++ // Pin 13 has an LED connected on most boards int led = 13; // the setup routine - runs after each reset: void setup() { // initialize digital pin as an output pin pinMode(led, OUTPUT); Serial.begin(9600); // start serial port } // infinite loop; HIGH & LOW are voltage levels! void loop() { Serial.println(“Hello, World”); // send string digitalWrite(led, HIGH); // shine a light delay(1000); // wait for a second digitalWrite(led, LOW); // switch off LED delay(1000); // wait for a second } Serial stream received by host and displayed on the IDE‘s Serial Monitor if available
  • Programming Models generate In general, there are three programming models for embedded devices: Arduino IDE based on command-driven mode. Command-Driven (proactive, polling) +ü´ßw saeqq Event-Driven* (reactive, Pub/Sub) Model-Driven (e.g., Matlab + Simulink, Labview) Command Driven All of these models have strengths and limitations Select the right one for your environment Model-Driven generates code for one of the other models * It is also called Behaviour-driven or Reactive Model
  • Reactor Pattern If the event-driven model is not supported, you may use the Reactor pattern to avoid the command-driven model. dispatches * Reactor owns maintains select notifies * Event_ Handler * Consider whether you have timing constraints before use! Handle Handler 1 Reactor (central component) waits for incoming events and demultiplexes & dispatches each event (i.e., calls your Handler which is supposed to deal with this event) Handlers must implement a predefined interface Handle is a unique value of a particular type (e.g., interrupts, Unix handles) that determines to which handler an event will be dispatched Handler 2 Handlers are interested in certain types of events and register for this type with the Reactor or are hardwired • • • Events can be prioritized Handlers may run concurrently Dispatching tasks to a thread in a multicore system is possible, but very complex (to do it right)
  • Recommended Design Approach In most projects, finite state machines (FSM) (together with timing diagrams) are the best choice for design activities 1. 2. 3. 4. 5. Define the problem (space) and check the requirements Elaborate all program flows that are necessary (but also consider error scenarios!) Determine the states the system must support as well as the transitions incl. the actions to be called for a particular transition Check and optimize the FSM Implement it with the table approach or generate it
  • Host/Target Development Host Target USB Test Environment IDE Bootloader starts on reset Command Line ICSB port for programming other firmware CrossCompiler Development Environment Developing Cross-Compiling Testing on Simulator or Physical Target
  • Developer Ecosystems Arduino native IDE MariaMole: alternative IDE CodeBlocks for AVR & Arduino Arduino for Microsoft Visual Studio and Atmel Studio (free). Plug-In with features of the Arduino IDE, optional USB/WiFi debugger Arduino Eclipse Plug-In Arduino-Devel: ant-scripts for Eclipse instead of plug-in Eclipse & AVR PlugIn embedXcode: Apple’s Xcode MiniBloq: Graphical UI More details on the Arduino Playground: http://playground.arduino.cc/
  • Java VM on Arduino HaikoVM runs on Arduino and implements Java 6 bytecode Runs on AVR ATmega8, AVR ATmega328p (and Windows, UNIX) A lot of nice features: Preemptive threads & Synchronization Exceptions ... Workflow 1. 2. 3. 4. Java to Class Class to C C to Binary Upload and Run Work still ongoing
  • Learning by Example Examples are helpful to introduce Arduino concepts Thanks to Mike McRoberts for providing a free manual with various experiments (see below) In theory, theory and practice are the same. In practice, they are not. http://math.hws.edu/vaughn/cpsc/226/docs/askmanual.pdf
  • Arduino Projects I will demo one of my own experiments The other projects are actually taken from the Arduino Playground: http://playground.arduino.cc// main/projects ... so that you can find detailed instructions, part lists, etc. on the Web. Uncountable Arduino projects availabe that may give you inspiration for your own experiments But don‘t go too far!
  • Project Traffic Light Building a Traffic Light with LEDs and a Piezo speaker that signals red or green.
  • Example 1: Debouncing Problem: when pressing a switch or button the signal can bounce for a while Solution: Debouncing pattern
  • Example 1 – Code (Setup) // constants won't change. They're used here to set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // Variables will change: int ledState = HIGH; int buttonState; int lastButtonState = LOW; // the current state of the output pin // the current reading from the input pin // the previous reading from the input pin long lastDebounceTime = 0; // the last time the output pin was toggled long debounceDelay = 50; // the debounce time; increase if output flickers void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); // set initial LED state digitalWrite(ledPin, ledState); }
  • Example 1 – Code (Loop) void loop() { // read the state of the switch into a local variable: int reading = digitalRead(buttonPin); // If the switch changed, due to noise or pressing: if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so take it as the actual current state: // if the button state has changed: if (reading != buttonState) { buttonState = reading; // only toggle the LED if the new button state is HIGH if (buttonState == HIGH) { ledState = !ledState; } } } digitalWrite(ledPin, ledState); // set the LED lastButtonState = reading; // this will be the lastButtonState in the next loop }
  • Alternative Solution Using the Debounce Library (DRY) Available in the Arduino IDE Implements the same functionality in an elegant way // This code turns a led on/off through a debounced switch #include <Debounce.h> #define SWITCH 5 #define LED 13 // Instantiate a Debounce object with a 20 millisecond debounce time Debounce debouncer = Debounce( 20 , SWITCH ); void setup() { pinMode(SWITCH,INPUT); pinMode(LED,OUTPUT); } void loop() { // Update the debouncer debouncer.update ( ); // Get the update value digitalWrite(LED, debouncer.read() ); }
  • Example 2: Pull-Up Resistors PullProblem: circuits are subject to electrical fluctuations which may lead to an undefined state. Solution: use a pull-up resistor so that when unpressed, 5V will be on pin 2, and when pressed will be low to connection with ground Arduino internally provides Pull-Up resistors for digital pins
  • Example 2 – Code void setup(){ Serial.begin(9600); // start serial connection pinMode(2, INPUT_PULLUP); // pin 2 is input and uses the pull-up resistor pinMode(13, OUTPUT); } void loop(){ //read the pushbutton value into a variable int sensorVal = digitalRead(2); //print out the value of the pushbutton Serial.println(sensorVal); // send current value via serial communication to host // // // // if Keep in mind the pull-up means the push-button's logic is inverted. It goes HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the button's pressed, and off when it's not: (sensorVal == HIGH) { digitalWrite(13, LOW); } else { digitalWrite(13, HIGH); } }
  • Example 3: Using PWM Problem: for dimming a led, ..., we need to change the actual current continuously, but how? Solution: Use PWM (PulseWidth-Modulation) to simulate an analog output with variable current Done by swítching the signal on and off for specific time intervals (duty cycles)
  • Example 3 – Code int ledPin = 9; // LED connected to digital pin 9 void setup() { // nothing happens in setup } void loop() { // fade in from min to max in increments of 5 points: for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // analog write on digital pin! // wait for 30 milliseconds to see the dimming effect delay(30); } // fade out from max to min in increments of 5 points: for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } }
  • Example 4: Using Libraries Problem: How can we access the LiquidChrystal display Solution: we need to import the LiquidChrystal Library
  • Example 4 – Code #include <LiquidCrystal.h> // the library for using LCDs // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's to 16 numbers and 2 rows lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); }
  • Example 5: Control Speed of DC Motor Problem: Connecting a low current Arduino with a high current consumer Solution: Transistor (npn) to separate both circuits Potentiometer to let user avry the speed Diode to prevent any current caused by induction damaging the circuit Source: http://www.dummies.com/how-to/content/how-to-control-the-speed-of-a-dc-motor-with-the-ar.html
  • Example 5 – Code int int int int potPin = A0; // potentiometer on analog pin A0 motorPin = 9; // motor on digital pin 9 potValue = 0; motorValue = 0; void setup() { Serial.begin(9600); } void loop() { potValue = analogRead(potPin); // map maps from [0, 1023] to [0, 255] motorValue = map(potValue, 0, 1023, 0, 255); analogWrite(motorPin, motorValue); // set speed Serial.print("potentiometer = " ); Serial.print(potValue); Serial.print("t motor = "); Serial.println(motorValue); delay(2); }
  • Alternative Solution Use a motor shield (several available) Can support multiple motors (brushed dc motor, stepper, servo) Motor shields leverage the H-bridge L298P
  • Alternative – Code (Setup) const int PWM_A = DIR_A = BRAKE_A = SNS_A = 3, 12, 9, A0; void setup() { // Configure the A output pinMode(BRAKE_A, OUTPUT); pinMode(DIR_A, OUTPUT); // Brake pin on channel A // Direction pin on channel A // Open Serial communication Serial.begin(9600); Serial.println("Motor shield DC motor Test:n"); }
  • Alternative – Code (Loop 1) void loop() { // Set the outputs to run the motor forward digitalWrite(BRAKE_A, LOW); digitalWrite(DIR_A, HIGH); // setting brake LOW disable motor brake // setting direction to HIGH: motor will spin forward analogWrite(PWM_A, 255); // Set the speed of the motor, 255 is the max value delay(5000); // hold the motor at full speed for 5 seconds Serial.print("current consumption at full speed: "); Serial.println(analogRead(SNS_A)); // Brake the motor Serial.println("Start brakingn"); // raising the brake pin the motor will stop faster than the stop by inertia digitalWrite(BRAKE_A, HIGH); // raise the brake delay(5000); // to be continued
  • Alternative – Code (Loop 2) // … continued // Set the outputs to run the motor backward Serial.println("Backward"); digitalWrite(BRAKE_A, LOW); digitalWrite(DIR_A, LOW); // setting againg the brake LOW to disable motor brake // now change the direction to backw: LOW DIR_A pin analogWrite(PWM_A, 255); // Set the speed of the motor delay(5000); Serial.print("current consumption backward: "); Serial.println(analogRead(SNS_A)); // now stop the motor by inertia, motor will stop slower than with brake function analogWrite(PWM_A, 0); // turn off power to the motor Serial.print("current brake: "); Serial.println(analogRead(A0)); Serial.println("End of the motor shield test with DC motors. Thank you!"); while(1); }
  • Example 6: Interface to Processing Problem: How can we access Arduino from Processing? Solution: use the Processing library Based on Firmata: generic protocol for communicating with microcontrollers like the Arduino from software on a host computer. Guess, where the Arduino IDE came from. Processing was developed as a subset of Java to support visual artists, designers, young programmers, .... It provides stunning Animation, Simulation, Graphics.
  • Example 6 – Code import processing.serial.*; import cc.arduino.*; Arduino arduino; int ledPin = 13; void setup() { //println(Arduino.list()); // we assume it is the first device arduino = new Arduino(this, Arduino.list()[0], 57600); arduino.pinMode(ledPin, Arduino.OUTPUT); } void draw() // draw is the Processing cousin of loop { arduino.digitalWrite(ledPin, Arduino.HIGH); delay(1000); arduino.digitalWrite(ledPin, Arduino.LOW); delay(1000); }
  • Libraries If you want to provide a library you need to program in C/C++ Interface defined in header file, implementation in c++ file /* Header file specifies public contract */ /* The Implementation File */ #ifndef Loudspeaker_h #define Loudspeaker_h #include <Loudspeaker.h> const byte SPEAKER_PIN = 0x8; class Loudspeaker { Loudspeaker(); ~Loudspeaker(); public: void playTone(int freq); void shutUp(); } #endif Compile with gcc-avr //constructor Loudspeaker::Loudspeaker() { pinMode(SPEAKER_PIN, OUTPUT); } Loudspeaker::~Loudspeaker() { /* NOP */ } void Loudspeaker::playTone(int freq) { /* ... */ } void Loudspeaker::shutUp() { /* ... */ }
  • Arduino Simulators Simulator for those with limited tinkering capabilities or without interest Virtronics not perfect, but so far the best solution I found (14,95 AUD) Running my Traffic Lighht example
  • Netduino „Arduino.NET“ Shield-compatible with Arduino Uno Rev. 3 Based on .NET Micro Framework Supports C#, VB, ... STMicro 32-bit microcontroller Speed: 168MHz, Cortex-M4 Code Storage: 384 KB RAM: 100+ KB 10 mbps Ethernet Micro SD card support up to 2 GB Input Voltage: 7.5 - 9.0 VDC or USB powered 25 mA max. current per pin Digital I/O 3.3 V but 5 V tolerant 12 bit ADC (Analog Digital Converter) USB For both images: (c) Microsoft
  • Blinking LED in Netduino In Visual Studio: Change deployment target from emulator to the real board (in the „project menu“ visit „Hello_LED properties“. There you‘ll find the „.NET Micro Framework“ where you eventually change the transport type to „USB“) using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace Hello_LED { public class Program { public static void Main() { OutputPort LED = new OutputPort(Pins.ONBOARD_LED, false); while (true) { LED.Write(true); Thread.Sleep(250); LED.Write(false); Thread.Sleep(250); } /* while */ } /* Main() */ } //* Program */ } //* Hello_LED */
  • EventEvent-Driven Netduino Event-driven system-level example using .NET eventhandlers /* imports as in the Blinking LED example */ namespace EventDrivenLED { public class Program { static OutputPort LED = new OutputPort(Pins.ONBOARD_LED, false); public static void Main() { InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode. Disabled, Port.InterruptMode.InterruptEdgeBoth); button.OnInterrupt += new NativeEventHandler(button_OnInterrupt); Thread.Sleep(Timeout.Infinite); } //* Main() */ static void button_OnInterrupt(uint inf1, uint inf2, DateTime time) { // inf1: id of the button, inf2: button state LED.Write(inf2 == 0); // true => button was pushed } /* button_OnInterrupt */ } /* Program */ } /* EventDrivenLED
  • Raspberry Pi more a cheap ARM6-based PC to go with size of a credit card With 1 GHz, 512 MB RAM, separate Broadcom Graphics processor, HDMI. Often used as media center (XBMC) Created by the Raspberry Pi Foundation. „PI“ originally came from „Python Interpreter“. Not fully open source! GNU/Linux (Raspbian), or other OS loaded from a SD card Voltage 5V (Micro-USB or batteries) Ports: 17 Digital GPIO-Pins, SPI, I²C, UART, EGL Caution: Ports can only handle 3.3V GPIO = General Purpose I/O SPI = Serial Peripheral Interface EGL = Programming Interface: shields APIs (OpenGL, ...) from the underlying windowing system
  • Using the GPIO Pins Different choices: Python, favourite language of the RPi creators Unix Shell: writing 1 to the port 17 with the program gpio: gpio -g write 17 1 C/C++ Javascript Java HTML5 Perl import RPi.GPIO as GPIO import time /* use board pin numbers */ GPIO.setmode(GPIO.BOARD) /* use it as an output port */ GPIO.setup(11, GPIO.OUT) def helloRPi(pin): GPIO.output(pin,GPIO.HIGH) time.sleep(1) GPIO.output(pin,GPIO.LOW) time.sleep(1) return Erlang for i in range(0,1000): helloRPi(11) ... GPIO.cleanup()
  • Expanding the Raspberry Pi Limited capabilities compared with Arduino Various shields available, e.g.: Shield to connect Raspberry Pi & Arduino Shield to expand the capabilities of RPi The Gert Board is a well known expansion board Sold assembled and not assembled 12 x Buffered I/O 3 x Push Buttons 6 x Open collector drivers (50V, 0.5A) 18V, 2A motor controller 28-pin dual in line ATmega microcontroller 2 -channel 8, 10, or12 bit Digital to Analog converter 2- channel 10 bit Analog to Digital converter
  • beagleboard.org beagleboard.org - BeagleBone BeagleBone Black, the sprinter: Powered by Embedded Linux CPU AM335x 1GHz ARM® Cortex-A8 512MB DDR3 RAM 2GB 8-bit eMMC on-board flash 3D graphics accelerator NEON floating-point accelerator 2x PRU 32-bit microcontrollers Connectivity USB client for power & communications USB host Ethernet HDMI 2x 46 pin headers • PRU • PMIC = Programmable Realtime Unit = Power Management IC
  • BeagleBone External Interface Pins Satisfaction guaranteed
  • BeagleBone Programming Supports Python, Perl, C/C++, JVM Languages, JavaScript + BoneScript Library, Shell commands, ... Can interact with Arduino serially using Java RxTx Eclipse,Visual Studio, Cloud9 support JavaScript + BoneScript var b = require('bonescript'); var state = b.LOW; b.pinMode("USR0", b.OUTPUT); b.pinMode("USR1", b.OUTPUT); b.pinMode("USR2", b.OUTPUT); b.pinMode("USR3", b.OUTPUT); setInterval(toggle, 1000); function toggle() { if(state == b.LOW) state = b.HIGH; else state = b.LOW; b.digitalWrite("USR3", state); }
  • And the rest? pcDuino: Arduino + Android or Linux Nanode: Actually, an extended Arduino Libelium Waspnode: Designed for Wireless Sensor Networks, uses the Arduino IDE, for Arduino sketches - only some adjustments necessary ... CubieBoard, PandaBoard, ... Mona Lisa built with hardware (c) http://karachi.olx.com.pk/
  • What we didn‘t hear This was the tip of the iceberg In practice, we face additional challenges: Multitasking and Synchronization Board-to-Board Communication Native tools „ilities“ such as Safety Real-time requirements Developing Drivers Evolution and Update Product Families Testing & Debugging ... Nonetheless, the capabilities of open source hardware as well as its wide acceptance are more than promising. Wiring is fun!
  • Robotics For robotics applications you may use Arduino, Raspberry Pi, BeagleBone et al. but that is tedious Often, special robotics kits may be the better choice, e.g., Lego Mindstorms EV3 Not open source but often used for prototyping or demos Contains NI LabVIEW, a graphical programming environment.You may also use: LeJOS implements Java and provides its own firmware RobotC ... many further options ...
  • State-of-theState-of-the-Art Software is essential for embedded devices Only a few systems today aren‘t based on software Today‘s microcontrollers are several orders of magnitudes more powerful than an Intel 8051 Open Source Hardware helps to learn the fundamentals of embedded systems (development) to build prototypes to create commercial systems to implement physical computing devices that interact with users and the Web to have fun Most systems can be programmed using comfortable IDEs But don‘t let the IDEs fool you. Embedded systems differ significantly from desktop systems, e.g., Hard resource constraints (small memory, short battery lifetime, less speed, ...) Time as a first order concept Integration with electronics, mechatronics, mechanics, ... Dependability and Safety Testing & Simulators Updates of (mobile) devices
  • Future Trends The Future is Embedded Modern cars contain a network with several dozens interconnected embedded systems In „hardware“-companies like Siemens two thirds of revenues depend on software. And this number is increasing. There are far more embedded systems than other systems, but they are usually hidden in a box Connected embedded systems become commodity products (example: cars, home automation) New types of HMI (Human Machine Interaction) Robotics on the rise Arduino-based or not? Resistance is futile Human-Machine Interaction
  • Conclusions Open source hardware boards offer a cheap and easy way to dive into embedded systems Arduino & Raspberry Pi & Beaglebone are the VIPs Arduino is superior for pure electronics projects, but Arduino Yun and Arduino Tre provide a Linux system, a microcontroller, and a bridge Raspberry Pi comprises a small Linux system BeagleBone: Arduino-like GPIO and Linux-based like Raspberry PI Netduino: interesting for .NET developers compatible with the Arduino board layout (shield compatible) BeagleBone and other boards http://hacknmod.com/hack/make-a-uav-spyplane-using-the-arduino/ • Dear NSA, the community strikes back with an Arduinobased Drone! • Already available and much cheaper than the Euro-Hawk! are powerful but have less distribution Board selection based on need and available support Lego Mindstorms EV3 is excellent for learning robotics albeit commercial Solutions for connecting Arduino/Raspberry Pi, Arduino/ Mindstorms, ... already available Boards help to learn the pitfalls of developing embedded software without needing a safety net
  • Some folks won‘t ever give away their Arduino board Others would shamelessly steal it It is like a precious ring So, keep an eye on your ring micro controller board
  • Last Words:The Pain of Engineering The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong, it usually turns out to be impossible to get at and repair. [Douglas Adams]