xPC Target    

xPC Target CAN Library

The drivers support CAN specification 2.0A and 2.0B and use the dynamic object mode of the CAN-AC2 firmware to achieve maximum real-time performance.

The library supports the following CAN-boards from Softing GmbH, Germany.

Board Name
Form
factor

Identifier Range
Multiple Board Support
CAN-AC2
ISA
Standard (& Extended with piggyback module)
No
CAN-AC2-PCI
PCI
Standard & Extended
Yes (up to 3)
CAN-AC2-104
PC/104
Standard & Extended
Yes (up to 3)

For more information on the board specifications visit http://www.softing.com.

The xPC Target CAN library intentionally restricts its support for Softing boards with two CAN ports (boards with one channel would be available as well). This is because the two port versions allow checking the correct functioning of the board and drivers by just connecting the first CAN port to the second CAN port. This forms a loop-back without having the need to connect the board to a `real' CAN-network. The xpcdemos directory xpcdemos contains simple loop-back test models to test the ISA, PCI and PC/104 boards. Type the following commands to open the corresponding test models.

Model name (command)
For board
xpccanisa
CAN-AC2
xpccanpci
CAN-AC2-PCI
xpccanpc104
CAN-AC2-104

The size of the driver code of the CAN boards supported by the xPC Target block library is significant and because not all xPC Target applications will use CAN, the CAN library code is not linked by default when building a target application. This makes target applications smaller if no CAN-communication functionality is needed. If the model to be built contains CAN driver blocks, the corresponding CAN-library support has to be enabled prior to the initiation of the build process. This has to be done in the xPC Target setup environment either using the xpcsetup-GUI or the corresponding command-line functions. See chapter 2 below for further information.

For each CAN-board three driver blocks are provided. These are: A Setup block, which defines the type of physical connection (baud rate and so forth). Exactly one instance of the setup block has to be defined in a model for each physically installed CAN-board. A Send block, which transmits (sends) the data entering the block's input ports to the connected CAN-network. One or more instances of the Send-block can be used in a model. A Receive block, which retrieves (reads) CAN-messages received by the board and outputs the data at the corresponding output ports. One or more instances of the Receive block can be used in a model.

The maximum size of the data frame of a CAN-message is 8 bytes. This is the same size as the C data type `double' uses on PC-compatible systems. At the same time, the double data type is the default data type used for Simulink signals. Therefore the CAN data frame within a Simulink model can be easily represented by a scalar Simulink signal even if the data frame normally has nothing in common with a double floating point value. The xPC Target CAN library provides a Utility sublibrary which offers bit-packing and bit-unpacking blocks. These blocks are used to pack data types other than doubles into 64 bits (8 bytes or a double) as well as for the opposite operation. This will be discussed in greater details further below. What is important for now, is, that CAN data frames are represented by Simulink signals of data type double.

All drivers for the supported CAN-boards program the boards for the so-called "dynamic object mode". This is one of three modes the CAN-board firmware from Softing can operate in. For a more detailed discussion of the three modes see the board's user manual. The dynamic object mode is best suited for real-time environments where each component of the application has to have deterministic time behavior. This is the case for xPC Target and that is the main reason why this mode has been chosen over the other two modes, which are FIFO and static object mode.

The following paragraph summarizes the differences between the three supported Softing boards.


  Introduction CAN-AC2