This example demonstrates how to configure the J1939 Device Manager included with Codesys to send and receive messages. This example will receive SPN 701 and 702 and set the user LED's accordingly then transmit the status back on custom PGN 65350. See notes in the code for details on its operation.
Adding The J1939 CAN Bus Devices
- Right click on the uController Device then select Add Device and add the CAN device.
- Right click on the newly created CANbus device and select Add Device then select the J1939 Manager
- Right Click on the new J1939 Manager and add two J1939 ECU Devices. When complete the device tree should look as shown in the picture. Add as many ECU devices for each unique CAN port, Source Address, Transmitter, or Receiver combination necessary for the application.
Configuring a Receiver
- Rename one of the devices as a Receiver to help distinguish its function.
- To Receive data simply set the preferred source address of the data then add PGN's you wish to receive from the built in J1939 data base. Notice the Tab is labeled Tx Signals which is confusing.
Configuring a Transmitter
- Rename one of the devices as a Transmitter to help distinguish its function.
- Select Local Device check box in the General settings tab to make this device a transmitter.
- Add PGNs from the data base in the Tx Signals Tab. You can also create custom parameters on the fly from this screen by selecting Add Signal.
- To transmit the message select the Transmission Mode, Cyclical will transmit x number of times the main loop executes.