SlideShare a Scribd company logo
Embedded Erlang, Nerves, and
SumoBots
Frank Hunleth
Twitter: @fhunleth
Erlang Factory 2015
Agenda
● Embedded Erlang and the problem to be solved
● Nerves Project overview
● Getting started with the base image
● Communicating with hardware
● Putting everything together
Road to Embedded Erlang (ca. 2012)
● Searching for a better way to build embedded devices
– Embedded for me was 32-bit micro w/ RTOS or Linux and
C/C++
● Erlang/OTP provided the high level functionality that I
had been writing already
● Others had used it in embedded
– Ericsson's AXD301 switch
– Various hits on Google
– Open-source projects for accessing hardware on GitHub
The Problems
● Erlang installations were huge
– Required desktop Linux install
– Megaco, CORBA??
– Clearly others had fixed this, but where?
● Open-source libraries for accessing hardware
were not well-maintained
– Erlang/ALE helped, but now suffers
– How many erlang-serial forks?
Nerves Project
● What would a small to mid-sized embedded
system look like if as much as possible was done
or controlled by Erlang?
● Practice
– Embedded Linux w/ glibc for POSIX APIs
– Cross-compiled to only need libraries and apps
required for the device (Build systems pull in a lot)
– Calling into programs for network setup, etc is ok to
avoid rebuilding everything
Nerves Themes
● Erlang VM, of course
● Minimalist
● Buildroot
● Custom init process, erlinit
● OTP releases
● Full system updates
Nerves Work Flow
OTP applications
BEAMs and
cross-compiled
binaries
Erlang/OTP
release
Base Firmware
Image
SDCard image
and
firmware update
package
mix,
rebar,
erlang.mk
relx
Nerves scripts
nerves-sdk
customizations to
Buildroot
Updated filesystem
on target
(Development)
relsync
Cross-compiling
● Building your program on a different machine (or VM) that
runs it
● Why?
– Development cycle on the target is painful
– Target is slow or doesn't have enough memory
– Networking, video and other interfaces taken over by the program
● Sometimes cross-compiled development is painful
– Structure code so that it can be developed and tested on host
– Debug hardware interface code on target with a full Linux install
Demo
● Building the base Nerves image
– Clone https://github.com/nerves-project/nerves-sdk
– make nerves_rpi_defconfig
– make
– make burn-complete
● Booting
● Bringing up Ethernet and sending messages
10 Seconds on Building the Frame
● Original plans from http://sumobotkit.com/
– One of the least expensive robotics “kits” out there
– Intended for use with Node.js (search for NodeBots)
– Lasercut 5 mm hardwood plywood
– 3D printed ball holder
● Modified plans at
https://github.com/fhunleth/elixirbot
Controlling Hardware from Erlang
● Erlang/ALE and Elixir/ALE
– GPIO, I2C, SPI for Linux platforms
– Erlang/ALE has PWM support for Raspberry Pi
● Erlang-serial
– UART for Linux platforms
– Many forks - see
https://github.com/knewter/erlang-serial
Servos
● Motors that turn to a precise angle based on an input signal
● Continuous-turn servos are servos with the feedback
mechanism removed
– Really just motors in a convenient package
– Stop, Clockwise, Counter-clockwise
● Signal is sent on the white wire
– Pulse sent every 20 ms
– Duration of pulse controls angle or direction
– 1.5 ms is neutral
Servo Control Strategies
● Option 1
– Gpio.write(myservo, 1)
– :timer.sleep(1.5)
– Gpio.write(myservo, 0)
– :timer.sleep(20 - 1.5)
● Issues
– Pulse durations must be consistent (within microseconds) or the
servo is unstable
– Much better implemented in C (called software PWM)
– Even C has trouble on Linux due to context switches, etc.
Servo Control Strategies
● Option 2:
– Use hardware PWM on Raspberry Pi
● Issues
– Original Pi's only exposed one hardware PWM
– Standard RPi way doesn't use generic PWM kernel
driver
Servo Control Strategies
● Option 3: Use a microcontroller
– Microcontrollers excel at hard real-time!
– Communicate via standard I2C bus
– Arduinos have made programming and using
microcontrollers very accessible
– ATtiny85 is $1.67 from Digikey - doesn't need any extra parts
– Can even buy preprogrammed PWM drivers
● Issues
– Microcontrollers are programmed in C
Simplified ElixirBot Connections
4 AA Batteries
5 V
I2C, 3.3 V
5 V Regulator
ATtiny85
Servos
Battery level
Control signal
Control signal
I2C Interface to the ATTiny85
● I2C bus address 0x4
● Protocol
– First byte in a write sets the
ATTiny85's active register
– Subsequent read or write
accesses active register
– Active register increments after
operation
● Write <<2, Right:16/little>> to
set the right servo's pulse
duration
Left duration (μs) LSB
Left duration (μs) MSB
Right duration (μs) LSB
Right duration (μs) MSB
Battery volts (mV) LSB
Battery volts (mV) MSB
Registers
0
1
2
3
4
5
Debug
Debug
6
7
Demo
● Create a new Elixir project that uses Nerves
● Pull in Elixir/ALE
● Communicate via I2C to the ATTiny85
● Move the robot
The Rest of the Pieces
● Web-based control
– Slightly modified Cowboy websockets example
● Video
– MotionJPEG streamed via Cowboy
– Image tag in HTML running on client
● Wi-Fi
● https://github.com/fhunleth/elixirbot
Going Farther
● Try out the Nerves Project for yourself
– All open source and hosted on GitHub
– http://nerves-project.org
● Supported hardware
– Raspberry Pi, Beaglebone Black, various embedded x86
– Ports to hardware supported by Buildroot generally easy
● Keep in touch
– Twitter: @fhunleth
– Email: fhunleth@troodon-software.com
Embedded Erlang, Nerves, and
SumoBots
Frank Hunleth
Twitter: @fhunleth
Erlang Factory 2015

