Site Information

 Loading... Please wait...

Blog

Programming the SAE J1939 ECU Simulator Board Using Visual Studio C#

Posted by Wilfried Voss on

jCOM C# Demo Code Window Screen Shot

The following refers to a Visual Studio C# application, representing a very simplified version of our  jCOM1939 Monitor - SAE J1939 Monitor, Analyzer, And ECU Simulator. The jCOM1939 Monitor Software is a tool to monitor, analyze, and simulate SAE J1939 data traffic. The system combines our jCOM.J1939.USB that functions as an SAE J1939 to USB (or UART) gateway. A comprehensive and easy-to-use, easy-to-understand Windows software displays not only SAE J1939 data traffic; it also allows to scan the network, simulate an ECU (incl. full node address negotiation features), and respond to data request messages.

Hardware Requirements

It is important to point out that you will need one of our gateways for both program versions, the demo code and the actual monitor program, to work. The programs are not designed to work with any other hardware from other manufacturers.

The jCOM1939 Monitor software works directly with the following SAE J1939 gateways:

In contrast to the full monitor software, the demo program, as introduced in this post, is available in full source code. The C# code was developed using Visual Studio 2013, but it can be easily imported to newer versions.

Functionality

The first step of handling the software is to select the COM port that was assigned to the gateway. The program offers choices by scanning the PC for available COM ports. After selecting the right COM port and clicking the  Start command button, you will see the heartbeat messages appearing on the screen. The gateway sends the heartbeat message every one second.

Clicking on the Request Status will provide a feedback such as  REPSTATUS - Listen-Only Mode, indicating that the gateway will only receive SAE J1939 PGNs and display them. However, be aware that you will need to set a PGN filter for data to be displayed. That PGN filter is hard-coded as 65280, but can be modified to any other PGN.

Use the  Add Filter command button to add the filter and Delete Filter to remove it.

In order to transmit data into an SAE J1939 network, you will need to claim a node address. This is accomplished by clicking  Claim Address. Please be aware that you will need at least one other network node to establish communication, otherwise the address claim will fail.

After the node address has been claimed successfully, you will be able to transmit data into the network. Yet again, all parameters such as desired node address and the transmitted data are hard-coded into the program but can be easily modified. After all, the code is designed to demonstrate the communication between the gateway and the PC.

C# Source Code

I will not engage into a detailed description of the source code, since this would require some tremendous efforts and time. Every programmer with some basic C# experience will be able to recognize the important parts and I have tried to keep the program as simple as possible. The code explains the most important commands to the gateway and how to receive feedback and data.

However, in order to understand the protocol between the gateway and the PC, you will need to read our document (PDF):

Download


SAE J1939 Starter Kit And Network Simulator

SAE J1939 Starter Kit And Network Simulator

Our J COM.J1939 Starter Kit And Network Simulator is designed to allow the experienced engineer as well as the beginner to experiment with SAE J1939 data communication without the need of connecting to a real-world J1939 network, i.e. a diesel engine. It may sound obvious, but in order to establish a network, you need at least two nodes, and that fact applies especially to CAN/J1939 where the CAN controller will basically shut down after transmitting data without receiving a response. For that reason, our jCOM.J1939 Starter Kit And Network Simulator consists of two J1939 nodes, namely our jCOM.J1939.USB, an SAE J1939 ECU Simulator Board With USB Port.

More Information..