Real-Time Motor Control with Simulink and SOLO
Introduction
A control model that runs perfectly in simulation can still miss its deadline the moment it talks to a real motor. Simulation time is flexible. Real time is not. A loop that overruns by even a few milliseconds will jitter, stutter, or trip a fault on real hardware.
This guide shows you how to go from a working Simulink model to real-time motor control of a physical motor with SOLO. You will set a realistic sample time, map your model signals to SOLO commands, run in external mode or deployed, and keep the loop deterministic under load. If you only need the first block to talk to the drive, start with the SOLO Simulink block hello world and come back here for the real-time part.

Simulink and SOLO: The Setup
SOLO ships a Simulink blockset that wraps its Motion library, so you drive the controller from native Simulink blocks instead of writing serial code by hand. Each block maps to one command: open the port, read a feedback value, write a reference. You wire those blocks into your model the same way you wire any other source or sink.
The setup is short. You install the blockset, add a serial setup block with the right COM port and baud rate, then add read and write blocks for the signals you care about. The hello-world tutorial covers the install and the first handshake in detail, so we will not repeat it here. What matters for real-time work is what happens after the handshake: how often the model runs, and whether each step finishes on time.

Takeaway: the blockset gives you the connection. The rest of this guide is about making it run in real time.
Choosing the Right Sample Time
Sample time is the first thing to get right, because it sets whether the model can keep up. In Simulink you set a fixed-step solver and a step size, for example 0.001 s for a 1 kHz loop. Every block in the model has to finish its work inside that step. Miss it once and you get an overrun.
Here is the trap that catches most people: there are two different rates, and they are not the same.
- The control rate is how fast the inner loops run. On SOLO, the current and FOC loops run inside the controller firmware at tens of kHz, independent of Simulink.
- The communication rate is how often Simulink can read or write a value over the link. This is much slower, usually in the hundreds of Hz to a few kHz, and it depends on the bus and baud rate.
So your Simulink step time is generally limited by the communication rate, not by the motor. A common mistake is to pick a 0.0001 s step because the motor could handle it, then watch the model stall because the serial link cannot move a packet that fast. As a rule, set your Simulink sample time to match what the link can sustain, then let SOLO run the fast loops on its own.
Takeaway: pick a sample time the communication path can hit every step, not the fastest number the motor allows.
Communication Path
Digital Mode over UART/CAN
To command SOLO from Simulink you put the controller in digital mode, where it takes its setpoints from the data bus instead of analog pins. The two common links are UART over a USB-to-serial adapter and CAN over a USB-to-CAN adapter. UART is the simplest to start with on a single drive. CAN scales better when you add nodes or need more noise immunity on a longer run.
The baud rate sets your ceiling. A faster baud rate means each packet clears sooner, which means a shorter sample time is achievable. Match the baud rate in the Simulink serial setup block to the value configured on the controller, or the link will not open.
Blockset Read/Write Blocks
Inside the model you map each Simulink signal to a SOLO command with a read or write block. A write block sends a reference down to the drive. A read block pulls a feedback value back up.
| Simulink block | Direction | Maps to | Typical use |
|---|---|---|---|
| SetSpeedReference | write | speed setpoint | send target RPM each step |
| SetTorqueReference | write | torque setpoint | send target torque each step |
| GetSpeedFeedback | read | measured speed | close an outer loop in Simulink |
| GetPositionFeedback | read | measured position | position tracking, logging |
| GetBusVoltage / GetTemperature | read | telemetry | monitoring, safety limits |
Keep the number of read and write blocks per step small. Every block adds one transaction on the link, and the transactions are serialized, so ten reads cost roughly ten times one read. If you are still building the basic speed or torque loop, the torque and speed control for PMSM and BLDC in Simulink walks through the reference blocks step by step.
Takeaway: each read or write is one transaction on the bus, so budget them against your sample time.
Real-Time and Hardware-in-the-Loop
External Mode vs Deployed
You can run a Simulink model against real hardware in two ways, and the choice changes your real-time guarantees.
- External mode keeps the model running on the PC while it streams to and from SOLO. You get live tuning and live plots, which is great for development. The downside is that the PC operating system is not real-time, so timing can jitter under load.
- Deployed means you generate code from the model and run it on a real-time target. Timing is tight and repeatable, which is what you want for a final loop. You give up the live, click-to-change convenience of external mode.
Most teams use external mode to tune, then deploy once the loop is stable. Start in external mode for the fast feedback, and move to deployed when jitter starts to matter.
HIL: SOLO as the Plant Interface
In a hardware-in-the-loop setup, part of your system is real and part is simulated, and they run together in real time. SOLO sits at the boundary. It is the plant interface: the real motor, sensors, and power stage that your Simulink model commands and reads back.
This is useful when you want to test a controller or supervisory logic against a real motor without committing the whole system to hardware yet. Your high-level logic stays in Simulink where it is easy to change, while SOLO handles the actual current, commutation, and FOC on the physical motor. You get real motor behavior, real back EMF, and real thermal effects, fed back into a model you can still edit.
Takeaway: external mode is for tuning, deployed is for the final loop, and SOLO is the real motor at the edge of your HIL test.
Keeping the Loop Deterministic
Determinism is the whole game in real-time control. The loop has to do the same work in the same time, every step. Three things break that, and each has a fix.
- Overruns. A step takes longer than the sample time, so the next step starts late. Usually the cause is too many transactions per step. Cut the number of read and write blocks, or slow the sample time until each step fits.
- Buffering and latency. Serial drivers buffer data, which adds delay between a command and its effect. Flush or size the buffer so old data does not pile up, and keep the per-step payload small.
- Jitter. The step time wobbles because the PC is busy. In external mode this is expected. If it hurts your result, move to a deployed real-time target where timing is enforced.
If the communication link simply cannot sustain your rate, do not fight it from the PC side. Push the fast work down into SOLO. Let the controller run the closed current and FOC loops at its own high rate, and have Simulink send a reference and read feedback at a slower, sustainable rate. That split is usually what keeps a real motor loop stable.
Takeaway: if the link cannot hold the rate, move the fast loop into the controller and let Simulink supervise.
Logging and Tuning Online
While the loop runs, you want to see what the motor is actually doing. In external mode you can wire a Scope block to any read signal and watch speed, torque, or position update live as the motor turns. Because you are tuning against real hardware, the trace shows real overshoot, real settling, and real noise, not a clean simulation.

