Machinekit
BuildReal-TimeSystemswithPython
Alexander Rössler
2
Overview
● Machinekit and HAL
● The 4 APIs
● Configure and Run
● Create HAL components
● Interface with the CNC stack
● Remote Control Machinekit
3
AboutMe
● Alexander Rössler
● Embedded Systems
● All things Open Source
● 3D printing, CNC, robots, …
● “Solopreneur”
4
MachinekitandHAL
5
Machinekit
Embedded Devices
TabletsSmartphones
Desktop ComputersCNC Machines
Robots Quadcopters
Machinekit
3D Printers
Other Applications
?
6
Architecture Overview
Hardware
Hardware Abstraction Layer (HAL)
Motion
Controller
IO
Controller
Task Executor
User Interface
CNC Stack
7
7404
abcd
efgh
Hardware AbstractionLayer
● Configuration
– Components
– Pins
– Signals
● Real-Time
● Userland
8
WhyMachinekitandnot…?
● RT made simple
● Portable
● Future proof
● Runs on Linux
● Tools and GUIs
9
Supported Plattforms
● Desktop Linux PC
● SBCs
– BeagleBone (Black, Green, Blue, …)
– Raspberry Pi 3
– Altera and Xilinx SoC/FPGA
– …
● POSIX, PREEMPT_RT or Xenomai
10
The 4APIs
11
The4 Python APIs
1) Python HAL and configuration API
2) Python HAL component API
3) Python linuxcnc API
4) pymachinetalk
5) ...
12
Whatcanbedone withPython
● Create HAL configurations
● Launch and manage Machinekit/HAL instances
● Create Userland HAL components
● Interface with CNC stack
● Remotely interact with HAL
● Extend GCode
● ...
7404
UI 1
12345
SDK
13
Whatcan’tbe done Python
● Create new HAL RT components
7404
14
ConfigureandRun
15
MachinekitModule
● import machinekit
– config, launcher, hal, rtapi
● src/hal/cython
● lib/python/machinekit
16
VeryBasicHALApplication
● run.py - Run file
● hal_basics.py – HAL config
17
HALBasics
input0
input1
input0
input1
output
in0
in1
out
button0
button1
led
and2.demo anddemo
main-thread
HAL Component HAL Remote Component
HAL Signals
HAL Thread
HAL Pins
HAL Function
18
Tools
● halcmd
● halmeter
● Halscope
● hal-graph
20
Create HAL
Components
21
HALAPI
● import hal
● CPython module
● Lib/python/hal.py
22
Simple HALComponent
● import hal
● Create pins
● Update pins in main loop
● custom_sum
– in0 + in1 = out
24
Interfacewiththe
CNCStack
25
Linuxcnc Module
● import linuxcnc
– stat, command, ini, positionlogger
● CPython module
● lib/python/linuxcnc.so
27
RemoteControl
Machinekit
28
Pymachinetalk
● import machinetalk
● import pymachinetalk
– dns_sd, halremote, application, ...
● Available on PyPI
● Python 3 and 2
● Windows, Linux, Mac, ...
UI 3
12345
UI 2
12345
UI 1
12345
Real-time hostent 1
Real-time environment
HAL instance
Haltalk
12345
UI 3
12345
UI 2
12345
UI 1
12345
UUID
29
Machinetalk
Machinetalk
ZeroMQ
Protobuf
DNS-SDovermDNS
OS, platform technology
30
HalremoteService
● halrcomp & halrcmd
● haltalk
● Remote API
Real-time hostClient 1
Real-time environment
HAL instance
Haltalk
abcd
efgh
Client 2
12345
31
Applications
● Testing Machinetalk
● Remoting HAL
● CLIs and UIs
● Distritbuted HAL setups
● 3rd party plugins
32
Questions?
33
More Information
● http://machinekit.io
● https://machinekoder.com
● Machinekit on Google Google Groups
● https://github.com/machinekit
● https://github.com/machinekoder/cookiecutter-machinekit-python-hal
●

Machinekit - Build Real Time Systems with Python