Skip to content

Initial values does not show up in debug mode

Hello,

I have multiple questions with C++ library and PLCNext application.

  1. Init value in the PLCNext does not show up in debug mode. I tried Retain option enable/disable and the default value in debug mode is always 0.
  2. Every time C++ library is rebuilt I have to disconnect the ports and re-assign them. This is not at all feasible as i have 2000+ variables to configure. Is there an option to avoid ports re-assignment when C++ library changes?
  3. Cannot upload images or copy screenshots to the post.

Comments

  • Above are the screenshots from PLCNext and C++ debug mode.

  • 1. I'm not quite sure what you expect to see (sorry). I created a C++ PLM project with these two port variables in a Program:

    These port variables are not assigned anywhere else.

    In PLCnext Engineer, I created an instance of this Program in a Cyclic Task, and without making any Port connections this is what I see in the watch window:

    The two Port variables have kept the initial value that was assigned in the C++ code.

    2. I connected the two C++ program ports above, to corresponding port variables in PLCnext Engineer. I added a variable to the C++ Program (not a port variable), and I added some code to the Execute method of the C++ Program. I rebuilt the C++ code into a PLCnext Engineer library, and exchanged the old version of the library with the new library in PLCnext Engineer. The ports remained connected in PLCnext Engineer.

    Can you explain what steps cause the ports to become disconnected?

    3. Are the images only a problem in a new post? The ones in your reply look ok.

  • Martin,

    Here is the struct in C++ and does not have any initial values. I was hoping to get those from PLCNext as I have initialized PLCNext variables.

    Should the initialization be done in C++? I would like it the other way around so c++ pulls values from PLCNext variables.

    Last night, I was unable to upload the screenshot (not sure why), but I was able to this morning and hence the 2nd post.

    For ports getting disconnected, there is nothing special on my end. IEC variables assigned to struct variables.

    I just edited my C++ and rebuilt the library, and this is what I see in PLCNext app


  • Just on the Initial value problem -

    I've created an OUT port variable in an IEC program, with the initial value TRUE.

    I've connected that OUT port variable to an IN port variable on the C++ program instance. The C++ port variable is not initialised in the C++ code.

    When I go online, I can see that the IEC variable has the default value (TRUE), and that value has been transferred to the IN port variable on the C++ program:

    In your PLCnext Engineer project, when you go online, what values do you see for the OUT and IN port variables?

  • Martin,

    defining the below code in Execute method was causing issues for me. Initially I defined my structure in a different header (Separate topic, will open another discussion for that).

    Once, I commented the above lines, I can see the data flow between PLCNext and C++. Sorry about the confusion.

    My 2nd issue still remains. Can you please assign a struct variable to the IEC port and rebuild the library. I see the below error every time i recompile my library. No errors when the struct variables are not connected to any ports.


  • I also get the same problem in some cases, but this video shows a procedure that seems to work in PLCnext Engineer version 2022.6.


  • martin,

    I installed 2022.6 and followed the procedure in the video, but still no luck. I see the same error. I tried assigning 1 port variable and all of them, but the result is the same.

    When the library is added, I do see a message to accept the change but the option is grayed out.


    This is frustrating to re-assign variables every time the library changes.

Sign In or Register to comment.