Products & Services Solutions Academia Support User Community Company

Learn more about xPC Target   

Asynchronous Event Support

Adding an Asynchronous Event

The xPC Target software includes support for asynchronous events. These events are triggered by a hardware interrupt asynchronously to normal execution. Some I/O boards raise interrupts that the CPU can use to interrupt the normal execution of code and jump to another sections of code called an Interrupt Service routine (ISR).

When developing a model in the Simulink interface 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

    xpclib

    The xPC Target Library opens.

  2. Double-click the Asynchronous Event group block.

    The Library: xpclib/Asynchronous Event window opens.

  3. 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 the Simulink and Real-Time Workshop documentation.

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

  4. Double-click the IRQ Source block.

    The Block Parameters: IRQ Source dialog box opens.

  5. From the IRQ line number dropdown list, choose Auto (PCI only) to enable the xPC Target software to automatically determine the IRQ that the BIOS assigned to the board and use it.

    Alternatively, you can choose 3, 4, . . . , 15 for this number. To determine the available IRQ line numbers on the target PC, use the function getxpcpci.

  6. Select or deselect the Allow preemption of function call subsystem check box.

  7. From the I/O board generating the interrupt dropdown list, select an interrupt board.

  8. In the PCI slot (-1: autosearch) or ISA base address field, enter the PCI slot number or enter -1 to let the xPC Target software determine the number.

  9. Click OK.

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

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, Async Buffer Write and Read, and Asynchronous Interrupt Examples.

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

Asynchronous Interrupt Examples

The xPC Target software provides several example models. If you installed the Async IRQ SourceMATLAB software in the default location, these models are located in

C:\MATLAB\toolbox\rtw\targets\xpc\xpcdemos

To access any of these models, in the MATLAB Command Window, type the name of the model. Each model contain annotations documenting its purpose, and should serve as an example of how to use these blocks.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS