xPC Target    

Example 1

Lets start with a simple model using the FIFO Setup block, FIFO Write block, FIFO Read block, and FIFO Read Filter block. The entire CAN network consists of a single physical connection between CAN port 1 and port 2 (loop-back configuration). For this, both CAN ports have to be terminated properly.

The objective of the application is the following:

The data transmitted with the CAN messages are double values in all the following examples. This has been chosen for simplicity. You should refer to the bit-packing and bit-unpacking chapter of the standard CAN driver documentation, on how to construct from respectively extract into bit fields.

The first implementation uses the following scheme.

The matrix signal entering the FIFO Write block consists of all three messages including the Control element (sixth element), therefore the matrix size will be [3,6]. The sample time of the FIFO Write block is defined as 1 ms. For the standard identifiers which have to be sent out every other millisecond, the Control element is alternated accordingly. This is achieved by using a Unit delay block with corresponding feedback as the Control element value.

The FIFO Read block has a Read depth of 3 and also a base sample of 1 ms. Three FIFO filter blocks are connected to the output of the FIFO read block (in parallel) to extract the information of the incoming CAN messages. You can display the model by typing, in the MATLAB command window, either xpccanpcififo1.mdl or xpccan104fifo1.mdl.

The model uses several xPC Target scope blocks to display different type of data on the target screen:


  Examples Example 2