Softing CAN-AC2-PCI with Philips SJA1000 FIFO Write Driver block
Simulink® Real-Time™ Library for CAN
The FIFO Write driver block writes CAN messages into the transmit FIFO. The firmware running in FIFO mode processes the information in the transmit FIFO and finally puts the constructed CAN messages onto the bus. This block dynamically detects the data type and signal size of the signal you connect to the input port. If you use this block inside an enabled subsystem, the block sends the message only when you enable the subsystem.
If you use the CAN_MESSAGE data type:
If the block input is a CAN_MESSAGE data type, use CAN Pack blocks to pack individual signals into a CAN message. If you use CAN Pack blocks to prepare each message, the FIFO Write block reads the CAN_MESSAGE data. To combine several messages into a vector of CAN_MESSAGE data that the FIFO Write block sends, use a Mux block. Use the Port (if input is CAN_MESSAGE) parameter to select the port to which to send the CAN_MESSAGE data.
Tip: To prepare a remote frame, use the CAN Pack block with the Remote frame check box selected. To request the current value, send the remote frame to the responding subsystem.
If you use the double data type (legacy):
If the block input consists of double values in a matrix, the block has one input port of type double. At this port, the required information must be provided to construct valid CAN messages to be written into the transmit FIFO. For each CAN message, five elements are passed in this order:
The value can be either 1 (port 1) or 2 (port 2) and defines the port the CAN message is sent from.
Identifier of the CAN message to be sent. If it is a standard CAN message the valid range is 0 to 2047. If the CAN message is extended, the range is 0 to 229-1.
The value can be either 0 (standard identifier range) or 1 (extended identifier range) and defines the identifier type of the outgoing CAN message.
Data frame size
The value can be in the range of 0 to 8 and defines the data frame size in bytes of the outgoing CAN message.
Data for the data frame itself. Use the CAN Bit-Packing block to construct the data as double values in a matrix.
This information can be dynamically changed in FIFO mode during real-time application execution. Therefore, you send the information through the block input instead of setting block parameters. To transmit more than one CAN message per block instance, use a matrix signal as a container.
The dimension of the matrix signal entering the block is
n is the number of CAN messages that you
expect this block instance to send. Each row of the matrix signal
defines one CAN message and each row combines the five information
[Port, Identifier, Identifier type, Data frame size, Data]
For examples of constructing the matrix signal for the FIFO Write block, see CAN FIFO Loopback Tests.
For some models, you can make the writing
of a CAN message into the transmit FIFO dependent on the model dynamics.
For this case, the matrix signal can also be of dimension
n*5. The sixth column defines whether the corresponding
CAN message is written into the transmit FIFO (
or not (
Define the board used to send the CAN messages defined by this block instance. For more information about the meaning of the board number, see the Setup driver block. If just one board is present in the target system, you should select 1.
Select this check box to track the number of inputs to the block
and add a second input port, N, to the block. If this port value exceeds
the size of the input vector of CAN_MESSAGE messages, the block limits
the transfer to the size of the input vector. If this port value is
smaller than the CAN_MESSAGE input vector size, the block transfers
data up to the size of this port value. For example, assume an input
of 10*5 matrix. If you then input a
5 to input
port N, the block sends only the first five messages.
In an n*6 matrix, the last entry in the row is still the individual
message enabled, but the block checks only messages up to n. If the
input is a matrix of doubles, the block ignores the value of the Port parameter.
The block considers the port as part of the data.
If this check box is cleared, the block sends all elements of the input vector.
If the message is a CAN_MESSAGE data type, from the list, select
the port to send the message through. The block sends a message to
a single CAN port. If you want to send messages to different ports
in a model, use multiple FIFO Write blocks. This input
port is the first one on the block. Its input is a vector or single
If the message consists of double values in a matrix, changing this parameter does not change the block behavior. You specify the port number in the CAN message. A single FIFO Write block can send messages through both ports.
Select this to enable the status output port. If the box is
cleared, the block does not have an output port. If enabled, a port
is shown. The signal leaving the block is a vector of type CAN_MESSAGE
or double depending on which data type you are using for your messages,
in which the number of elements depends on the signal dimension of
the block input port. There is one element for each CAN message written
into the transmit FIFO and the value is identical to the return argument
CANPC_send_data, described in the Softing® user
manual. Refer to that manual for more information. The function return
Function executed without detecting an error.
Function encountered an error.
Timeout firmware communication.
Board not initialized.
Defines the sample time at which the FIFO Write block is executed during a real-time application run.
You can use as many instances of the FIFO Write block in the model as required. For example, by using two instances of the block, you can send CAN messages at different sample times. Or you can use multiple instances to structure your model more efficiently.