メインコンテンツ

ブロックの接続

モデル内のブロック間の関係を確立するには、それらのブロックを接続します。

ほとんどのブロックは信号線を使用して接続できます。信号線はブロックの端子に接続されます。シミュレーション中に、信号は出力端子から接続された入力端子に移動します。

  • 信号線を分岐させると、1 つのブロックの出力端子から複数のブロックの入力端子に信号を送信できます。

  • 一部のブロックでは、ブロックの入力端子の数を変更できます。たとえば、同じグラフに複数の信号をプロットするには、Scope ブロックの入力端子の数を増やします。

信号線のレイアウト変更の詳細については、モデルのレイアウトの構成を参照してください。信号線にラベルを付ける方法の詳細については、モデル要素の名前とラベルの構成を参照してください。

信号をバンドルすることでブロック線図を簡略化できます。信号のバンドルの詳細については、バーチャル バスへの信号またはメッセージのグループ化を参照してください。

"関連するブロック" は、信号線を使用せずに接続されます。関連するブロックを接続する方法の詳細については、信号線を使用しないブロックの接続を参照してください。

信号線を使用したブロックの接続

信号線を使用して 2 つのブロックを接続するには、一方のブロックの出力端子にある端子シンボル Port Symbol をクリックしてもう一方のブロックの入力端子にドラッグします。

A Sine Wave block is to the left of a Gain block. They are not connected. The output port of the Sine Wave block and the input port of the Gain block face each other and are labeled. The output port is on the right side of the block, and the input port is on the left side of the block.

次のショートカットを使用してブロックを接続できます。

  • 信号線をドラッグせずにブロックを接続する場合:

    1. 接続する出力端子と入力端子を垂直方向に整列して、それらの端子の間に他のコンポーネントを配置しないようにします。端子が既に整列している場合は、いずれかのブロックを移動して配置をずらしてから、再度整列します。端子を揃えるために移動したブロックを放すと、接続のプレビューが表示されます。

      A Sine Wave block is to the left of a Gain block. They are not connected. The Sine Wave block output port is horizontally aligned with the Gain block input port. A faint blue horizontal arrow points from the output port to the input port.

    2. 接続するには、プレビューをクリックします。

      The Sine Wave block output port connects to the Gain block input port with a solid black signal line.

  • 信号線をドラッグしたり端子を整列したりせずにブロックを接続する場合:

    1. 接続する出力端子の端子シンボルをクリックします。接続できる他のコンポーネントの入力端子に端子のヒント シンボル Port hint symbol が表示されます。

      A Gain block is below and to the right of a Sine Wave block. The port symbol of the Sine Wave block output port is highlighted in blue, and there is a port hint symbol in front of the Gain block input port.

    2. 接続のプレビューを表示するには、接続先にする入力端子の端子のヒント シンボルをポイントします。

      A light blue line connects the Sine Wave block output port to the Gain block input port.

    3. 接続するには、プレビューをクリックします。

      A solid black line connects the Sine Wave output port to the Gain block input port.

  • 信号線をドラッグしたり端子を整列したりせずに複数のブロックを単一のブロックに接続する場合:

    1. たとえば、左クリックしながら選択ボックスをドラッグしてブロックを囲んで、出力端子を接続するブロックを選択します。

    2. Ctrl キーを押しながら、入力端子を接続するブロックをクリックします。

    The video shows three In Bus Element blocks labeled myPort.A, myPort.C, and myPort.B simultaneously connecting to the same Subsystem block, which has input ports named A, B, and C. The block labeled myPort.A connects to port A, the block labeled myPort.C connects to port C, and the block labeled myPort.B connects to port B.

  • ブロックの入力端子と出力端子の両方を既存の信号線に接続するには、ブロックをクリックして信号線にドラッグします。端子シンボル Port Symbol が信号線上に置かれるようにブロックを配置します。出力端子シンボルが消えて、入力端子シンボルが塗りつぶされた矢印に変わったら、ポインターを放します。

    The top image shows a pointer holding a Gain block over a signal line, with the port symbols a little above the signal line. The bottom image shows the Gain block over the signal line such that the ports are right on top of the signal line. The right port symbol is not visible, and the left port symbol is changed to a solid arrowhead.

信号線のセグメントを斜めにするには、Shift キーを押しながら、接続する頂点を別の信号線のセグメントにドラッグします。

