Skip to content

OPC-UA string to OUT port string error

edited May 2021 in PLCnext Engineer
Hi,

I’m currently working on a project to connect a OPC-UA value to a global OUT port that’s connected to a C++ application.
When writing a value to OPC-UA, the following debug screen is visible.

[img]https://i.imgur.com/sKTHP9l.png[/img]

When I’m changing the WebApp.city and WebApp.key to a hardcoded string (e.g. Jakarta) the code works fine.

Does anybody know what is wrong?

Kind regards,
Kelvin S.

Comments

  • Can you please show:
    - the type of the WebApp structure, including the types of all the fields?
    - the declaration of the WebApp variable?
    - the declaration of the glob_wapi_city and glob_wapi_key variables?
  • Hi Martin,

    The WebApp structure has the following UDT:
    TYPE
        UDT_WEB_APP : STRUCT
            city : STRING;
            key : STRING;
            temperature : REAL;
            setpoint : REAL;
        END_STRUCT;
    END_TYPE
    

    It is decelerated in the main instance:
    KRqWdUX.png

    The OUT ports are also defined in the main instance:
    6p95GLy.png

    The C++ application is called every 10s with a watchdogtimer of 15s. It is connected like this:
    rmr2D3N.png

    Kind regards,
    Kelvin S
  • The problem you describe is the assignment of the Struct field values to the OUT port variables. These assignments, and all the associated variables, are in the Main program instance.
    Is the connection to the C++ program instance relevant in this case? i.e., if you disconnect the two OUT ports from the C++ program variables, does the assignment in the Main program instance work properly?
  • Hi Martin,

    When I'm using a temporary string it also doesn't work.

    7nDvkHn.png

    I will look further and submit the answer to the forum when I fixed the problem.

    Kind regards,
    Kelvin S.
  • OK, I can't reproduce that problem here, even when I write the WebApp struct fields from an OPC UA client.
    I am using PLCnext Engineer 2021.3 and AXC F 2152 FW 2021.0.5.
    Please check that the Cycle100 task is actually being executed cyclically, and that the assignment is being called on every task cycle.
  • Hi Martin,

    If found the bug! When the FAIL led is turned on, the conversion from string to string doesn’t work anymore. A soft reset was all what was needed.

    Kind regards,
    Kelvin
  • I'm glad you found the error. When the FAIL LED is on, it means that the tasks will not be executing, and so no code will be running. This would explain why the assignments were not being made.
    If the FAIL LED continues to appear, and if you need help with that, please let us know in a separate post.
  • Hi,

    For everyone who is facing the same problem. Check the watchdogtimer. I changed it to 0 (turns watchdog off) and everything was fine!

    Kind regards,
    Kelvin
  • The task watchdog timer is there for a reason. If you need to disable it to get your project to run, then that indicates an error in your code that is causing an excessive task execution time. You need to fix that error to avoid problems further down the road.
    ~ Martin.
Sign In or Register to comment.