Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

J1939 Transmit Parameter Group

kochjr
2017-06-01
2017-06-07
  • kochjr - 2017-06-01

    I'm trying to send a P2P J1939 message from a local ECU using Transmission Mode - Application Triggered. However, I'm having problems using the J1939.TransmitParameterGroup function block. Whenever the xExecute input is TRUE the xError output becomes TRUE and the eError output indicates ERROR.WRONG_PARAMETER. My itfECU input is set to the name of my local J1939_ECU, and the dwPGN input is set to the PGN in my TX Signals menu I wish to send. Additionally, that PGN is configured as Application Triggered.

    Does anyone have an example of how to do this properly?

     
  • Lo5tNet - 2017-06-01

    Have you setup the destination address?
    An example of how I can get it to work is:

    VAR
       request_PGN_Transmit: J1939.TransmitParameterGroup;
       request_PGN_Transmit_Trigger: J1939.TransmissionTrigger;
       request_PGN_Timer: TON;
       request_PGN_Trigger: R_TRIG;
    END_VAR
    //Setup parameter group
       request_PGN_Transmit(xExecute:= TRUE, itfECU:= HFX48_Send, byDestinationAddress:= 139, dwPGN:= 59904);
    //Request message every 500ms                  
       request_PGN_Timer(IN:= NOT request_PGN_Timer.Q, PT:= T#500MS);
       request_PGN_Trigger(CLK:= request_PGN_Timer.Q);
       request_PGN_Transmit_Trigger(xExecute:= request_PGN_Trigger.Q, itfParameterGroup:= request_PGN_Transmit.itfParameterGroup);
    

    Then I have my signal setup like:

    IMG: AppTrigSetup.PNG

     
  • kochjr - 2017-06-01

    The important thing I didn't have or understand was that the Destination Address needed to be set and match in both the J1939.TransmitParameterGroup function block and the J1939_ECU transmission settings for the PGN. I was trying to do it in one or the other, not both...

    Is there a way to programmatically change the destination address? For instance, if the address of the ECU I am transmitting to changes I would need to manually change all the destination addresses in each PGNs transmission settings. If there was a way to programmatically do that it could save a lot of work.

    Thanks for the help!

     
  • kochjr - 2017-06-02

    As a follow up, I need to send multiple Proprietary A (PGN: 61184) messages to the same ECU. The first byte is the command code and the length varies depending on the command. While CODESYS allows the same PGN to be declared multiple times in the TX Signals tab, I don't see a way to uniquely identify them to trigger a transmission. The only thing I can think of is to have a single PGN and transmit trigger then populate the bytes differently per cycle based on the command I need to send. Is there another or more appropriate way to handle this scenario?

     
  • Lo5tNet - 2017-06-05

    If you are looking to change the DA programmatically then you will need to write your own function for sending the message to the best of my knowledge and is what I have done in the past. The CANAPI might have an easier way of going about it but I have just been going to the "CAA Can Low Level Extern" to do what you are asking and making something custom.

    As for having multiple PGN 61184 this is an issue I have run into also and was told to use the method "TriggerPGByIDx" from a distributor (Does work). Codesys has this marked as obsolete so I didn't end up using it. Again I just made function blocks to transmit the messages through code instead of using the CANBus stack. For example I have two messages that I needed to send, available flow and desired flow to a valve. I call two function blocks, one for the available flow command and one for the desired flow. When the function block is called and x amount of time as passed since the last message was sent (or can be setup to do it on change) it automatically publishes the message to the bus without needing to setup anything on the J1939 manager.

    Initial setup might take longer but has saved time on newer projects when implementing this valve.

     
  • kochjr - 2017-06-07

    Thanks for the help. I was having an issue with P2P receive but I just figured out that you shouldn't place your local address in the PGN.

     

Log in to post a comment.