Skip to main content

Deimos

Control program and data integrations for the Deimos data acquisition ecosystem.

Library usage examples are in examples. Hardware calibration, validation, and benchmark tools are in deimos_procedures.

See the project readme for contact details as well as commentary about the goals and state of the project.

The control program and the firmware-software shared library share a changelog at the workspace level.

Deimos DAQ hardware

Install - Rust

cargo add deimos

Install - Python

pip install deimos-daq

Features & Roadmap

✅ Implemented | 💡 Planned

Feature Category Features
Control Loop ✅ Fixed-dt roundtrip control loop
✅ Network scanning for available hardware
✅ Planned loop termination
✅ Global event logging
✅ Reconnection
✅ Low-CPU-usage background operation
Control Calcs ✅ User-defined custom calcs
✅ Explicit (acyclic) calc expression
✅ Low-pass filters
✅ Sequenced state machines
✅ Polynomial calibration curves
💡 Cyclic expressions with explicit time-delay
💡 Prototype calc w/ rhai script-defined inner function
Data Integrations ✅ User-defined custom targets
✅ Manual read/write
✅ CSV
✅ In-memory dataframe
✅ TimescaleDB
💡 InfluxDB
💡 Zarr file/bucket
💡 Generic sqlite, postgres, etc.
Hardware Peripherals ✅ Deimos DAQs
✅ User-defined custom hardware
✅ User-defined hardware drivers
✅ Hardware-out-of-the-loop wrapper
Socket Interfaces
(peripheral I/O)
✅ User-defined custom interfaces
✅ UDP/IPV4
✅ Unix socket
✅ Thread channel

Concept of Operation

The control program follows the hardware peripheral state machine, which is linear except that an error in any peripheral state results in returning to Connecting.

Peripheral states:

  1. Connecting (no communication with the control machine)
  2. Binding (waiting to associate with a control machine)
  3. Configuring (waiting for operation-specific configuration from control machine)
  4. Operating (roundtrip control)

The controller initialization schedule is:

                  --------------------binding timeout windows
                 /                          /
                /    Controller init       /           
             |====|=====================|====|         timeout to operating
     scan for|                          |==============|
  peripherals|                          |      \
   (broadcast|              sent binding|       \
     binding)|                          |    configuring window
                             peripherals|
                              transition|
                          to configuring|            

In words,

  1. Scan network for peripherals available to bind
    • Broadcast binding request, but do not send configuration; allow Configuring to time out back to Connecting
  2. Initialize controller (set up data integrations, initialize internal state, etc)
  3. Send binding request
  4. Wait for binding responses
  5. Send configuration
  6. Wait for start of Operating

Peripherals acknowledge binding and transition to configuring on their next internal cycle (usually 1ms) after receiving a request to bind. They will then wait for configuration input until the timeout to operating, and either proceed to Operating if configuration was successful, or return to Connecting (and likely return immediately to Binding) if configuration was not successful.

The control loop then follows a fixed schedule on each cycle:

  1. Send control input to peripherals
  2. Wait for outputs from peripherals
    • Target synchronization to middle of cycle
  3. Update time-sync control
  4. Run calculations on peripheral outputs

Control loop timing uses the control machine's best available monotonic clock. Both system time in UTC with nanoseconds and monotonic clock time are stored in order to support post-processing adjustments to account for the slow drift of the monotonic clock relative to system time.

Example: 200Hz Control Program w/ 2 DAQs

use std::time::Duration;

use deimos::calc::{Constant, Sin};
use deimos::peripheral::{PluginMap, analog_i_rev_3::AnalogIRev3};
use controller::context::ControllerCtx;
use deimos::*;

// The name of the operation will be used as the table name for databases,
// or as the file name for local storage.
let op_name = "test_op".to_owned();

// An optional dictionary mapping user-defined custom hardware
// peripheral model numbers to initializer functions.
let peripheral_plugins: Option<PluginMap> = None;

// Configure the controller
//    Sample interval is taken as integer nanoseconds
//    so that any rounding and loss of precision is visible to the user
let rate_hz = 200.0;
let dt_ns = (1e9_f64 / rate_hz).ceil() as u32;  // Control cycle period

// Define idle controller
let mut ctx = ControllerCtx::default();
ctx.op_name = op_name;
ctx.dt_ns = dt_ns;
let mut controller = Controller::new(ctx);

// Set up any number of data integrations,
// all of which will receive the same data at each cycle of the control loop
//    TSDB-flavored postgres database
let buffer_window = Duration::from_nanos(1); // Non-buffering mode
let retention_time = Duration::from_secs(60 * 60);
let timescale_dispatcher: Box<dyn Dispatcher> = TimescaleDbDispatcher::new(
    "<database name>",  // Database name
    "<database address>", // URL or unix socket interface
    "<username>",  // Login name; for unix socket, must match OS username
    "<token env var>",  // Environment variable containing password or token
    buffer_window,
    retention_time,
);
controller.add_dispatcher("tsdb", timescale_dispatcher);

