xPC Target    

Adding an Asynchronous Event

When developing a model in Simulink that runs in the xPC Target environment, an Interrupt Server Routine (ISR) is modeled by using a Function-Call Subsystem. Additionally, you need to add an IRQ Source block connected to the Function-Call Subsystem block. This subsystem is then executed when an interrupt occurs and the CPU is ready to accept it.

After you install an I/O board with interrupt support into your target PC, you can add xPC Target asynchronous blocks to your Simulink model.

  1. In the MATLAB command window, type

The xPC Target Library opens.

  1. Double-click the Asynchronous Event group block.

The Library: xpclib/Asynchronous Event window opens.

  1. Drag-and-drop the xPC Target IRQ block in your Simulink model and connect the output to this block to the input of a Function-Call Subsystem. For more information on Function-Call subsystems, see Using Simulink and the Real-Time Workshop User's Guide.

  1. In the setup shown above, the CPU executes the contents of the Function Call-Subsystem whenever IRQ 5 occurs.

  1. Double-click the IRQ Source block.
  1. The Block Parameters: IRQ Source dialog box opens.

  1. From the IRQ line number list, choose 1, 2, . . . , 15. To determine the available IRQ line numbers on the target PC, use the function getxpcpci.
  2. Select or deselect the Allow preemption of function call subsystem check box.
  3. From the I/O board generating the interrupt list, select Computer Boards CIO-CTR05, Softing CAN-AC2-104, or CAN-AC2-PCI. Currently, these are the only interrupt boards supported by xPC Target.
  4. In the PCI slot box, enter the PCI slot number or enter -1 to let xPC Target determine the number.
  5. Click OK.

For more information about the IRQ Source block, see Async IRQ Source Block.

If you need to transfer data from your ISR, add an Async Transition Block or Async Read/Write blocks to your Simulink model. See Async Rate Transition Block, Async Buffer Write and Read Blocks, and Asynchronous Interrupt Examples.

If you are using a CAN fieldbus with interrupts, see Asynchronous Interrupt Examples.


  Asynchronous Event Support Async IRQ Source Block