hello everyone, I’m trying to connect my model to RT-LAB but when I try to verify my model on Simulink once adding the RTLAB blocks, I’m having some error with the OpComm block.
My error messages:
**Error in port widths or dimensions. ‘my_model/Subsystem/OpComm’ Input Port 1
is a one dimensional vector with 4 elements, but the block expects a
one dimensional vector with 1 element.
Component: Simulink | Category: Model error
Error in ‘my_model/Subsystem/OpComm’: Invalid setting for input port
dimensions. The number of inputs specified in the block parameters (4)
does not match the number of ports on the block (1).**
What I’ve tried so far:
I put my controller blocks in a subsystem and added an OpComm block inside it to bring in 4 signals from my plant. In the OpComm block parameters I set the number of inputs to 4 and clicked OK. The block still only shows 1 input and 1 output.
I connected my 4 signals through a Mux anyway and tried to check the model with Update Diagram (Ctrl+D), and still got the same error message as above.
My controller subsystem is still called “Subsystem” because I haven’t renamed it yet, and my plant subsystem is called plant model . Is there a setting I’m missing, or is something wrong with how I’ve set up the OpComm?
I think your error is coming from your subsystem names rather than the OpComm block. RT-LAB only applies OpComm changes when the block sits inside a subsystem with a proper RT-LAB prefix. Your controller subsystem is still called “Subsystem”, so when you set the number of inputs to 4, RT-LAB ignores it and the block stays at 1 input and 1 output. That’s also why Simulink complains: your Mux sends 4 signals into a block that still only has 1 port.
Here’s an example of the same issue. The number of inports is set to 2, but the block still has only one port, so the second signal can’t connect:
To fix it, rename your subsystems with one of these prefixes:
SM_ for the master (computation) subsystem, e.g. SM_plant_model
SS_ for slave (computation) subsystems, e.g. SS_controller
SC_ for the console (GUI) subsystem, e.g. SC_console
A few tips while you’re renaming:
The prefix isn’t case sensitive, so sm_ works too.
Don’t leave spaces or symbols at the end of the name. Your plant model has a space at the end, and that can cause errors when you build. Using underscores, like SM_plant_model, is the safest option.
After renaming, open the OpComm block again, set the number of inports to 4 and click Apply. You should see the ports update right away, and then you can connect your 4 signals directly (no Mux needed) and run Ctrl+D again.