sac-base (Signal And Control)
sac-base is the base crate of its two child crates sac-control and sac-signal. This crate is still under heavy construction and not finished.
Idea
The sac-* crates help to implement signal processing and control systems in a network based approach. Similar to to Simulink as example. The project is designed for a primary usage on embedded systems and is therefore a [no_std] crate. A generic solution such as the used network based approach will never be as fast as a custom system implementation for a specific problem. But it will allow to directly and quickly implement and change systems in code instead of designing it Matlab and exporting it to C. Generation the network and building the topology is relatively expensive. Therefore the crate does all the allocations and setup before the normal operation starts. This base crate is designed in a way that allows the Signal and the Control crate to easily extend it, and allow the operations to be interchangeable between each other. Both the sac-control and the sac-signal are under construction and are not available yet.
Base crate
The base crate provides the following features:
- Network description.
- Base node implementation which the operations are based on.
- Simple math operations such as adding, subtraction. Generally operations that will be used in both the Signal and Control crates.
- Generic elements such as buffers.
no_std
The library is built with no_std. Therefore it can be used on embedded systems and while not tested, probably wasm aswell.
Example
The following example, can be build by the code given below:
//
// +----+
// | |
// +--+ In +----+
// | | | +-----+
// +----+ +---+ |
// | Add +----+-------------+
// +----+ +---+ | | |
// | | | +-----+ | | +-----+
// +--+ In +----+ | +-----+ |
// | | | | Mul +------+---+
// +----+ | +-----+ | |
// | +-----+ | +-----+ |
// +----+ +--+ | | |
// | | | Add | | |
// +--+ In +----------------------+ +----+ |
// | | | | |
// +----+ +-----+ | |
// | +-----+ |
// | +-----+ |
// | | | |
// +--------------+ z^1 +--------------+
// | |
// +---- +
//
use Network;
use Add;
use Buffer;
use Multiply;
// Generate the network
let mut network = new;
// Generate some operations
let add1 = network.add_operation;
let mul1 = network.add_operation;
let add2 = network.add_operation;
// Add some inputs
let in1 = network.add_input;
let in2 = network.add_input;
let in3 = network.add_input;
// Connect the operations with each other
network.add_connection.unwrap;
network.add_connection.unwrap;
network.add_connection.unwrap;
network.add_connection.unwrap;
network.add_connection.unwrap;
network.add_connection.unwrap;
// Register the multiplication as an output
network.as_output;
// Insert a closed loop (Positive feedback loop)
network.close_loop;
// Generate the network
network.build;
// Main loop operation
// Update the inputs
network.set_inputs;
// Iterate over the network
network.process;
let res = network.get_outputs;
// Update the inputs
network.set_inputs;
// Process twice to let the closed loop propagate
network.process;
let res = network.get_outputs;
Extending the functionality
It is likely that the library does not implement all the operations that will be needed in your application. Implementing a new operation is simple and can be added outside of the library.
As example: Lets say you want to add a new operation that drops every third element.
// we need a possibility to count. So we need to add a count variable to the struct which will
// be boxed and moved into the node
use Node;
use Any;
use Network;
// Now define the functionality
let mut network: = new;
// Insert the new node into the network
let third = network.add_operation;
network.build;
network.set_input_slice;
network.process;
let res = network.get_output.unwrap;
assert_eq!;
Outlook
- Base crate:
- Operations:
- To chunk and from chuck operations
- Far future:
- Static operation (With heapless vectors as feature)
- Operations:
- Signal processing:
- Control: