886fbf002020f88ceca991c100c5d10b61f9d644
Physical
Conceptual Design
Physical is a library for interacting with the physical world from a computer. This can broadly be broken down into two categories:
- Collecting and digitizing data from the physical world.
- Controlling devices that take physical action.
As this is a broad purpose physical is intended to run on or interact with a wide range of computer hardware. This broad range of hardware can be categorized into two distinct "layers".
Computer Hardware Layers
-
Peripherals - A peripheral is a minimal set of hardware and firmware that directly interfaces with sensors or controllers (in fact it may be a single hardwired sensor or controller).
- Peripherals are always where analog to digital conversion takes place in the case of inputs and digital to analog conversion takes place in the case of outputs.
- Peripherals are things that run extremely minimal software, either with no dedicated operating system at all or a minimal RTOS such as Embassy.
- Peripherals should do very little data processing, usually directly sending collected data to the host in the case of inputs or adjusting electronics components in response to output settings. Potentially a peripheral could have some very simple logic built in for things that need extremely fast response times such as closing a gate between two evacuated solar collectors when one loses vacuum.
- Physical is designed to work with peripherals running arbitrary firmware, i.e. peripherals do not need to be running any components from physical. However, it will eventually be possible for to make firmware for peripherals using firmware.
-
Hosts - A host is the computer peripherals are connected to. A host may be a fairly low power single board computer like a raspberry pi 0, all the way up to a 128 core supercomputer.
- Hosts are intended to run full fledged multi-process operating systems such as GNU/Linux.
- Hosts are intended to do the heavy lifting of data processing and decision making for the system being controlled.
Software Abstractions
- Input - Individual unit for data collection (e.g. an analog input reads a voltage).
- Output - Individual unit for device control.
- Transformation - Some way of transforming data coming from inputs and going to outputs. E.g. transforming an analog input to a type K thermocouple. Transformations are for I/O where many different physical sensors or devices could be plugged into an input or output and need some algorithm applied to the direct data for it to be useful. E.g. analog input reads voltage whether a thermocouple or pressure sensor is connected to it. Transformation will transform the voltage to temperature or pressure.
- Peripheral - Software representation of what's described in "Computer Hardware Layers".
- Peripherals host inputs and outputs.
- Connection - Peripherals could be connected to the host in various ways (SPI, I²C, USB, etc.) different connection methods must be supported in physical.
Device Builder
- In physical, all configuration must be done ahead of time. That is once the device build phase of the program is complete, there cannot be any change to the configuration.
- Peripherals cannot be added or removed.
- I/O settings cannot be changed.
- The only allowed "change" is to change the value of an output (like setting a digital output to high instead of low).
Roadmap
- Minimal implementation of physical for hosts. Think about what components can be separated out and reused for peripherals.
- Add support for more peripherals (basically aiming to add support for what's needed for early BFPOWER systems).
- Common abstractions for system control (recording, PID control, etc.)
- Implementation of physical running directly on peripherals.
- Kotlin embedded DSL and general API to make simple programs to be run on a physical host (optional).
- GUI to be run on a physical host to do simple data collection, control, and analysis.
Questions
- Nested hosts - Should there be abstractions built in to physical for setting one host to be the master of another.
- Leaning towards not having this. Would be better to have slightly more sophisticated peripherals running a RTOS then to have the added complexity of nested hosts.
Languages
Rust
100%