//    A 50MB CSV file that will be wrapped and overwritten when full
let csv_dispatcher: Box<dyn Dispatcher> =
    CsvDispatcher::new(50, dispatcher::Overflow::Wrap);
controller.add_dispatcher("csv", csv_dispatcher);

// Associate hardware peripherals that we expect to find on the network
// The controller can also run with no peripherals at all, and simply do
// calculations on a fixed time interval.
controller.add_peripheral("p1", Box::new(AnalogIRev3 { serial_number: 1 }));
controller.add_peripheral("p2", Box::new(AnalogIRev3 { serial_number: 2 }));

// Set up calcs that will be run at each cycle
//     Add a constant for duty cycle and a sine wave for frequency
let freq = Sin::new(1.0 / (rate_hz / 100.0), 0.25, 100.0, 250_000.0);
let duty = Constant::new(0.5);
controller.add_calc("freq", freq);
controller.add_calc("duty", duty);
//     Set a PWM on the first peripheral to change its frequency in time
controller.set_peripheral_input_source("p1.pwm0_freq", "freq.y");  // A value to be written to the hardware
controller.set_peripheral_input_source("p1.pwm0_duty", "duty.y");
//     Set a PWM frequency on one peripheral based on a measured temperature from the other peripheral
controller.set_peripheral_input_source("p2.pwm0_duty", "duty.y");  // Values can be referenced any number of times
controller.set_peripheral_input_source("p2.pwm0_freq", "p1_rtd_5.temperature_K");

// Serialize and deserialize the controller (for demonstration purposes).
// All of the configuration up to this point, including any custom peripheral plugins
// or user-defined calcs, are serialized with the controller and can be written to and read from a json file.
let serialized_controller: String = serde_json::to_string_pretty(&controller).unwrap();
let _deserialized_controller: Controller = serde_json::from_str(&serialized_controller).unwrap();


// Run the control program
// (skipped here because there are no peripherals
// or databases on the network in the test environment).
// controller.run(&peripheral_plugins, None);

Direct-to-PC Ethernet Connection and Statically-Addressed Networks

Deimos DAQs can be connected directly to your computer by ethernet, bypassing the need for a router or network switch. They can also be used on networks with a switch but no router.

When a Deimos DAQ connects to a network without a DHCP server to provide dynamic IP address assignments, it will automatically self-assign an IP address in the 169.254.x.[2-254]/16 range. It will attempt up to 3 candidate addresses, which limits the maximum amount of address resolution spam on the network, while also yielding a trivially small probability that no candidate address is available.

The rev7 firmware's IPv4 address manager follows this state machine:

stateDiagram-v2
    direction LR

    classDef a stroke-width:2px

    [*] --> Unconfigured:::a

    Unconfigured --> TentativeFallback:::a : Claim next MAC-derived<br>static address candidate
    Unconfigured --> ActiveDhcp:::a : DHCP configured

    TentativeFallback --> ActiveFallback:::a : No ARP conflict
    TentativeFallback --> Unconfigured:::a : ARP conflict
    TentativeFallback --> ActiveDhcp:::a : DHCP configured

    ActiveFallback --> ActiveDhcp:::a : DHCP configured

    ActiveDhcp:::a --> Unconfigured: DHCP deconfigured

To connect directly without a router,

  1. Connect the DAQ's ethernet cable to your computer's ethernet port.
  • (or to a shared network switch with no router).
  • If your computer does not have an ethernet port, an ethernet-to-USB adapter can be used at the expense of added latency.
  1. Check your computer's network settings.
  • Make sure that a static IP address was assigned in the 169.254.X.Y range.
  • This should occur automatically on MacOS and Windows.
  • On linux, you may need to manually set a static IPV4 address: 169.254.254.1/16

Make sure the netmask for your computer's static address is set to exactly /16 (255.255.0.0).

Otherwise, the DAQ will not recognize your computer as being on the same link-local network, and will not respond to your attempts to scan or bind it.

Release files for deimos-daq 0.21.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deimos-daq 0.21.2
File Size Uploaded
deimos_daq-0.21.2.tar.gz 729.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for deimos-daq 0.21.2
File
deimos_daq-0.21.2-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_i686.whl CPython 3.11 abi3 Linux musl 1.2+ x86-32 Details
deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_armv7l.whl CPython 3.11 abi3 Linux musl 1.2+ ARMv7l Details
deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl CPython 3.11 abi3 Linux glibc 2.17+ IBM System/390x Details
deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.11 abi3 Linux glibc 2.17+ PowerPC 64-le Details
deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.11 abi3 Linux glibc 2.17+ ARMv7l Details
deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
deimos_daq-0.21.2-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
deimos_daq-0.21.2-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 31.2 MB

