1/28/2022 4:01 PM | |
Joined: 1/20/2022 Last visit: 6/20/2022 Posts: 12 Rating:
|
Hello everyone I have problem that I believe stems from the same confusion that julien.reinauld had. I have configured the PLC in the TIA portal and filled the tag table with names for all DI and DO that I plan to use. Now, I have many similar elements in my system (lets say I have 10 valves). Each valve can be controlled with one DO (if 0 close the valve, if 1 open the valve); in addition, each valve sends a DI where it specifies its status (if 0 it is closed, if 1 it is opened). I want to write a basic FC that changes the status of a valve. Since i would like to be able to apply this function to any valve, I tried to be as general as possible. So, I initially created a new PLC data type, called "valve". It has two attributes: its status (opened or closed) and its command (command to open or command to close); both are of boolean type. I imagined the FC with 1 input of "valve" type, which represents the physical valve that I want to control. The FC gets the input, reads its status (if it is opened or closed) and changes the command accordingly (if it is open, then close it and viceversa). Here comes my problem. I am able to do everything I said before, and everytime I use the FC, I get the variable "valve" with the right values. But then, I face the problem of assigning those values to the DO of my PLC. For example, if the physical valve is controlled by the %Q2.1, I have to assign the FC result to the variable in the PLC tag table which has the address %Q2.1 in order to be able to send this command. I would like to skip this step, and I was wondering if there is a way to link the elements in the PLC tag table to my symbolic variables. For example, I tried creating a DB with all my valves: it contains the symbolic variables valve_1, valve_2, etc, and each of these variables is of the type "valve", so it gets its own attributes. I would like to link each of these attributes to its corresponding element in the PLC tag table, so that I can skip the manual assigning step everytime. (i.e., permanently link the "My_DB.valve_1.command" to the element in the PLC tag table that has the address %Q2.1, so that every time i change the command value for valve_1, it also changes in the outputs). Let me know if I was clear enough. Thank you for your help in advance.
------------------------------------------------------------------------------------------ |
Last edited by: Jen_Moderator at: 01/31/2022 06:36:12New subject after splitting |
|
1/29/2022 10:08 AM | |
Joined: 3/30/2020 Last visit: 8/7/2024 Posts: 4670 Rating:
|
Hello. Perhaps you should have someone spend time mentoring you. There are gaps that needs filling when it comes to structuring programs and using subroutines. I say 'subroutines' because OB / FC / FB code blocks fill that role. You will benefit from knowing what multi-instance FBs can do for you in the current question you are asking. See if you can get value from this: |
Activities of this user is voluntary. There is no obligation or liability placed on this user. Though optional, your 'please' and 'thank you' is highly valued. |
|
This contribution was helpful to
1 thankful Users |
1/31/2022 10:51 AM | |
Joined: 1/20/2022 Last visit: 6/20/2022 Posts: 12 Rating:
|
Thank you for your answer. I understand waht multi-instance is and I am trying to study deeper how it works. But I believe my question is not strictly related to multi-instancing. Multi-instancing may help me in creating just 1 DB for 10 valves instead of 10 DBs, but the central point of my problem was to find a way to link all the DI and DQ of my PLC (listed and named in the tag table) to the symbolic variables that appear in my program. As far as I understood, the only way of doing it is to write some line of codes where I explicitly assign all the DI to my symbolic variables and other symbolic variables to all my DQ (if I have a total of 100 DI and 100 DQ, I must write 200 lines of code in a FC and call it from the OB). Anyway, thank you for the time you spent answering me and the resources you linked to me. |
Follow us on