The micro:bit… inside and out
Joe Finney
School of Computing and Communications
Lancaster University UK
School of Computing and Communications: InfoLab21
What computers used to look like… (I had one of these!)
Commodore 64 ( I had one of these)
What computers used to look like… (I didn’t have one of these – but martin did!)
Sinclair ZX Spectrum (I didn’t have one of these)
And then there was this one too!
BBC Model B (Delivered free to every school in the UK in the 1980s)
Circa January 2015
Micro:bit Legend
Howard Baker
“We have some prototypes…”
BBC R&D by Michael Sparks early 2015… http://www.bbc.co.uk/rd/blog/2015-07-prototyping-the-bbc-microbit
Delivered by a wide partnership
More Prototyping…
The micro:bit SB1…
And More Prototyping…
Micro:bits of Legend…
In the most unlikely places…
Micro:bit SB2 Proof of Concept…
In the most unlikely places…
Micro:Bit Font is called “Pendolino” for a reason…
In the most unlikely places…
Micro:bit device drivers largely written at the car park at Cockerham Junior Football Club…
A whirlwind of events…
But not without its problems…
We delivered 22nd March 2016…
DEMO: Coding a micro:bit with MakeCode
Inside the micro:bit…
25 LED matrix screen Light sensor User definable buttons
17 Digital input/output 6 Analog input 3 PWM output 3 Touch sensitive I2C, SPI, UART
Inside the micro:bit…
16MHz ARM Cortex M0 16KB RAM, 256K FLASH
USB Storage/Serial/Debug
3 axis accelerometer 3 axis magnetometer Temperature sensor Bluetooth Low Energy
How it all works…
Blocks <-> JavaScript Editors
Simulator Compiler
Micro:bit DAL Runtime
pxt.microbit.org
TypeScript
Web sites
PXT
Devices
Introducing the micro:bit runtime
Provides a Device Abstraction Layer (DAL) for the BBC micro:bit
Built on the ARM mbed platform and Nordic libraries
Accessible C/C++ component based API for all capabilities of device
Open source (MIT licence)
Designed with many requirements in mind: High level language features in mind (concurrency, eventing models and managed types)
RAM efficiency
Power efficiency
http://lancaster-university.github.io/microbit-docs/
The micro:bit runtime architecture
The micro:bit community encourages many languages…
The micro:bit runtime architecture II
Eventing and the Message Bus
Many languages support the concept of events.
This is also something that kids find familiar from visual languages such as Scratch.
And something that lends itself to embedded systems too… e.g.
Eventing and the Message Bus
The micro:bit runtime contains a simple yet powerful extensible eventing model
Events are themselves a very simple managed type.
Contain two numeric values: a source and a value.
Every component in the runtime has a unique ID – the source of an event.
Each component can then create ANY value with that ID as a source at any time:
MicroBitEvent e(MICROBIT_ID_GESTURE, MICROBIT_ACCELEROMETER_EVT_SHAKE);
#define MICROBIT_ID_GESTURE 27
#define MICROBIT_ACCELEROMETER_EVT_SHAKE 11
Eventing and the Message Bus
The MessageBus then delivers events to any code that registers an interest.
Functions can be either plain C functions, or C++ methods.
Wildcard values can also be used to capture lots of events at once.
void onShake(MicroBitEvent e)
{
// do something cool here!
}
int main()
{
uBit.messageBus.listen(MICROBIT_ID_GESTURE, MICROBIT_ACCELEROMETER_EVT_SHAKE, onShake);
}
Eventing and the Message Bus The runtime generates a range of events application can build on.
Users can also define their own events easily… just numbers!
#define MICROBIT_ACCELEROMETER_EVT_TILT_UP 1
#define MICROBIT_ACCELEROMETER_EVT_TILT_DOWN 2
#define MICROBIT_ACCELEROMETER_EVT_TILT_LEFT 3
#define MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT 4
#define MICROBIT_ACCELEROMETER_EVT_FACE_UP 5
#define MICROBIT_ACCELEROMETER_EVT_FACE_DOWN 6
#define MICROBIT_ACCELEROMETER_EVT_FREEFALL 7
#define MICROBIT_ACCELEROMETER_EVT_SHAKE 11
#define MICROBIT_BUTTON_EVT_DOWN 1
#define MICROBIT_BUTTON_EVT_UP 2
#define MICROBIT_BUTTON_EVT_CLICK 3
#define MICROBIT_BUTTON_EVT_LONG_CLICK 4
#define MICROBIT_BUTTON_EVT_HOLD 5
#define MICROBIT_BUTTON_EVT_DOUBLE_CLICK 6
#define MICROBIT_RADIO_EVT_DATAGRAM 1
Fiber Scheduler: Providing Concurrent behaviour…
…or at least apparently concurrent behaviour!
Take this simple example again. What behaviour would you expect?
Given that show string will scroll the given text on the 5x5 matrix display…
Fiber Scheduler: Providing Concurrent behaviour…
Fibers can be created at any time, and execute independently
By design, a non pre-emptive scheduler to reduce potential race conditions.
Fibers can sleep, or block on events on the MessageBus
Anytime there’s nothing to do… processor enters a power efficient sleep
void doSomething()
{
while(1)
{
uBit.display.print(‘A’);
uBit.sleep(100);
}
}
void doSomethingElse()
{
while(1)
{
uBit.display.print(‘B’);
uBit.sleep(100);
}
}
Fiber Scheduler: Providing Concurrent behaviour…
void onButtonA()
{
uBit.display.scroll(“hello”);
}
void onButtonB()
{
uBit.display.scroll(“goodbye”);
}
// Then in your main program...
uBit.messageBus.listen(MICROBIT_ID_BUTTON_A, MICROBIT_BUTTON_EVT_CLICK, onButtonA);
uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonB);
Device Drivers Each hardware component is supported by a corresponding C++ object:
MicroBitAccelerometer
MicroBitButton
MicroBitMultiButton
MicroBitCompass
MicroBitDisplay
MicroBitIO
MicroBitLightSensor
MicroBitRadio
MicroBitSerial
MicroBitStorage
MicroBitThermometer
Putting the pieces together…
SimulatorEditors
C++
TypeScript
Blockly
ARMbinary
ARMAssembly
IR
mapping
JavaScript
ARMbinary
Linker
compile
ARMbinary
ARMbinary
link
cached copy
decompileCloud-based compilation
TypeScript
Memory Footprint
micro:bit has 16Mhz Nordic nrf51822 CPU (32 bit Cortex M0)
256 KB FLASH memory, 16KB SRAM…
micro:bit runtime
NordicSoft Device
BLE Bootloader 16 KB
98 KB
FLASH MEMORY SRAM MEMORY
NordicSoft Device
stack 2 KB
8 KB
ARMmbed/Nordic-sdk 2 KB
1.5 KB
User data 2.5 KB
micro:bit runtime
ARMmbed/Nordic-sdk 20 KB
~50 KB
User data ~72 KB
Power Efficiency
Pi 3 ~ 2000mWhttps://www.raspberrypi.org/help/faqs/
Pi Zero ~500mWhttp://raspi.tv/2015/raspberry-pi-zero-power-measurements
http://www.reuk.co.uk/wordpress/microbit-battery-capacity/
What can you do?
Baseball pitch counter – HawaiiMicro:bit in Space – Rishworth SchoolAir guitar – Tech Will Save UsMicro:bit as a security deviceMicro:bit family fun day – IET/Schneider Electric
What can you do?
IET Faraday Challenge Day 2016 winners… the “No-Nod” by Kings School, Winchester. Meeting the Princess Royal at the opening of IET Savoy Place
What can you do?
Veggard from Norway (age 12)
What can you do?
What can you do?
What can you do?
• 13 million visits to the
micro:bit website
• Nearly 10 million code
simulator runs
• And nearly 2 million
compiles to the device
A positive impact that is changing
attitudes
• 70% increase in the number
of girls that said they would
definitely choose computing
• 86% said it made computer
science more interesting
• 88% said it showed that
coding isn’t as hard as they
thought
Source: Discovery Research Report for BBC Learning
The Outcome?
Going Forward…
Blocks <-> JavaScript Editors
Simulator Compiler
Runtime
pxt.microbit.org mini.pxt.io adafruit.pxt.io
TypeScript
Web sites
PXT
Devices
The future is now!
Joe Finney
Micro:bit Foundation
Vision:
In the future, every child will be an inventor
Mission:
To empower children, parents and teachers around the globe to learn and innovate using the micro:bit
Big Objective:
100M people globally will use a micro:bit
BBC micro:bit is going global
Now available in 32 countries
microbit.org in 8 languages
National roll-outs in UK, Iceland, Croatia
78 partner ecosystem
globally!
Croatia: 1000 primary schools Crowd Funded…
Sri Lanka: Early Days…
micro:bit User Group Sri Lanka
Key Take Away…
Everyone can help, visit us at http://microbit.org to find out how!
Call to Action
All children are natural inventors, which micro:bit
is helping unleash!