Release files / deimos_daq-0.21.2.tar.gz

Download URL deimos_daq-0.21.2.tar.gz
Size 729.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a2eab22f47429b168b14f335b6353e26329001633698f288e92f79420069c717
BLAKE2b-256 checksum
How to use checksums
258b4e54e14f0dcf0f7f597414477e48ce18706351fb772b9cd7dd0c6cff3a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-win_amd64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0ba02a02a1d7d036a6a5ee0fb348fca48c84c68b5636d3c495d9387a174ccc5e
BLAKE2b-256 checksum
How to use checksums
dcc50d3e81e68b5aeece64ed3efe645c93c2cd6fc9820924a4e0d6de5ded1755
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_x86_64.whl
Size 2.7 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
7356470ae74a0f6845f16fc78b8cbfaaf536597702d675960030ea3fa0206050
BLAKE2b-256 checksum
How to use checksums
e9191e6cd09e4d0666d78efd27901e37881a3bfdec7cd5e0480fe218d6517b7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_i686.whl

Download URL deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_i686.whl
Size 2.7 MB
Tags CPython 3.11 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
b7d5340937607589ee2ca7cedb4d16a4d79ed1a5bf8ce87fcb656101dbdbecad
BLAKE2b-256 checksum
How to use checksums
692a5f9fcbdcd32f3c8230aa25e649ea203ff33a62fbf9f0c5f565c8bca6a1ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_armv7l.whl

Download URL deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_armv7l.whl
Size 2.8 MB
Tags CPython 3.11 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
c9b31ed4aeb1ef5b88bfe98f70d721a793dbbe53ac63af6bd3f8276310b64b3f
BLAKE2b-256 checksum
How to use checksums
37c5029be9607376236fd3f18b7c384818d3c641203f3ea73f429a1cbc860922
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-musllinux_1_2_aarch64.whl
Size 2.6 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
33a8d83a02a89e8701bdb12a1bb7dbd454ea2f7c0a78bb292290faf36d978b57
BLAKE2b-256 checksum
How to use checksums
987358b46bd78a602c4865120586d36ddf8880b1b561048e3e397727f8e87af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.5 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c746da4be38d6a2c714657c60db9302d0fbe6712aec3e2f8ee30647e671d3973
BLAKE2b-256 checksum
How to use checksums
5d330904eede55818b6a14ac7f15385a1a9512e1a15a8bfc52e8954bb5888262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
b4e9bf2642bd559281495cca3a6417b953e090452c8935650f02b126fc55a7a1
BLAKE2b-256 checksum
How to use checksums
e839c08874488aa64d38c700d4624d39813706b5782fea5bb1457381e3c569c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
2977f648151d934453c5c93f71fd0841fe509a7dea61d43e58091dbe1e0a599f
BLAKE2b-256 checksum
How to use checksums
b949607d9a50a024a8ca32e1b991f2f8610400fb0504686e7d5038c76e541ea7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 2.5 MB
Tags CPython 3.11 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
f81a4b3a0d6f9585c732d8d565b61ad38b3befa5f3823a5890ddf9f6a75b65d2
BLAKE2b-256 checksum
How to use checksums
de54dd9f3ff056ddae853d8c65b4b22134b8886c250b52593765b028c9784a99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.4 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f393ddc14ec9e1893508de6dc82eb303e6944247c31ad3cffdc6211f14b5b210
BLAKE2b-256 checksum
How to use checksums
3986ec8d14a9d88825b5359e9d01bb1b7fd8d39f16306173f1cbd8c7f36e4f71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-macosx_11_0_arm64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7e84afa60e4d879f3ca6a50a7e0d731118a8449da55875206b2b6eef3e7843aa
BLAKE2b-256 checksum
How to use checksums
a59a520a7fe3b6a44f4cf4e5709c8d910731d2d9fa83e370517ba80dd1de6ebb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / deimos_daq-0.21.2-cp311-abi3-macosx_10_12_x86_64.whl

Download URL deimos_daq-0.21.2-cp311-abi3-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
62d6e1049d1677cf163ad47fa249aefd5e2bf52adbe49ab934ed3b1c1b30202d
BLAKE2b-256 checksum
How to use checksums
4e3f109d72996be9f0b65f34f06c8653618efb05c84b66fbcbe6c40bff1fd033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release history Release notifications | RSS feed

This release

0.21.2 This release

13 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page