Does anyone have a sample program they’d be willing to share that uses the mapp J1939 library? I’m trying to understand how this mapp component could be used in the context of a mobile application on the X90.
The mapp Configuration allows you to enable various PGNs and set whether they should be Send or Receive. However, if a PLC needs to communicate this protocol with multiple devices it will need to both send and receive some messages. In this case, are multiple mapp components and multiple function blocks required?
Additionally, the available PGNs are only a subset of the overall list defined by the standard. My understanding is that, if you want to transmit additional data, you’ll have to pack it yourself and then use the MpJ1939Transmit or MpJ1939Receive function blocks. If anyone has a sample that shows how these are supposed to be used, it would help me to understand this library much better.
I don’t currently have an example program that I can pass on to you, but it’s relatively easy to implement yourself.
In order to gain more understanding about the mapp component MpJ1939, you can build an executable simulation example with a PLC (with two CAN interfaces that are connected to each other):
The 1st CAN interface is used for an instance of the MpJ1939Generic configuration.
The 2nd CAN interface is used for instances of the MpJ1939Receive/MpJ1939Transmit configuration.
In this constellation, messages can now be sent or received with quasi-simulated J1939 participants.
If the PLC has to communicate with several devices via the J1939 protocol, several instances of the mapp configuration (the partner CAN address is also defined here) and function blocks must be created.
The J1939 standard defines many different PGNs that contain a wide variety of signals. In the MpJ1939Generic configuration only the PGNs that are most commonly used are defined. If a PGN is to be transmitted that is not included in the MpJ1939Generic configuration, the function blocks MpJ1939Receive, MpJ1939Transmit or MpJ1939SpecificRequest must be used. Of course, it should be noted that only raw data can be transferred via these 3 function blocks. The breakdown into the individual signals of the PGNs must be done applicatively. However, the function blocks MpJ1939Receive, MpJ1939Transmit and MpJ1939SpecificRequest also support multi-message transfers, i.e. messages larger than 8 bytes (maximum message length = 1785 bytes) can also be transferred.
Test1939.zip (981.1 KB)
This example is made with two X20CS1070 and VEP1 PGN. It was made to understand the structure. The J1939 structures are adapted for the 8bytes data in the can-frame.
For example VEP1 structure in the can-frame:
It seems that AltCurrent (USINT) can have a value between 0 250.
It seems that netBatteryCurrent (SINT) can have a value betweem -125 +125.
The other values are rated between 0 and 32715.75 so REAL type could be correct.
Here is an Automation Studio sample project to simulate the technology package MpJ1939.
This example contains simulations for all function blocks of MpJ1939.
The hardware used, is an X20CP1586 with a CAN interface module X20IF2772 (with 2 CAN bus interfaces).
The two CAN interfaces are directly connected to each other.
The software includes five ladder diagram tasks:
“GenericFUB”:
An instance of the function block “MpJ1939Generic” is called in this task.
The mapp configuration “gJ1939Generic” for this instance defines the following PGN’s:
EEC1 → Send
EEC2 → Receive
CI → Request with a cycle time of 5 seconds
“SpReqHOURS” (Specific Request HOURS - Engine Hours):
An instance of the function block “MpJ1939SpecificRequest” is called in this task.
The PGN HOURS is requested from the remote station (Task: “AnswRequ”) in a cycle of 7.5 seconds.
The raw data subsequently received is entered into an instance of the structure “MpJ1939HOURSType”.
“RecvEEC1” (Receive EEC1 - Electronic Engine Controller 1"):
An instance of the function block “MpJ1939Receive” is called in this task.
The PGN, sent by the “MpJ1939Generic” function block (task: “GenericFUB”), with a time grid of 20 milliseconds is received as a raw data array.
The received raw data is entered into the structure “MpJ1939EEC1Type”, so that it is displayed again analogously to the structure sent out by the MpJ1939Generic.
“TransEEC2” (Transmit EEC2 - Electronic Engine Controller 2):
An instance of the function block “MpJ1939Transmit” is called in this task.
First, the data from the “MpJ1939EEC2Type” structure is converted into a raw data array and then sent to the “GenericFUB” task.
The time frame for the PGN is defined as 50 milliseconds. This time grid is controlled with a TON-timer.
“AnswRequ” (Answer Requests):
In this task the requests sent by the “MpJ1939Generic” or the “MpJ1939SpecificRequest” are received and answered.
The receipt of the requests is handled via the “ArCanReceive” function block from the “ArCAN” standard library.
In the receive data of the “ArCanReceive” the PGN of the desired request is received in bytes 0 and 1.
One instance of the “MpJ1939Transmit” function block answers the corresponding request with prepared data.