Multi-master feature for distributed networked control systems
Table of Contents
This note focuses on the multi-master feature of the B-Box/B-Board that enables distributed networked control of power electronic systems.
The multi-master feature allows executing control codes on multiple B-Box/B-Board units interconnected using optical fiber (SFP). The imperix home-made protocol (RealSync) allows for low latency communication (sub-μs) and high data exchange rate (hundreds of kHz) all while keeping synchronized sampling instants and PWM signals (±2ns). As illustrated by the image below, these characteristics allow the effective distribution of control algorithms on multiple devices exchanging many signals at each control task execution, with only one control period of latency.
How to use the multi-master feature
Before proceeding, the B-Box/B-Board devices used as masters must be connected to the user’s PC using Ethernet cables.
No particular configuration is required to enable multi-master operation. The user simply has to create one control model per device (C/C++ project, Simulink, or PLECS file) and launch the code on devices that are interconnected using SFP cables. However, two points must be observed:
- A code must be running in every device before the PWM outputs can be enabled.
- (Beta) Launch code order:
- All codes must manually be stopped.
- All codes except for the root device(device #0) must be launched (in any order).
- The code of the root device (device #0) must be launched last.
By default, the user must open the target configuration window to manually start or stop the user code. However, as shown on the screenshots below, it possible to display the start/stop code button directly in the project panes. (required imperix SDK 2024.1 or later)
In a multi-master configuration, the following apply:
- All CLOCKs are natively synchronized and by extension the analog inputs sampling, control tasks execution and the PWM outputs are all synchronized.
- If a fault occurs anywhere on the network then the PWM outputs of all devices are immediately disabled.
- (Beta) The PWM outputs of each device have to be enabled independently.
Exchanging data between the models
The SFP blocks shown below allow exchanging data between models through the optical fiber links. The SFP blocks work in pairs, an SFP output mailbox must be placed in a model and an SFP input mailbox in another model. The two mailboxes are automatically linked together when they share the same name and number of signals.
By default, the SFP output mailbox sends data at every control period. However, the user may enable a trigger input to precisely control when to send data. On the SFP input mailbox side, a data valid output port indicates when new data have been received.
The image below shows an example where 3 control models are running on 3 B-Boxes and are exchanging data using SFP blocks. The control models are running at the same control frequency and have the same sampling phase. Consequently, the sampling occurs at the same time on all devices and the 3 control tasks start simultaneously. Thanks to the low communication latency (~200 ns per hop), the data transferred arrives before the next task execution, leading to only one control period delay. Please note that the two mailboxes can be situated in any device of the network, the devices do not need to be adjacent.
Multi-master using Simulink
The multi-master feature requires one Simulink model per master device. The user can include these models in a parent model using the Model block. In this way, the referenced model can be simulated together, allowing the simulation of multiple master devices controlling the same plant and/or collaborating by exchanging signals.
Grouping multiple control models
The multimaster_template.zip contains a ready-to-use parent model top.slx as well as its two referenced models model_a.slx and model_b.slx (see image below).
The user can add additional model references by:
- Making a copy of model_a.slx, model_b.slx or any other imperix control model
- Adding a Model block in the model top.slx
- Double-clicking on the freshly added Model block and specifying the referenced model name
Simulation and code generation
The workflow is very similar to any standard imperix control development project. However, a couple of points must be observed:
- To simulate top.slx, the model execution purpose of all referenced models must be set to “Simulation”.
- The build command (Ctrl+B) must be executed from within the referenced model. The model must be open in another window.
As shown in the image below, a helper block is provided in the template to assist the user in performing the aforementioned points. This block allows to:
- Configure the model execution purpose of all referenced models in one click.
- Launch build commands from a single window, without the need to open the referenced model. (reminder: stop all codes before executing a build all)
Inter-devices communication simulation
As illustrated in the image below, the SFP blocks behavior is properly modelized. The user simply has to enable the simulation ports in the SFP block masks and connect them together.
Multi-master using PLECS
Multi-master development using PLECS is quite straightforward. The user can simply start from the provided template and duplicate the Imperix controller subsystem.
The Imperix controller subsystems are listed on the Coder Options page. ([Ctrl+Alt+B] or click on Coder > Coder Options). The user has to select the subsystem for which he wishes to generate CPU code and click on Build.