Test harnesses and reference models

9 次查看(过去 30 天)
Oliver McEnteggart
Oliver McEnteggart2012-7-20
Hi,
I am making a test harness in simulink to test an actuator model and have ran into a problem. The actuator itself is a reference model so I can quickly switch out different actuator model. However, I have a signal going into the model which is a bus signal, the bus signal itself is comprised of buses within buses etc.
So I had to write some code in the base workspace so that the model would see the incoming signal as a bus, the problem is the bus structure is different when it goes into the model in that it is just a long list of signals rather than having the hierarchy of the bus signal in the test harness.
So when I run this code and start the simulation the model can find the signals it needs easily enough but I get an error message that says.
Cannot propagate bus signal from output port 1 of 'Actuator/Bus Creator' to input port 5 of 'Actuator/Actuator' because the destination block expects a bus signal with different structure than the signal that is connected to it
So does anyone have any ideas? I'm thinking I can edit the code to mimic the hierarchy.
Thanks in advance for any advice.

回答(1 个)

Adam Filion
Adam Filion 2012-7-20
First I would double check that you are using virtual vs non-virtual buses where appropriate.
There's a good blog post here that shows an easy way to do this for a constant testing signal:
And a file here that will create a bus test harness that you can modify for non-constant signals:
  1 个评论
Oliver McEnteggart
Oliver McEnteggart 2012-7-23
Thanks that's helpful but essentially what my problem boils down to is modifying the code that creates the bus in the model workspace to allow for nested buses.
For example at the moment my code looks like this..
names={'Ep_struct_Ex000_struct'... ,'AccLimit_m_s2_or_rad_s2'... ,'Autotune_struct'... ,'C_Ns_m_or_Nms_rad'... ,'C_Ns_m_or_Ns_rad'... ,'Cb_s_m_or_s_rad'... ,'Ch1No_DEF'... ,'Ch1Pos_struct'... ,'or_Vs_rad'... ,'Zd_ND'... ,'Zeta_ND'... ,'Zn_ND'... }; %Define names of signals in this bus element
clear elems; clear numElems;
numElems = length(names);
for i=1:numElems elems(i) = Simulink.BusElement; elems(i).Name = char(names(i)); elems(i).Dimensions = 1; elems(i).DataType = 'double'; elems(i).SampleTime = -1; elems(i).Complexity = 'real'; elems(i).SamplingMode = 'Sample based'; end
Ep_struct=Simulink.Bus; %Define bus Ep_struct.Elements=elems; %Define whats in this bus
However, some of those things which I named as elements of the bus I want to define as buses as well and then define their inner structure...

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by