A Sine Wave block connects to a Scope block. The Sine Wave block is higher on the canvas than the Scope block. The signal line between the blocks consists of three line segments joined at two vertices. The pointer is dragging the lower vertex to the right. The line segment connecting to the Sine Wave block and the line segment connecting to the Scope block are horizontal. The line segment joining the two horizontal segments is diagonal.

単一の出力端子と複数の入力端子の接続

1 つの出力端子を複数の入力端子に接続するには、1 つの入力端子を出力端子に接続してから、信号線を分岐させて他の入力端子に接続します。

信号線を分岐させるには、Ctrl キーを押しながら既存の信号線をクリックして、接続するブロックの入力端子にドラッグします。

A Sine Wave Block connected to a Gain block by a signal line, and a dotted line branching out of the signal line and reaching part of the way towards an unconnected second Gain block

ヒント

線を分岐させるために、未接続の入力端子の端子シンボルをクリックして既存の信号線にドラッグすることもできます。

The top image shows a Sine Wave block connected to a Gain block by a signal line, and an unconnected second Gain block with a dotted line part of the way towards the signal line. Above the dotted line is the text "Drag to Existing Signal Line". The bottom image shows the Sine Wave block connected to both Gain blocks.

複数のブロックの出力端子と単一のブロックの接続

一部のブロックでは、その入力端子側に複数の信号線を接続できます。たとえば、1 つのグラフに複数の信号をプロットするには、複数のブロックの出力端子を単一の Scope ブロックに接続します。

複数のブロックの出力端子を単一のブロックに接続するには、接続する各出力端子から単一のブロックの入力端子側 (左端) に信号線をドラッグします。ブロック アイコンが青色に変わって端子番号が表示されたら、ポインターを放します。入力端子が自動的に作成され、信号線が接続されます。

Two Constant blocks are to the left of a Scope block. The Scope block only has one port, and one of the Constant blocks connects to it. A blue signal preview line runs from the other Constant block to the left side of the Scope block. The Scope block icon is blue, and the port number 2 is displayed next to the point where the preview line connects to the Scope block.

出力端子を接続するブロックがモデル内にまだない場合に、単一のブロックの入力端子の数を増やすには、以下を行います。

  1. ポインターの横にプラス記号が表示されるまでブロックの入力端子側 (左端) をポイントします。

    Pointer at left edge of Scope block, with boxed plus symbol near pointer

  2. 次に、ポインターをクリックしてドラッグし、ブロックから離します。別のブロックの出力端子に接続できる破線の信号線が表示されます。

    Scope block with two input ports, with the top input port connected to signal line, and bottom input port unconnected

入力端子を削除するには、その端子シンボルをクリックして Delete キーを押します。

ブロックの入力端子の数を指定するには、[ブロック パラメーター] ダイアログ ボックスまたはプロパティ インスペクターの [パラメーター] タブを使用します。

Scope block Property Inspector dialog box with the Parameters tab showing and the "Number of input ports" parameter text box highlighted

ヒント

一部のブロックでは、モデルにブロックを追加するときに入力端子の数を入力できます。

The left image shows a Scope block with a prompt below it asking for the "Number of input ports" and the answer "2". The right image shows the resulting Scope block with two input ports.

サブシステムの接続

サブシステムに信号を送信するには、サブシステムに送信する信号と同じ数の入力端子がそのサブシステムに含まれている必要があります。

サブシステムから信号を受信するには、サブシステムから受信する信号と同じ数の出力端子がそのサブシステムに含まれている必要があります。

モデルに空のサブシステムを追加した場合、そのサブシステムには既定で入力端子と出力端子が 1 つずつ含まれています。