More Related Content

What's hot

Thotcon2013
Thotcon2013Thotcon2013
Thotcon2013
Philip Polstra
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case study
Linaro
 
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
Linaro
 
TFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesTFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU Delegates
Koan-Sin Tan
 
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans VerkuilKernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Anne Nicolas
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
Opersys inc.
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 
The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012
Philip Polstra
 
Cyberhijacking Airplanes Truth or Fiction
Cyberhijacking Airplanes Truth or FictionCyberhijacking Airplanes Truth or Fiction
Cyberhijacking Airplanes Truth or Fiction
Philip Polstra
 
Dist::Zilla - A very brief introduction
Dist::Zilla - A very brief introductionDist::Zilla - A very brief introduction
Dist::Zilla - A very brief introduction
Dean Hamstead
 
LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)
Linaro
 
A Peek into TFRT
A Peek into TFRTA Peek into TFRT
A Peek into TFRT
Koan-Sin Tan
 
Process injection - Malware style
Process injection - Malware styleProcess injection - Malware style
Process injection - Malware style
Sander Demeester
 
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
linuxlab_conf
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
Emertxe Information Technologies Pvt Ltd
 
Stefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto ProjectStefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto Project
linuxlab_conf
 
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
Emertxe Information Technologies Pvt Ltd
 
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computersPiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
Ian Kluft
 
Embedded C workshop
Embedded C workshopEmbedded C workshop
Embedded C workshop
Mostafa El-koumy
 
Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...
Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...
Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...
Anne Nicolas
 

What's hot (20)

Thotcon2013
Thotcon2013Thotcon2013
Thotcon2013
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case study
 
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
 
TFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesTFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU Delegates
 
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans VerkuilKernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
Kernel Recipes 2017 - HDMI CEC: Status Report - Hans Verkuil
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012
 
Cyberhijacking Airplanes Truth or Fiction
Cyberhijacking Airplanes Truth or FictionCyberhijacking Airplanes Truth or Fiction
Cyberhijacking Airplanes Truth or Fiction
 
Dist::Zilla - A very brief introduction
Dist::Zilla - A very brief introductionDist::Zilla - A very brief introduction
Dist::Zilla - A very brief introduction
 
LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)
 
A Peek into TFRT
A Peek into TFRTA Peek into TFRT
A Peek into TFRT
 
Process injection - Malware style
Process injection - Malware styleProcess injection - Malware style
Process injection - Malware style
 
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
Stefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto ProjectStefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto Project
 
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
 
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computersPiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
 
Embedded C workshop
Embedded C workshopEmbedded C workshop
Embedded C workshop
 
Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...
Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...
Kernel Recipes 2017 - Developing an embedded video application on dual Linux ...
 

Similar to Embedded Erlang, Nerves, and SumoBots

One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launches
Leszek Godlewski
 
Building the ZoomFloppy (ECCC 2010)
Building the ZoomFloppy (ECCC 2010)Building the ZoomFloppy (ECCC 2010)
Building the ZoomFloppy (ECCC 2010)
Nate Lawson
 
