How to change the number of input/output-terminals based on mask parameter

12 ビュー (過去 30 日間)
Teppei Tsujita
Teppei Tsujita 2015 年 8 月 28 日
コメント済み: Teppei Tsujita 2015 年 9 月 18 日
I’m now writing a custom driver for Simulink Real-time and have a question about how to change the number of input/output-terminals. I want to change the number of the terminals by setting the mask parameter “channel” like pre-installed drivers, e.g. MM-32 Diamond Analog Input or PCI-6621 National Instr. Analog Input.
I started to write the driver using “xpcdrivertool” and added initialization function (below) using these pre-installed drivers as examples.
function [maskdisplay] = init(channel)
maskdisplay = sprintf( 'disp(''Interface Baord'');' );
for i=1:length(channel)
maskdisplay = sprintf('%s port_label(''output'', %d, ''%d'');', maskdisplay, i, channel(i) );
end
In the mask editor of the driver block, I added ‘channel’ parameter and wrote an initialization command as follows.
[maskDisplay] = init(channel);
set_param(gcb, 'MaskDisplay', maskDisplay);
Also, I’m changing the number of terminals in the initialization function in C code as follows.
if (!ssSetNumOutputPorts(S, number_of_channels)) return;
for (i = 0; i < number_of_channels; i++) {
ssSetOutputPortWidth(S, i, 1);
}
However, the number of terminals does not change in the block diagram. Can someone please help me out?

採用された回答

Shruti Sapre
Shruti Sapre 2015 年 9 月 2 日
Hi Teppei,
The following link could help you in resolving this issue:
The “xpcdrivertool” seems to be from MATLAB Central, so it might also help to contact the author directly.
Hope this helps!
-Shruti
  1 件のコメント
Teppei Tsujita
Teppei Tsujita 2015 年 9 月 18 日
Hi Shruti,
I appreciate your help. The link helped me in finding my mistake. I did not pass the parameter “channel” to S-Function by specifying “S-Function parameters:” in Function Block Parameters Dialogue. I would like to attach my simplified code for those who have the same question.
Teppei

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by