Documentation search search close
CONTENTS
https://www.speedgoat.com/help/slrt/page/icon_documentation.jpg
v10.0.1.x for R2026a
View other versions

IO901/IO902 Usage Notes

IO901/IO902 Usage Notes — Usage information about the I/O module

Initialize Shared Memory Nodes

To use the IO901/IO902 shared memory I/O module, you must define a node initialization structure. The I/O modules drivers use MATLAB structures to define shared memory node initializations. A node initialization structure describes the shared memory partition and the IO901/IO902 board configuration, including interrupt configurations.

The initialization can done with an m-file, which is then loaded with your Simulink model (see example io901_io902_init.m). The following usage notes describe the initialization procedure.

Memory Partitions

For each variable, a partition must be defined. The example below shows how to define the variables:

Partitions(1).Size = '1';
Partitions(1).Type = 'uint8';

Partitions(2).Size = '2';
Partitions(2).Type = 'double';

Partitions(3).Size = '1';
Partitions(3).Type = 'double';

Partitions(4).Size = '1';
Partitions(4).Type = 'uint8';

Partitions(5).Size = '2';
Partitions(5).Type = 'double';

Partitions(6).Size = '1';
Partitions(6).Type = 'double';
Partitions(6).Address = '0x5000';

Partitions = completepartitionstruct(Partitions,'5565');

For further information, function sscgtpartitionstruct can be used.

Partition = scgtpartitionstruct(Partition);

Nodes

Each shared memory I/O module installed needs to have a "node ID":

Target Machine 1 – Node ID = 1

Node1.Interface.NodeID = '1';
InitiatorNode.Partitions = Partitions;
InitiatorNode = completenodestruct(InitiatorNode,'5565');

Target Machine 2 – Node ID = 2

TargetNode.Interface.NodeID = '2';
TargetNode.Interface.Interrupts.PendingInt1='on';
TargetNode.Partitions = Partitions;
TargetNode = completenodestruct(TargetNode,'5565');

Create a node initialization structure for each I/O module with the help of the scgtnodestruct command. Type

  • help scgtnodestruct

for a description of the command.

  • node=scgtnodestruct([])
    
    node =
    
         Interface: [1x1 struct]
        Partitions: [1x1 struct]
    

    where

    Node Structure FieldsDescription
    InterfaceSpecifies settings for the IO901/IO902. The Interface structure has the following fields. Refer to the IO901/IO902 product documentation for a description of the operation modes.
    • NodeID

      -- Configures board node ID (0 - 255, or -1 for no change)

    • ActiveInterface

      -- Configures which board interface to use (0, 1, or -1 for no change)

    • Mode

      -- Configures board modes (see Board Mode chapter below)

    • Lasers

      -- Enables/disables the transceiver lasers (see Board Lasers)

    • Interrupts

      -- Enables the board to generate and receive interrupts from the network (see Board Interrupts)

    • Internal

      -- Reserved for internal use

    PartitionsStores the shared memory segments
  • Using the scgtnodestruct command at the MATLAB Command Window, create a default node initialization structure. For example, type

Create Shared Memory Partitions

To use the IO901/IO902 blocks to Read, or Write data, you must define a partition structure. The shared memory drivers use MATLAB structures to define shared memory partitions. A partition structure describes how you want to allocate (or partition) the shared memory. Speedgoat Target allocates shared memory with bundles of data that are packed into memory partitions. Create a shared memory structure with the scgtpartitionstruct command. Type

  • help scgtpartitionstruct

for a description of the command.

  • speedgoat_partitionstruct([])
    
    ans =
    
          Address: '0x0'
             Type: 'uint32'
             Size: '1'
        Alignment: '4'
         Internal: [1x1 struct]
    
  • Partition(1).Address='0x5000';
    Partition(1).Size='10';
    Partition(2).Size='5';
    Partition(3).Size='3';
    Partition(4).Size='[2, 3]';
    
  • Using the scgtpartitionstruct command at the MATLAB Command Window, create a default partition structure. For example, type

  • At the MATLAB Command Window, create a user-defined partition structure. The easiest way to do this is to create an M-file, partially define a structure, load that M-file into the MATLAB workspace, and supplement the resulting structure with a call to the scgtpartitionstruct function.

    For example

  • This example defines a partition with four segments.

    • The Address field is optional. Only specify this field for the first segment of a partition. The elements of a partition are defined as a continuous memory block from the first address. The following segments extrapolate their addresses from the first segment. If you have fragmented memory, use multiple partitions and SCRAMNet GT Read and Write blocks to work with the memory.

    • The Size field is required for all fields in the partition structure.

    • The base addresses of subsequent segments are fully defined by the size of the preceding segment.

    • You can then call the scgtpartitionstruct() command to full populate the partition structure.

      You do not need to use all the fields of a partition initialization structure. However, knowledge of the possible structure fields will be helpful when you are setting up the partition structure to use shared memory.

      A shared memory partition structure has the following fields:

      FieldDescription
      AddressSpecifies the base address (in hexadecimal, for example, '0x08') of the memory partition within the shared memory space of the node. The default value is '0x00', the first location in the shared memory.
      Type

      Specifies the data type of the memory segment. Specify one of the following types:

      • 'single'

      • 'double'

      • 'uint8'

      • 'int8'

      • 'uint16'

      • 'int16'

      • 'uint32'

      • 'int32'

      • 'boolean' (a single byte represents a boolean value)

      Size

      Specifies the dimension and size of the memory segment. You can enter a scalar value or a value with the [m,n] format. The default value is '1'.

      • scalar — Treats the Size entry as the specification of the length of a non-oriented array or vector

      • [m,n] — Treats the Size entry as an array dimension. The total number of elements in this segment is m*n

      AlignmentIf another partition precedes this partition, this field defines the byte alignment of this segment. Specify one of the following alignment values: 1, 2, 3, 4, or 8. The default value is '4'.

      The variables defined in the memory partition are used for read and write from all shared memory nodes.