サブシステムを接続するには、以下を行います。

  1. サブシステムを入力するには、Subsystem ブロックをダブルクリックします。

    Two unconnected Constant blocks on the left, an unconnected Subsystem block in the center, and two unconnected Scope blocks on the right

  2. サブシステム内に、必要な数の入力端子と出力端子を追加します。

    Inside the Subsystem block, there are two unconnected input ports on the left, two unconnected gain blocks in the center, and two unconnected output ports on the right. The two input ports display the numbers 1 and 2 on the block icons, and so do the two output ports.

  3. サブシステム内で、入力端子と出力端子をサブシステムに接続します。

    Inside of the Subsystem block, the input port with the number 1 on the block icon connects to a Gain block, which connects to the output port with the number 1 on the block icon. The input port with the number 2 on the block icon connects to the other Gain block, which connects to the output port with the number 2 on the block icon.

  4. モデルの階層構造内で 1 つ上のレベルに移動するには、Simulink® キャンバスの上部にあるエクスプローラー バーで、Subsystem ブロックの名前の左にあるレベルの名前をクリックします。

    Explorer Bar showing the hierarchy model->Subsystem, with the callout "Click" pointing to the model level

  5. サブシステムに送信する信号の信号線を Subsystem ブロックの入力端子に接続します。

    Subsystem ブロックの各入力端子はサブシステム内の Inport ブロックに対応しています。Subsystem ブロックのどの入力端子がサブシステム内のどの Inport ブロックに対応しているかは、端子番号で判断できます。

  6. サブシステムから受信する信号の信号線を Subsystem ブロックの出力端子に接続します。

    Subsystem ブロックの各出力端子はサブシステム内の Outport ブロックに対応しています。

    The two input ports of the Subsystem block connect to two Constant blocks, and the two output ports connect to two Scope blocks. The input ports and output ports of the Subsystem block have the same numbers on the block icon as the input ports and output ports inside the subsystem.

ヒント

サブシステムを手動で接続しないようにするには、Subsystem ブロックを追加するモデルの階層構造のレベルにサブシステムの内容を作成します。次に、この内容をサブシステムに変換します。

  1. キャンバスでポインターをクリックしてドラッグし、コンポーネントを囲む四角形を描画することで、サブシステム コンポーネントを選択します。

  2. 表示される省略記号をポイントします。

  3. 展開された操作バーで、[サブシステムの作成] をクリックします。

サブシステムへの変換により、サブシステムの入力端子と出力端子が自動的に追加され、接続されます。

信号線を使用しないブロックの接続

"関連するブロック" は、信号線を使用せずに相互に接続されます。

たとえば、Goto ブロックと From ブロックは、信号線を使用せずに信号を送信するために使用できる関連するブロックです。Goto ブロックに入る信号は、信号線を通過せずに From ブロックから出ます。

A Constant block connects to a Goto block with a signal line, and a From block connects to a Display block with a signal line. The Constant block has a value of 5.25, and the Display block shows a value of 5.25. The Goto block is selected, and the From block is highlighted in purple.

関連するブロックを接続するには、[ブロック パラメーター] ダイアログ ボックスまたはプロパティ インスペクターの [パラメーター] タブを使用します。

ヒント

2 つ以上の関連するブロックが接続されているかどうかを確認するには、いずれか 1 つを選択します。選択したブロックに接続されているすべての関連するブロックが紫色で強調表示されます。

関連するブロックの中には、タグを使用して接続されるものもあります。たとえば、同じタグをもつすべての Goto ブロックと From ブロックが接続されます。

Two rows of blocks are one above another. The top row contains a Constant block connected to a Goto block with a signal line, and a From block connected to a Display block with a signal line. The bottom row contains the same blocks. The value of the Constant block in the top row is 5.25. The tag on the Goto block icon in the top row is A, and the tag on the From block icon in the bottom row is A. The display block in the bottom row shows a value of 5.25. The value of the Constant block in the bottom row is-1. The tag on the Goto block icon in the bottom row is B, and the tag on the From block icon in the top row is B. The display block in the top row shows a value of -1.

これらのブロックのタグは、[ブロック パラメーター] ダイアログ ボックスまたはプロパティ インスペクターの [パラメーター] タブで設定できます。

In the Goto block Block Parameters dialog box, the "Goto tag" parameter text box is highlighted and displays the value A.

Dashboard ライブラリと Customizable Blocks ライブラリのブロックも関連するブロックです。これらのライブラリの Display ブロックを信号に接続できます。制御ブロックをブロック パラメーターまたは変数に接続できます。Dashboard ブロックを接続する方法の詳細については、Connect Dashboard Blocks to Simulink Modelを参照してください。

信号線から Goto ブロックと From ブロックへの変換、およびその逆の変換

長い信号線を Goto ブロックと From ブロックに置き換えることで、モデルのブロック線図を簡略化できます。ただし、信号パスをトレースするときは、信号線を表示すると便利な場合があります。