Log the feedback channels you care about to the workspace, then compare runs as you change a gain or a reference. The same data is useful for monitoring: read bus voltage and temperature each step and you can stop the test if a limit is crossed. Tune in small steps, log every run, and keep the change that the trace says is better.
Takeaway: live scopes and logged feedback let you tune against the real motor, not a model of it.
How SOLO Supports Simulink Workflows
SOLO is built to support Simulink integration rather than fight it. The blockset wraps the Motion library so your model talks to the drive through native blocks, and the controller can run in digital mode over UART or CAN to take references from your loop. Because the fast current and FOC loops run inside SOLO, you can keep your Simulink sample time at a rate the link sustains and still get tight motor control underneath. The blocks, libraries, and protocol docs live on the SOLO resources page, which is the place to grab the blockset and the command reference before you wire your model.
Conclusion
Real-time motor control from Simulink with SOLO comes down to four moves. Set a fixed-step sample time the communication link can actually hold. Put SOLO in digital mode and map your signals with the read and write blocks, keeping the count low. Tune in external mode with live scopes, then deploy when jitter matters. And when the link cannot keep up, push the fast loop into SOLO and let Simulink supervise. Get those right and a model that ran only in simulation will drive a real motor on time, every step. The SOLO resources page has the blockset and docs to set it up.
FAQ
Can Simulink control a motor in real time through SOLO?
Yes. With the SOLO blockset and the controller in digital mode, Simulink can send references and read feedback in real time over UART or CAN. The fast current and FOC loops run inside SOLO, so the controller handles the time-critical work while Simulink runs the outer loop and logic.
What sample time should I use with the SOLO blockset?
Match it to what the communication link can sustain, not to the fastest rate the motor allows. For many UART setups a step in the 0.001 s to 0.01 s range is realistic. A faster baud rate or CAN lets you go lower. Test for overruns and back off the step time until every step finishes on time.
Do I run in external mode or deploy the model?
Use external mode while you tune, because it gives live plots and click-to-change gains. Deploy to a real-time target for the final loop, where timing is enforced and jitter is low. Most teams tune in external mode, then deploy once the loop is stable.
How do I avoid loop overruns with SOLO?
Cut the number of read and write blocks per step, since each one is a separate transaction on the bus. Keep the payload small, manage the serial buffer so old data does not pile up, and slow the sample time if needed. If the link still cannot hold the rate, move the fast loop into SOLO and have Simulink send references at a slower rate.
Related articles

Python on Raspberry Pi: Production Motor Control Tips with SOLO
Production tips for Python motor control on Raspberry Pi with SOLO: SoloPy setup, robust serial/CAN, threading, error recovery and reliable deployment.

EtherCAT Motor Control with the SOLO SOM
How EtherCAT motor control works with the SOLO SOM: CoE and CiA 402, distributed clocks, cyclic synchronous modes and wiring a deterministic servo network.

ROS2 and SOLO: A Design-Ready Motor Control Node
Build a design-ready ROS2 node for SOLO: package layout, topics and services, lifecycle, real-time tips and error handling for robot motor control.
