Uploaded by cesar.monagas

Software Remote Pump Station Application Lab

advertisement
Connected Components Workbench™ v20 Software
Remote Pump Station Lab
Hands-on programming of the Micro800™ Simulator
in Structured Text (ST) language
c
Important User Information
This documentation, whether, illustrative, printed, “online” or electronic (hereinafter “Documentation”) is intended for use only as
a learning aid when using Rockwell Automation approved demonstration hardware, software and firmware. The Documentation
should only be used as a learning tool by qualified professionals.
The variety of uses for the hardware, software and firmware (hereinafter “Products”) described in this Documentation, mandates
that those responsible for the application and use of those Products must satisfy themselves that all necessary steps have been
taken to ensure that each application and actual use meets all performance and safety requirements, including any applicable
laws, regulations, codes and standards in addition to any applicable technical documents.
In no event will Rockwell Automation, Inc., or any of its affiliate or subsidiary companies (hereinafter “Rockwell Automation”) be
responsible or liable for any indirect or consequential damages resulting from the use or application of the Products described in
this Documentation. Rockwell Automation does not assume responsibility or liability for damages of any kind based on the
alleged use of, or reliance on, this Documentation.
No patent liability is assumed by Rockwell Automation with respect to use of information, circuits, equipment, or software
described in the Documentation.
Except as specifically agreed in writing as part of a maintenance or support contract, equipment users are responsible for:
•
properly using, calibrating, operating, monitoring and maintaining all Products consistent with all Rockwell Automation
or third-party provided instructions, warnings, recommendations and documentation;
•
ensuring that only properly trained personnel use, operate and maintain the Products at all times;
•
staying informed of all Product updates and alerts and implementing all updates and fixes; and
•
all other factors affecting the Products that are outside of the direct control of Rockwell Automation.
Reproduction of the contents of the Documentation, in whole or in part, without written permission of Rockwell Automation is
prohibited.
Throughout this manual, we use the following notes to make you aware of safety considerations:
Identifies information about practices or circumstances
that can cause an explosion in a hazardous environment,
which may lead to personal injury or death, property damage, or economic loss.
Identifies information that is critical for successful application and understanding of the product.
Identifies information about practices or circumstances that can lead to personal injury or death, property
damage, or economic loss. Attentions help you:
• identify a hazard
• avoid a hazard
• recognize the consequence
Labels may be located on or inside the drive to alert people that dangerous voltage may be present.
Labels may be located on or inside the drive to alert people that surfaces may be dangerous temperatures.
Connected Components Workbench™ Software Remote Pump Station Lab
Contents
Before you begin ........................................................................................................................................... 4
About this lab .................................................................................................................................................................................... 4
Tools and prerequisites included in the OnCourse (RAcbi) image ................................................................................................... 5
Exercise #1 – Run the completed virtual demo for the remote pump control application ............................ 6
Exercise #2 – Create a Structured Text (ST) program to replace the Pump_Control ladder logic. ............ 17
Exercise #3 – Create a Structured Text (ST) program to replace the Water_Level_Simulation ladder logic.
.................................................................................................................................................................... 32
Exercise #4 – Convert the Water_Level_Simulation_ST program into a User-Defined Function Block .... 39
3 of 45
Before you begin
About this lab
This lab will guide you in using Connected Components Workbench™ software to program a Micro800™ Simulator
to control a remote pump control virtual application in Structured Text (ST) programming language. You will also
implement a Selectable Timed Interrupt (STI) routine and a user-defined function block (UDFB).
4 of 45
Inputs to the Micro800 simulator:
•
Pump Auto/Manual
•
Pump 1 Manual ON/OFF (_IO_EM_DI_06)
•
Pump 2 Manual ON/OFF (_IO_EM_DI_07)
•
Tank Water Level
(_IO_EM_DI_05)
(_IO_P2_AI_00)
Outputs from the Micro800 simulator:
•
Pump 1 Run
(_IO_EM_DO_02)
•
Pump 2 Run
(_IO_EM_DO_09)
Tools and prerequisites included in the OnCourse (RAcbi) image
•
•
Software:
o
Connected Components Workbench software version 20.01 (or later)
o
Chrome web browser
Lab Files:
o
Simulator directory with virtual demo kit/remote pump control application files
o
Completed Remote_Pump_Station_Ladder_Logic.ccwarc project archive file
5 of 45
Exercise #1 – Run the completed virtual demo for the remote pump control application
In this section, you will:
▪ Import a completed project into Connected Components Workbench software.
▪ Start up the Micro800 Simulator.
▪ Run the virtual remote pump control application.
6 of 45
1. Start the Connected Components Workbench software by double-clicking the
icon on the desktop.
2. Click File → Import Project, select Remote_Pump_Station_Ladder_Logic.ccwarc and click Open.
7 of 45
3. This completed project is programmed in Ladder Diagram (LD). Connected Components Workbench software
also supports programming Micro800 controllers in Structured Text (ST) and Function Block Diagram (FBD).
4. Click the Start Micro800 Simulator icon.
5. Verify that Enable I/O Interface under Options is checked.
8 of 45
6. Make sure the loopback IP Address 127.0.0.1 is selected.
7. Click the Synchronize the module configuration icon to automatically add any plug-in and/or expansion I/O
modules present in the project to the Micro800 Simulator and click Yes to confirm.
8. Click the Power On Micro800 Simulator icon.
9 of 45
9. Click the Micro850 tab and then click Download.
10. Browse to the Micro800 Simulator and click OK.
10 of 45
11. Click Download to confirm the download.
12. Click Yes to change the controller to run mode.
13. Note the warning displayed next. For the Developer Edition of Connected Components Workbench software, the
maximum simulator runtime is one day. For the Standard Edition, the maximum simulator runtime is ten minutes.
Click OK.
11 of 45
14. Double-click the Start Simulation shortcut icon on the desktop.
15. Click START.
12 of 45
16. The “SPEED COMMAND” potentiometer sets the water valve opening (that is, demand for water). Click the ‘+’
button until the “SPEED COMMAND” potentiometer dial points to 9. This is the maximum water demand setting.
17. In AUTO mode, Pump 1 will be on whenever the water level is below 50%. Pump 2 will turn on once the water
level drops to 20%. With both pump running, the water level will rise slowly at the maximum water demand
setting.
13 of 45
18. Click the ‘-’ button until the “SPEED COMMAND” potentiometer dial points to 0. With the water valve closed, the
water level will rise quickly. Pump 2 will turn off when the water level reaches 80% and Pump 1 will turn off
when the water level reaches 95%. The High Warning turns on when the water level is between 90…95% and
the High Alarm turns on when the water level is 95% or above.
19. Click the Pump MANUAL button so that you can manually switch the pumps ON and OFF. With the pumps off,
click the ‘+’ button until the “SPEED COMMAND” potentiometer dial points to 9. The water level will drop and
you will see the Low Warning turn on when the water level is between 5…10% and the Low Alarm turn on when
the water level is below 5%.
14 of 45
20. When you are done trying out the virtual remote pumping application, click the power switch to “turn the demo
off”.
15 of 45
21. Close the Rockwell Demo Box tab and the Start Simulation window.
22. Next, you will create your own Structured Text (ST) programs to control the simulation.
16 of 45
Exercise #2 – Create a Structured Text (ST) program to replace the Pump_Control ladder logic.
Structured Text (ST) is a high-level, structured programming language designed for automation processes. The
Structured Text (ST) language is mainly used to implement complex procedures that cannot be easily expressed with
graphic languages such as Ladder Diagram (LD) or Function Block Diagram (FBD).
In this section, you will:
▪ Add and rename a Structured Text (ST) program.
▪ Program the pump control logic in Structured Text (ST).
17 of 45
23. The existing Remote_Pump_Station project that you downloaded to the Micro800 Simulator consists of two
ladder logic programs: Pump_Control and Water_Level_Simulation. You will program two Structured Text
(ST) programs to replace these.
24. Add a new Structured Text program.
Right-click Programs under the Micro850 in your Project Organizer and select Add → New ST: Structured
Text.
18 of 45
25. Notice a new Structured Text (ST) program called Prog1 has been added under Programs.
Micro800 controllers allow you to create multiple programs and use multiple types of programs
(such as Structured Text or Function Block Diagram) in the same controller application.
19 of 45
26. To rename the program, right-click the Prog1 program icon and select Rename.
20 of 45
27. Rename the program, Pump_Control_ST.
28. Double-click the Pump_Control_ST icon to display the blank Structured Text (ST) program.
29. Double-click the original Pump_Control program to open the ladder logic program. You will convert each rung
into Structured Text (ST) statements, so you will be jumping back and forth between these two program tabs.
21 of 45
30. The first thing to note is that in ladder logic you can have rung comments. In Structured Text (ST), you can have
equivalent program comments. Double-click the Rung 1 comment box and copy the entire comment. Click the
Pump_Control_ST-POU tab and paste this comment into line 1 of the structured text program.
31. To designate this line as a comment instead of a command, enter in ‘(* ’ at the beginning of the comment and ‘
*)’ at the end of the comment. Any Structured Text (ST) comment text will show up as green.
32. The Structured Text (ST) equivalent of a ladder rung is typically an IF/THEN statement – IF variable
__SYSVA_FIRST_SCAN is ON, THEN set output _IO_EM_DO_00 ON.
33. Click Toolbox on the right-hand side to open the ST toolbox of commands. Click and drag IF THEN ELSE into
the program. This prompts you with what to enter.
34. The first Boolean expression is the value of variable __SYSVA_FIRST_SCAN and the result is an assignment of
variable _IO_EM_DO_00 equal to TRUE.
22 of 45
35. As you begin to enter a variable name, the software will present a list of all available variables starting with the
letters you have entered. At any time, you can double-click the variable name you intend to use from the list.
36. To set the value of a variable, use a ‘:=’ assignment statement. Each statement ends with a semicolon ‘;’
separator.
37. In this case, there is no ELSIF or ELSE conditions, so these lines can be deleted.
38. To verify that everything you have entered in so far is valid, go ahead and build the project by clicking the build
icon.
23 of 45
39. If the Output window indicates that the build succeeded with 0 errors and 0 warnings, then you have entered
everything in correctly so far. If you get any errors, return and make sure that your program looks exactly as
shown above. (The most common errors are a result of missing semicolons. You may get multiple errors that
can be corrected by entering one missing semicolon!)
40. Now continue with converting Rung 2.
41. First copy the rung comment over.
42. Enter the IF/THEN statement for the first contact in the rung.
24 of 45
43. There are four possible actions if _IO_EM_DI_05 is TRUE, so four IF/THEN statements must be embedded. To
help visualize this embedding, indent the embedded IF/THEN statements within the main IF/THEN statement. If
_IO_EM_DI_06 is TRUE, then set _IO_EM_DO_02 equal to TRUE.
44. In this case, we also have an ELSE condition if _IO_EM_DI_06 is FALSE - set _IO_EM_DO_02 equal to FALSE.
45. Remember to end each IF/THEN statement with an END_IF followed by a semicolon.
25 of 45
46. A second embedded IF/THEN statement for _IO_EM_DI_07 and _IO_EM_DO_09 uses the same structure as
the first.
47. The variable Alias/descriptions for the I/O addresses do not show up in Structured Text like they do in the ladder
logic, so you may find it helpful to add the comments directly following the I/O addresses.
26 of 45
48. Rung 3 is the ELSE condition to Rung 2 (when _IO_EM_DI_05 is FALSE).
49. As before, begin by copying the rung comments over.
50. The equivalent code for Rung 3 consists of four individual IF/THEN structures.
27 of 45
51. Don’t forget the END_IF (followed by a semicolon) at the end of the larger IF/THEN section starting at line 6.
28 of 45
52. Rung 4 will require four separate IF/THEN/ELSE structures to both turn each output on (when the comparison is
true) and off (when the comparison is false).
29 of 45
53. When there are two preconditions in series, you use an AND statement to make sure both evaluate true.
54. Build the project by clicking the build icon to verify that everything you have entered in is valid. If you get build
errors, return and verify that each line was entered correctly and rebuild until you do not get any build errors.
30 of 45
55. Now delete the original Pump_Control ladder logic program by right-clicking on it and selecting Delete.
56. Download and test the modified project with the simulation. See steps 9 to 20 as needed for reference.
57. When finished testing and verifying your project, Disconnect from the controller as shown.
31 of 45
Exercise #3 – Create a Structured Text (ST) program to replace the Water_Level_Simulation ladder
logic.
In this section, you will:
▪ Add and rename a Structured Text (ST) program.
▪ Assign the program to a Selectable Timed Interrupt (STI).
▪ Program the water level simulation logic in Structured Text (ST).
32 of 45
58. Add a new Structured Text (ST) program.
Right-click Programs under the Micro850 in your Project Organizer and select Add → New ST: Structured
Text.
59. Rename the new program Water_Level_Simulation_ST.
33 of 45
60. Double-click the Water_Level_Simulation_ST icon to display the blank Structured Text (ST) program.
61. Double-click the original Water_Level_Simulation program to open the ladder logic program. Notice that the
instructions in this one-rung program effectively only execute every 100 milliseconds.
34 of 45
62. An easy way to make the new Water_Level_Simulation_ST program code execute once every 100
milliseconds is to assign the program to a Selectable Timed Interrupt (STI) configured to execute every 100
milliseconds. Under the Micro850 tab, select Interrupts, click Add and fill in the Add Interrupt configuration
screen as shown. Click OK.
63. The program icon now has an orange indicator to flag that its execution is being controlled by an interrupt.
35 of 45
64. As before, begin by copying the rung comment into the Structured Text (ST) program.
65. Since Demand is a local variable in Water_Level_Simulation, it must be added as a local variable of type
REAL in Water_Level_Simulation_ST. The other variables used are Global Variables, so they are already
available to the new program.
36 of 45
66. Now you must convert the branches of the rung into Structured Text (ST).
67. See if you can come up with the equivalent Structured Text (ST) commands on your own and check it against
the solution on the next page.
37 of 45
68. Solution:
69. Delete the Water_Level_Simulation ladder logic program, then download and test the modified project with the
simulation. See steps 9 to 20 as needed for reference. You will receive warnings when the project is built but
these are expected because there are Global Variables being modified within the STI program. Click Yes to
continue with the download when you get the following screen.
38 of 45
Exercise #4 – Convert the Water_Level_Simulation_ST program into a User-Defined Function Block
In this section, you will:
▪ Convert the program into a user-defined function block (UDFB).
39 of 45
70. The main advantage of a UDFB is to be able to reuse the code in other projects. This requires removing the
hard-coded I/O assignments within the UDFB and instead making those input and output parameters for the
UDFB.
71. Right-click User-Defined Function Blocks and add a new Structured Text (ST) program.
72. Rename the UDFB WATER_LEVEL.
40 of 45
73. Next, create the input and output parameters for the UDFB. Right-click the WATER_LEVEL icon and select
Parameters.
41 of 45
74. For input parameters, there are Demand_Input (DataType UINT), Pump_1_Run (DataType BOOL) and
Pump_2_Run (DataType BOOL). For output parameters, there is Level_Output (DataType UINT). Create these
parameters using the New Input and New Output buttons. When finished, close the Parameters screen.
75. Cut and paste the Structured Text (ST) from Water_Level_Simulation_ST to the UDFB.
42 of 45
76. Replace _IO_P2_AI_00 with Demand_Input, _IO_EM_DO_02 with Pump_1_Run, _IO_EM_DO_09 with
Pump_2_Run and _IO_P2_AO_00 with Level_Output.
77. Cut and paste local variable Demand from Water_Level_Simulation_ST to the UDFB and then delete the
Water_Level_Simulation_ST program - the UDFB will be executed from the Pump_Control_ST program.
78. Add a 100-millisecond resetting timer by first configuring a timer on-delay (TON) Pump_Control_ST local
variable TON_1.
79. Add WATER_LEVEL_1 as an instance of UDFB WATER_LEVEL as a Pump_Control_ST local variable.
80. Add the Structured Text (ST) for the automatically resetting timer in Pump_Control_ST.
43 of 45
81. Add the Structured Text (ST) to execute the Water_Level UDFB every time the timer times out (TON_1.Q is
TRUE).
82. Download and test the final project with the simulation. See steps 9 to 20 as needed for reference.
44 of 45
Allen-Bradley, Connected Components Workbench, expanding human possibility, FactoryTalk, Kinetix, Micro800, Micro850, Micro870, PanelView, PowerFlex, Rockwell
Automation, Stratix, TechConnect are trademarks of Rockwell Automation, Inc.
Trademarks not belonging to Rockwell Automation are property of their respective companies.
Copyright © 2021 Rockwell Automation, Inc. All Rights Reserved. Printed in USA.
45 of 45
Download