SlideShare a Scribd company logo
1 of 21
Download to read offline
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

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 studyLinaro
 
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 OpenCSDLinaro
 
TFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesTFLite NNAPI and GPU Delegates
TFLite NNAPI and GPU DelegatesKoan-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 VerkuilAnne Nicolas
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012Philip Polstra
 
Cyberhijacking Airplanes Truth or Fiction
Cyberhijacking Airplanes Truth or FictionCyberhijacking Airplanes Truth or Fiction
Cyberhijacking Airplanes Truth or FictionPhilip Polstra
 
Dist::Zilla - A very brief introduction
Dist::Zilla - A very brief introductionDist::Zilla - A very brief introduction
Dist::Zilla - A very brief introductionDean 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
 
Process injection - Malware style
Process injection - Malware styleProcess injection - Malware style
Process injection - Malware styleSander 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
 
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 Projectlinuxlab_conf
 
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 computersIan Kluft
 
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 launchesLeszek Godlewski
 
Building the ZoomFloppy (ECCC 2010)
Building the ZoomFloppy (ECCC 2010)Building the ZoomFloppy (ECCC 2010)
Building the ZoomFloppy (ECCC 2010)Nate Lawson
 
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 cheapedlangley
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machinesAnne 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 Processorsaccount inactive
 
Embedded platform choices
Embedded platform choicesEmbedded platform choices
Embedded platform choicesTavish Naruka
 
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 KitSulamita Garcia
 
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 201244CON
 
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 ARMSherif Mousa
 
Nios2 and ip core
Nios2 and ip coreNios2 and ip core
Nios2 and ip coreanishgoel
 

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

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 

Recently uploaded (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 

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