Arduino Hands-on Workshop
Arduino Hands-on WorkshopArduino Hands-on Workshop
Arduino Hands-on Workshop
Suraj Kumar Jana
 
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheapUWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
edlangley
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machines
Anne Nicolas
 
Case Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded ProcessorsCase Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded Processors
account inactive
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
Tavish Naruka
 
Embedded platform choices
Embedded platform choicesEmbedded platform choices
Embedded platform choices
Tavish Naruka
 
Monkey Server
Monkey ServerMonkey Server
Monkey Server
Eduardo Silva Pereira
 
Bringing Tizen to a Raspberry Pi 2 Near You
Bringing Tizen to a Raspberry Pi 2 Near YouBringing Tizen to a Raspberry Pi 2 Near You
Bringing Tizen to a Raspberry Pi 2 Near You
Samsung Open Source Group
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
Sulamita Garcia
 
Polstra 44con2012
Polstra 44con2012Polstra 44con2012
Polstra 44con2012
Philip Polstra
 
Hacking and Forensics on the Go - 44CON 2012
Hacking and Forensics on the Go - 44CON 2012Hacking and Forensics on the Go - 44CON 2012
Hacking and Forensics on the Go - 44CON 2012
44CON
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++
JetBrains
 
Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...
Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...
Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...
jaxLondonConference
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
Sherif Mousa
 
arduino.pdf
arduino.pdfarduino.pdf
arduino.pdf
Gurumurthy B R
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Nios2 and ip core
Nios2 and ip coreNios2 and ip core
Nios2 and ip core
anishgoel
 

Similar to Embedded Erlang, Nerves, and SumoBots (20)

One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launches
 
Building the ZoomFloppy (ECCC 2010)
Building the ZoomFloppy (ECCC 2010)Building the ZoomFloppy (ECCC 2010)
Building the ZoomFloppy (ECCC 2010)
 
Arduino Hands-on Workshop
Arduino Hands-on WorkshopArduino Hands-on Workshop
Arduino Hands-on Workshop
 
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheapUWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machines
 
Case Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded ProcessorsCase Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded Processors
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
 
Embedded platform choices
Embedded platform choicesEmbedded platform choices
Embedded platform choices
 
Monkey Server
Monkey ServerMonkey Server
Monkey Server
 
Bringing Tizen to a Raspberry Pi 2 Near You
Bringing Tizen to a Raspberry Pi 2 Near YouBringing Tizen to a Raspberry Pi 2 Near You
Bringing Tizen to a Raspberry Pi 2 Near You
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 
Polstra 44con2012
Polstra 44con2012Polstra 44con2012
Polstra 44con2012
 
Hacking and Forensics on the Go - 44CON 2012
Hacking and Forensics on the Go - 44CON 2012Hacking and Forensics on the Go - 44CON 2012
Hacking and Forensics on the Go - 44CON 2012
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++
 
Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...
Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...
Do You Like Coffee with Your dessert? Java and the Raspberry Pi - Simon Ritte...
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
arduino.pdf
arduino.pdfarduino.pdf
arduino.pdf
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Nios2 and ip core
Nios2 and ip coreNios2 and ip core
Nios2 and ip core
 

Recently uploaded

Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

Embedded Erlang, Nerves, and SumoBots

  • 1. Embedded Erlang, Nerves, and SumoBots Frank Hunleth Twitter: @fhunleth Erlang Factory 2015
  • 2. Agenda ● Embedded Erlang and the problem to be solved ● Nerves Project overview ● Getting started with the base image ● Communicating with hardware ● Putting everything together
  • 3. Road to Embedded Erlang (ca. 2012) ● Searching for a better way to build embedded devices – Embedded for me was 32-bit micro w/ RTOS or Linux and C/C++ ● Erlang/OTP provided the high level functionality that I had been writing already ● Others had used it in embedded – Ericsson's AXD301 switch – Various hits on Google – Open-source projects for accessing hardware on GitHub
  • 4. The Problems ● Erlang installations were huge – Required desktop Linux install – Megaco, CORBA?? – Clearly others had fixed this, but where? ● Open-source libraries for accessing hardware were not well-maintained – Erlang/ALE helped, but now suffers – How many erlang-serial forks?
  • 5. Nerves Project ● What would a small to mid-sized embedded system look like if as much as possible was done or controlled by Erlang? ● Practice – Embedded Linux w/ glibc for POSIX APIs – Cross-compiled to only need libraries and apps required for the device (Build systems pull in a lot) – Calling into programs for network setup, etc is ok to avoid rebuilding everything
  • 6. Nerves Themes ● Erlang VM, of course ● Minimalist ● Buildroot ● Custom init process, erlinit ● OTP releases ● Full system updates
  • 7. Nerves Work Flow OTP applications BEAMs and cross-compiled binaries Erlang/OTP release Base Firmware Image SDCard image and firmware update package mix, rebar, erlang.mk relx Nerves scripts nerves-sdk customizations to Buildroot Updated filesystem on target (Development) relsync
  • 8. Cross-compiling ● Building your program on a different machine (or VM) that runs it ● Why? – Development cycle on the target is painful – Target is slow or doesn't have enough memory – Networking, video and other interfaces taken over by the program ● Sometimes cross-compiled development is painful – Structure code so that it can be developed and tested on host – Debug hardware interface code on target with a full Linux install
  • 9. Demo ● Building the base Nerves image – Clone https://github.com/nerves-project/nerves-sdk – make nerves_rpi_defconfig – make – make burn-complete ● Booting ● Bringing up Ethernet and sending messages
  • 10. 10 Seconds on Building the Frame ● Original plans from http://sumobotkit.com/ – One of the least expensive robotics “kits” out there – Intended for use with Node.js (search for NodeBots) – Lasercut 5 mm hardwood plywood – 3D printed ball holder ● Modified plans at https://github.com/fhunleth/elixirbot
  • 11. Controlling Hardware from Erlang ● Erlang/ALE and Elixir/ALE – GPIO, I2C, SPI for Linux platforms – Erlang/ALE has PWM support for Raspberry Pi ● Erlang-serial – UART for Linux platforms – Many forks - see https://github.com/knewter/erlang-serial
  • 12. Servos ● Motors that turn to a precise angle based on an input signal ● Continuous-turn servos are servos with the feedback mechanism removed – Really just motors in a convenient package – Stop, Clockwise, Counter-clockwise ● Signal is sent on the white wire – Pulse sent every 20 ms – Duration of pulse controls angle or direction – 1.5 ms is neutral
  • 13. Servo Control Strategies ● Option 1 – Gpio.write(myservo, 1) – :timer.sleep(1.5) – Gpio.write(myservo, 0) – :timer.sleep(20 - 1.5) ● Issues – Pulse durations must be consistent (within microseconds) or the servo is unstable – Much better implemented in C (called software PWM) – Even C has trouble on Linux due to context switches, etc.
  • 14. Servo Control Strategies ● Option 2: – Use hardware PWM on Raspberry Pi ● Issues – Original Pi's only exposed one hardware PWM – Standard RPi way doesn't use generic PWM kernel driver
  • 15. Servo Control Strategies ● Option 3: Use a microcontroller – Microcontrollers excel at hard real-time! – Communicate via standard I2C bus – Arduinos have made programming and using microcontrollers very accessible – ATtiny85 is $1.67 from Digikey - doesn't need any extra parts – Can even buy preprogrammed PWM drivers ● Issues – Microcontrollers are programmed in C
  • 16. Simplified ElixirBot Connections 4 AA Batteries 5 V I2C, 3.3 V 5 V Regulator ATtiny85 Servos Battery level Control signal Control signal
  • 17. I2C Interface to the ATTiny85 ● I2C bus address 0x4 ● Protocol – First byte in a write sets the ATTiny85's active register – Subsequent read or write accesses active register – Active register increments after operation ● Write <<2, Right:16/little>> to set the right servo's pulse duration Left duration (μs) LSB Left duration (μs) MSB Right duration (μs) LSB Right duration (μs) MSB Battery volts (mV) LSB Battery volts (mV) MSB Registers 0 1 2 3 4 5 Debug Debug 6 7
  • 18. Demo ● Create a new Elixir project that uses Nerves ● Pull in Elixir/ALE ● Communicate via I2C to the ATTiny85 ● Move the robot
  • 19. The Rest of the Pieces ● Web-based control – Slightly modified Cowboy websockets example ● Video – MotionJPEG streamed via Cowboy – Image tag in HTML running on client ● Wi-Fi ● https://github.com/fhunleth/elixirbot
  • 20. Going Farther ● Try out the Nerves Project for yourself – All open source and hosted on GitHub – http://nerves-project.org ● Supported hardware – Raspberry Pi, Beaglebone Black, various embedded x86 – Ports to hardware supported by Buildroot generally easy ● Keep in touch – Twitter: @fhunleth – Email: fhunleth@troodon-software.com
  • 21. Embedded Erlang, Nerves, and SumoBots Frank Hunleth Twitter: @fhunleth Erlang Factory 2015