Skip to content

C# Classes into PLCnext

Hello,

I have created some code which contains a class named "Tank".

The "Tank" class contains another class inside it as a variable which is named "Pipe" and contains 2 boolean variables (inputSwitch and outputSwitch).

How can I add the "Tank" class to my PLCnext Program Code and match the inputSwitch and outputSwitch of the "Pipe" class contained in it to actual I/O modules?

Any help is appreciated in advance!

Comments

  • edited April 2023

    Hello dimitrismvrm,

    I hope I understand you use case correctly and would like to recommend follws:

    • Define a Input and Output variables if you implement a FB or In- and Output-Variables, if you implement a Progrogram. This variables are you Data-Input and Data-Output flow to process data.
    • Depends on your Input-Data you can manage the inputSwitch and outputSwitch of the "Pipe" class, e.g. via a method call/execution.

    If I don't understand you use case correctly, please provide me the Source code of your project. Please use the following contact (if your company located in germany): Kontakt | PHOENIX CONTACT

    Automatisierung und Safety

    Montag - Freitag: 08:00 - 16:00 Uhr

    +49 5235 3-11000

    support@phoenixcontact.de


    BR Eduard

  • Well, my actual question is this. I have created a PLCnext C# Program which has some variables I want to connect to the actual Inputs and Outputs of my PLCnext device.

    I want to match the followings:

    _outputSwitch_Pipe1 to digital_output_1 of my PLCnext device

    _outputSwitch_Pipe2 to digital_output_2 of my PLCnext device

    _inputSwitch_Pipe1 to digital_input_1 of my PLCnext device

    _inputSwitch_Pipe2 to digital_input_2 of my PLCnext device

    How can I do that inside PLCnext Engineer?

  • edited April 2023

    Hello dimitrismvrm,

    the LibraryBuilder automatically generates the ".pcwlx" library within the process of Visual Studio compilation. The file is located in your project folder, e.g. C:/Users/<username>/workspace/FirstProject/Bin.

    You have to proceed the follwong steps:

    1. Importing a library into PLCnext Engineer
    2. Instantiating a program (plcnext.help) (also showed in video for C++ programming in timeslot of 4:44-5:00 minutes : https://youtu.be/IUGSZzuzm-c)
    3. Configuring Axioline F modules (plcnext.help)
    4. Assigning process data (plcnext.help) e.g. connect the consumer Variable in C# program "_inputSwitch_Pipe1 to digital_input_1" with the producer Out-Port-Process data "dio-1/IN00".
    5. Please note, the Datatypes of In- and Out-Port Variables must have the same elementary datatype (for connecting). It is not possible to connect the Boolean In-Port-Variable with Integer Out-Port-Variable!

    I think, the descriptions will help, if not, please let me know.

    BR Eduard

  • Alright I think that helped me a lot! Thank you Eduard! Step 4 was where I got confused.

Sign In or Register to comment.