[−][src]Crate sac_base
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.
Example
The following example, can be build by the code given below:
// // +----+ // | | // +--+ In +----+ // | | | +-----+ // +----+ +---+ | // | Add +----+-------------+ // +----+ +---+ | | | // | | | +-----+ | | +-----+ // +--+ In +----+ | +-----+ | // | | | | Mul +------+---+ // +----+ | +-----+ | | // | +-----+ | +-----+ | // +----+ +--+ | | | // | | | Add | | | // +--+ In +----------------------+ +----+ | // | | | | | // +----+ +-----+ | | // | +-----+ | // | | // | | // +-----------------------------------+ use sac_base::network::network::Network; use sac_base::operations::math::add::Add; use sac_base::operations::miscellaneous::buffer::Buffer; use sac_base::operations::math::multiply::Multiply; // Generate the network let mut network: Network<f32> = Network::new(); // Generate some operations let add1 = network.add_operation(Add::new()); let mul1 = network.add_operation(Multiply::new()); let add2 = network.add_operation(Add::new()); // Add some inputs let in1 = network.add_input(Buffer::new()); let in2 = network.add_input(Buffer::new()); let in3 = network.add_input(Buffer::new()); // Connect the operations with each other network.add_connection(&in1, &add1).unwrap(); network.add_connection(&in2, &add1).unwrap(); network.add_connection(&add1, &add2).unwrap(); network.add_connection(&in3, &add2).unwrap(); network.add_connection(&add1, &mul1).unwrap(); network.add_connection(&add2, &mul1).unwrap(); // Register the multiplication as an output network.as_output(&mul1); // Insert a closed loop (Positive feedback loop) network.close_loop(&mul1, &add2); // Generate the network network.build(); // Main loop operation // Update the inputs network.set_inputs(|input, index | { *input = 5.0; }); // Iterate over the network network.process(); let res = network.get_outputs(); // Update the inputs network.set_inputs(|input, index | { *input = 10.0; }); // Process twice to let the closed loop propagate network.process(); let res = network.get_outputs();
Outlook
Following features are planned before the first release:
- Signal and Control crates.
- Subnetworks to allow different time bases
Modules
network | |
operations |