Network Wiring

Each IO901/IO902 port has two fiber optic connections, RX (receive) and TX (transmit). When connecting two systems, a crossed connection is required. For networks with several nodes, a ring connection is required.

Using shared memory to synchronize target machines

This section provides information on how to synchronize multiple real-time target machines using Shared/Reflective Memory on IO901/IO902 I/O modules and interrupts. The first target machine works as an initiator, and sets the timing for the other machine(s), using a Network interrupt. This ensures that all the target machines are completely synchronized, and can access the same variables and values at the same time.

To use the interrupt mode for synchronization of the target machines, the board interrupts need to be activated. When initiating the nodes, add the lines in your initialization procedure:

Unicast interrupt:

Target – Node ID = 2

TargetNode.Interface.Interrupts.UnicastInterrupts = 'on';

Broadcast interrupt:

Initiator – Node ID = 1

InitiatorNode.Interface.Interrupts.ChangeBroadcastInterruptMask = 'yes';
InitiatorNode.Interface.Interrupts.BroadcastInterruptMask = '0xffffffff';

Target – Node ID = 2

TargetNode.Interface.Interrupts.ChangeBroadcastInterruptMask = 'yes';
TargetNode.Interface.Interrupts.BroadcastInterruptMask = '0xffffffff';

After configuring the inizalization structure, the Simulink real-time models can be run on each target. For the initiatior node, make sure to use a Send Interrupt block. For more information, refer to block documentation.

The Simulink real-time model of the target node requires a Speedgoat Interrupt Block that triggers the application or a subystem. Refer to the block documentation for more information.

Board Interrupts

The IO901/IO902 board allows you to specify the interrupt sources transmitted and received between the nodes of the network. You can set these bits through the Interface.Interrupts field. The Interface Interrupts fields set the corresponding values on the board. A value of 'nc' does not change the current value on I/O module. To display the board mode fields, type

  • >> node.Interface.Interrupts
    
    ans =
    
        ChangeBroadcastInterruptMask: 'no'
              BroadcastInterruptMask: '0x00000000'
                      SelfInterrupts: 'nc'
                   UnicastInterrupts: 'nc'
                 LinkErrorInterrupts: 'nc'
    

These fields have the following values:

FieldValuesDefault
ChangeBroadcastInterruptMask'yes', 'no''no'
ChangeBroadcastInterruptMask'0x00000000' - '0xffffffff''0x00000000'
SelfInterrupts'nc', 'on', 'off''nc'
UnicastInterrupts'nc', 'on', 'off''nc'
LinkErrorInterrupts'nc', 'on', 'off''nc'

Additional board settings

Board Mode

The IO901/IO902 board has a number of modes that you can set through the Interface.Mode field. The Interface Mode fields set the corresponding enables on theboard. A value of 'nc' does not change the current value on the board. To display the board mode fields, type

  • >> node.Interface.Mode
    
    ans =
    
                 ReceivePath: 'nc'
                TransmitPath: 'nc'
              RetransmitPath: 'nc'
               WriteLastPath: 'nc'
          ElectronicWrapPath: 'nc'
            ByteSwapGTMemory: 'nc'
            WordSwapGTMemory: 'nc'
        PCI64bitDataTransfer: 'nc'
    

These modes have the following values:

FieldValuesDefault
ReceivePath'nc', 'on', 'off''nc'
TransmitPath'nc', 'on', 'off''nc'
RetransmitPath'nc', 'on', 'off''nc'
WriteLastPath'nc', 'on', 'off''nc'
ElectronicWrapPath'nc', 'on', 'off''nc'
ByteSwapGTMemory'nc', 'on', 'off''nc'
WordSwapGTMemory'nc', 'on', 'off''nc'
PCI64bitDataTransfer'nc', 'on', 'off''nc'

Board Lasers

The IO901/IO902 board allows you to turn on or off the transmit lasers through the Interface.Lasers field. The Interface Lasers fields set the corresponding enables on the board. A value of 'nc' does not change the current value on I/O module. To display the board mode fields, type

  • >> node.Interface.Lasers
    
    ans =
    
        ActiveInterfaceLaser: 'nc'
             Interface0Laser: 'nc'
             Interface1Laser: 'nc'
    

These fields have the following values:

FieldValuesDefault
ActiveInterfaceLaser'nc', 'on', 'off''nc'
Interface0Laser'nc', 'on', 'off''nc'
Interface1Laser'nc', 'on', 'off''nc'