CAN Blocks
D
MotoHawk:Blocks:CAN Definition Block
Use this MotoHawk® block to select which CAN bus to initialize and define. CAN_1 is available on most ECUs, but CAN_2 and even CAN_3 are also available on some. See specific ECU datasheet for CAN information. Use this block's Bit Timing to select a preset baud rate, or have user-defined attributes set up the CAN baud rate. If a user-defined baud rate is selected, these fields are definable:
- Prescaler
- Propagation Segment
- Phase Segment 1/2
- Resynchronization Jump Width
Each CAN RX block includes an ID, which is used in combination with the mask. Only the bits set to 1 in the mask for the corresponding buffer are compared when detecting a received message. If a Queue Size of zero is input, then no queue will be attached. Check Install MotoTune Protocol to use MotoTune over the given CAN interface.
F
MotoHawk:Blocks:CAN Fault Status Block
This MotoHawk® block reports the current fault status of the selected CAN resource. "Bus Passive" is true when the bus is disconnected, shorted, improperly terminated, the baud rate is incorrect, or if bit error rates are high enough to cause hardware failures. "TX Error Counts" is 0 when the bus is operating properly and greater than 0 when the module is unable to transmit CAN messages. "RX Error Counts" is 0 when the bus is operating properly and greater than 0 when the module is unable to receive CAN messages.
R
MotoHawk:Blocks:CAN Read Message Block
This MotoHawk® block will receive and unpack a CAN message on the selected CAN channel. Attach Simulink signal specifications the output ports, to convert the output signals to an appropriate data type. Specifically, if a gain or offset is applied in the message specification, assign the signal to the floating-point data type.
Physical CAN Channel: The physical channel on which to transmit
Message Definition: A structure or a cell array of structures describing all of the details of 1 or more CAN messages. See motohawk_can_example.m for precise details of the structure.
Queue Size: This sets the size of the incoming message queue that will hold messages until this block executes. A value of zero or one will make only the most recently received message available.
Slot Name: The slot name can be used to connect this block to a slot which can be used to dynamically adjust the ID, ID Mask, Payload, and Payload Mask values.
Show Data Available Port: If selected a port will be added that will have the value 1 if a message is available and zero otherwise. If the queue size is larger than 1 than you can hook a Simulink Do-While block to this port and poll all of the messages out of the Queue.
Show Age Count Port: This port will increment every time the block executes and no messages are available. The date from this port can be used to do timeout logic on a message.
Label Wires with Field Names: Selecting this checkbox will cause the field names to be applied to the wires leading out of the block.
MotoHawk:Blocks:CAN Receive Slot Properties Block
This MotoHawk® block allows the user to configure the slot properties at run time.
S
MotoHawk:Blocks:CAN Send Message Block
This MotoHawk® block will pack and transmit one or more CAN messages on the selected CAN channel.
Name: The name of the CAN channel on which to transmit that is defined in a CAN definition block.
Message Definition: A structure or a cell array of structures describing all of the details of 1 or more CAN messages. See motohawk_can_example.m for precise details of the structure.
Pacing Interval[ms]: The time to delay between transmitting messages for a multiple message group. The pacing interval will insert the selected amount of time between each message if an array of messages has been specified. The group of messages will be transmitted at the interval defined in the message structure but will have an inter-message delay of the Pacing Interval. If the number of messages multiplied by the pacing interval is longer than the message interval, the latter messages will be dropped the cycle restarted with the first message in the group.
Label Wires with Field Names: Selecting this checkbox will cause the field names to be applied to the wires leading into the block.
MotoHawk:Blocks:CAN Send Message Raw Block
This MotoHawk® block is analogous to the Read CAN Raw block except that it transmits messages on the CAN bus instead of reading them. For single frame messages, the more advanced Send CAN Message block is typically preferred instead since this block does not perform any bit packing. It can be useful, however for sending multi-frame messages where data spans multiple CAN frames using the same message ID.
MotoHawk:Blocks:CAN Slot Trigger Block
This MotoHawk® block triggers whenever a CAN message is received on the given Slot.