信号線やバーチャル バスを Goto ブロックと From ブロックのセットに変換したり、Goto ブロックと From ブロックのセットを信号線に変換したりできます。Goto ブロックと From ブロックのセットは、接続されている Goto ブロックと From ブロックのグループです。つまり、これらのブロックは同じタグをもっています。

変換するモデル要素は次の条件を満たす必要があります。

  • 信号線、バス、またはブロックが完全に接続されている。

  • 信号線、バス、またはブロックがすべてモデルの階層構造内の同じ場所にある。つまり、すべてが階層構造の最上位レベルにあるか、すべてが同じコンポーネントにある。

  • 信号線またはバスが Goto ブロックまたは From ブロックに接続されていない。

変換プロセス中に、これらの条件を満たしていないモデル要素は無視されます。変換は、ブロック タグが表示されているかどうかに関係なく実行できます。

Goto ブロックとその接続先のすべての From ブロックを信号線に変換するには、Goto ブロックを選択します。From ブロックとその接続先の Goto ブロックを信号線に変換するには、From ブロックを選択します。選択したブロックの上に表示される省略記号をポイントします。展開されたアクション メニューで、[信号に変換する] を選択します。あるいは、Goto ブロックまたは From ブロックを選択し、Simulink ツールストリップの [Goto] タブまたは [From] タブで、[信号に変換] をクリックします。

A Sine Wave block is connected to a Goto block, and a From block is connected to a Scope block. The pointer selects the Goto block, and uses the action menu to convert the Goto and From blocks to a signal line that connects the Sine Wave block to the Scope block.

信号線またはバスを Goto ブロックと From ブロックのセットに変換するには、信号線またはバスを選択します。表示される省略記号をポイントします。展開されたアクション メニューで、[Goto ブロックと From ブロックに変換] を選択します。あるいは、信号線またはバスを選択し、ツールストリップの [信号] タブで、[Goto/From に変換] をクリックします。

複数の Goto ブロックとそれらに接続されたすべての From ブロックを信号線に同時に変換するには、Shift キーを押しながらブロックをクリックするか、ブロックを囲む選択ボックスをドラッグして、すべての Goto ブロックを選択します。Simulink ツールストリップの [Goto] タブで、[信号に変換] をクリックします。

Goto ブロックに同じタグをもつ複数の From ブロックがある場合に、From ブロックのサブセットを信号線に変換するには、変換する From ブロックを選択します。ツールストリップの [From] タブで、[信号に変換] をクリックします。選択した From ブロックが、対応する Goto ブロックから出る信号線に接続された信号線に変換されます。Goto ブロックは信号線に変換されません。

複数の信号線またはバスを Goto ブロックと From ブロックのセットに同時に変換するには、Shift キーを押しながらクリックするか、選択ボックスをドラッグして、信号線またはバスを選択します。ツールストリップの [信号] タブで、[Goto/From に変換] をクリックします。

The pointer selects a signal line and uses the action menu to convert the signal line into a Goto and From block pair. The pointer then selects two signal lines and uses the toolstrip to convert the signal lines to a Goto and From block set.

ブロックのコメント アウトとコメント スルー

ブロックをモデルから物理的に削除せずにシミュレーションから除外するには、そのブロックをコメント アウトまたはコメント スルーします。

  • コメント アウト: 選択したブロックをシミュレーションから除外します。信号は打ち切られて接地されます。

  • コメント スルー: 選択したブロックをシミュレーションから除外します。信号は通過します。コメント スルーするには、ブロックに同じ数の入力端子と出力端子が含まれていなければならず、また、制御端子と接続端子が含まれていてはなりません。

メモ

次の Simulink ブロックでは [コメント アウト] コマンドと [コメント スルー] コマンドはサポートされません。

  • Inport

  • Outport

  • Connection Port

  • Argument Inport

  • Argument Outport

  • Data Store Memory

  • Goto Tag Visibility

Signal Generator ブロックでは [コメント スルー] コマンドはサポートされません。

ブロックをコメント アウトするには、ブロックを選択します。表示された操作バーで、[コメント アウト] をクリックします。

Selected Constant block with the action bar above it, and the Comment Out button selected with the tooltip "Comment Out" displayed above it

ブロックをコメント スルーするには、ブロックを右クリックし、[コメント スルー] を選択します。

ヒント

あるいは、ブロックを選択して以下を押します。

  • コメント アウトするには Ctrl+Shift+X

  • コメント スルーするには Ctrl+Shift+Y

参考

トピック