Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Basic J1939 Communication over CAN

This example shows you how to use J1939 blocks to directly send and receive Parameter Group (PG) messages in Simulink®.

Vehicle Network Toolbox™ provides J1939 Simulink blocks for receiving and transmitting Parameter Groups via Simulink models over Controller Area Networks (CAN). This example performs data transfer over a CAN bus using the J1939 Network Configuration, J1939 Node Configuration, J1939 CAN Transport Layer, J1939 Receive and J1939 Transmit blocks. It also uses MathWorks Virtual CAN channels connected in a loopback configuration.

Set Up J1939 Block Parameters

Create a model to set up J1939 receive and transmit over the network. The model is configured to perform single frame transmission between two nodes defined in the J1939 database file.

  • Use a J1939 Network Configuration block and select the CAN Database, J1939.dbc. This J1939 database file consists of two nodes and a couple of single-frame and multiframe messages.

  • Use a J1939 CAN Transport Layer block and set the Device to MathWorks Virtual Channel 1. The transport layer is configured to transfer J1939 messages over CAN via the specified virtual channel.

  • Use basic Simulink source blocks to connect to a J1939 Transmit block. The J1939 Transmit block is set to queue data for transmit at each timestep when the Trigger port is enabled. For this example, a periodic trigger subsystem sends a high pulse every 50 milliseconds.

  • Use the J1939 Receive block to receive the messages transmitted over the network.

Visualize Signals Received on the Network

Plot the results to see the vehicle signal values received over the network. The X-axis corresponds to the simulation timestep.

Was this topic helpful?