Creating and Configuring A Script Program Tutorial Guide
Creating and Configuring A Script Program Tutorial Guide
Introduction
1 About This Guide ........................................................... 9
1.1 Purpose of This Guide ................................................................. 11
1.2 How This Guide is Organized ...................................................... 12
1.3 Typographical Conventions ......................................................... 13
Tutorial
3 Our Case Study ........................................................... 21
3.1 University X ................................................................................. 23
3.2 Requirements and Specifications ................................................ 26
3.2.1 Devices Used for This Case Study ............................................. 26
3.2.2 Software Used in This Tutorial ................................................... 26
3.2.3 Specifications ........................................................................... 26
3.3 Focus of This Tutorial .................................................................. 27
3.3.1 Pre-existing Project Database Folders and Programs ................ 30
3.3.2 Pre-existing Project Database Objects ...................................... 32
3.3.3 Pre-existing WorkStation for Projects User Accounts ................. 33
Topics
Purpose of This Guide
How This Guide is Organized
Typographical Conventions
1 About This Guide
1.1 Purpose of This Guide
Introduction
The Introduction part contains information on the purpose of this guide, how this
guide is organized, where to find more information, and information on regulatory
notices.
Tutorial
The Tutorial part contains a step-by-step description of how to carry out different
tasks. If you want more information, see WebHelp or the corresponding Building
Operation Guide.
The Tutorial part includes a case study for a fictional customer called University X.
You can decide if you want to follow the example or use the described procedures
as reference information. The case study in this tutorial is an example of a typical
way of configuring Building Operation for a customer. When reading through this
tutorial, you might not have access to the devices, programs, and other files that
are needed for the fictional customer University X. However, the purpose of having
a case study is to see the procedures put in context, so you see how the
procedures could be used when configuring Building Operation, devices, or
programs for your customer.
Note
The programs and files that are used for the fictional customer University X are
intended for training purposes only.
Tip
Helps you understand the benefits and capabilities of the product.
Note
Provides you with supplementary information.
Important
Alerts you to supplementary information that is essential to the completion of a
task.
Caution
Alerts you to a condition that can cause loss of data.
Warning
Alerts you to a condition that can cause product damage or physical harm.
Bold texts:
User interface items, such as property names and buttons, are written in bold, for
example "On the File menu, select New."
Example texts:
All the example related information is indicated by blue lines and bullets.
Topics
Where to Find Additional Information
Regulatory Notices
2 Additional Information
2.1 Where to Find Additional Information
UL 916 Listed products for the Unites States and Canada, Open
Class Energy Management Equipment.
Industry Canada
ICES-003
This is a Class B digital device that meets all requirements of the Canadian
Interference Causing Equipment Regulations.
Topics
University X
Requirements and Specifications
Focus of This Tutorial
3 Our Case Study
3.1 University X
3.1 University X
We are going to install Building Operation as the building management system for
University X. The university is a campus of buildings for which heating and cooling
are supplied from a Central Plant with an underground distribution system. The
case study focuses on the renovation of the Central Plant and the expansion of the
School of Business.
Note
The programs and files that are used for the fictional customer University X are
intended for training purposes only.
3.2.3 Specifications
You find specifications in the Building Operation datasheets for Enterprise Server,
WorkStation, Project Configuration Server, PS-24V Power Supply, Automation
Server, and I/O Module Family.
The functional description for the dampers control program describes the following
requested behavior:
• A single analog output (DprPos) shall be used to control all three AHU
dampers. The position of the OA and EA dampers shall be equal to DprPos.
The position of the RA damper shall be equal to 100 - DprPos. The relationship
between DprPos and the individual OA, EA, and RA damper position shall be
configured within the respective damper actuator.
• The dampers shall be used to provide a free cooling mode when the outside air
temperature (OaTmp) is 1 °C (2 °F) or more below the return air temperature
(RaTmp). When in free cooling mode, the mixed air temperature (MaTmp) is
measured and the dampers shall be modulated to maintain an adjustable
mixed air temperature setpoint. The mixed air temperature setpoint shall be the
same as the supply air temperature setpoint (SaTmpSpt). Under normal
conditions, when the building is occupied, the dampers (DprPos) must never
go below a lower limit defined by an adjustable minimum position value
(MinPos).
• When the outside air temperature is equal to or greater than the return air
temperature, the dampers shall be placed in recirculation mode and shall stay
in this mode until the outside air temperature has fallen to 1 °C (2 °F) or more
below the return air temperature. When the AHU is in recirculation mode, the
dampers (DprPos) shall be set to the minimum position value (MinPos).
• When the AHU is off, the fire signal is active, or the AHU lockout mode is
active, the OA and EA dampers shall be closed, and the RA damper shall be
opened. This requirement means that DprPos shall be set to 0 %.
The dampers control is dependent on the fans being operational. For this reason,
the fans start/stop control program provides a digital interlock value (DprIntlk),
which the dampers control program needs to connect to and read.
The review of the functional description and the previous design work indicate that
the dampers control program will need to connect to the inputs, outputs, and
values shown in the following figure.
The review of the functional description also indicates that there are three control
states for the dampers:
• Control Off
• Free Cooling
• Recirculate Mode
The three control states can be represented in a control matrix, which shows each
of the states and the required output for each state. The dampers control program
needs to reflect the control matrix shown below. To meet the requirement to have
different control states, the program needs to be a looping type program.
Control Off 0%
In our example, you develop the program step by step, by successively refining the
program until all parts of the control matrix are implemented. You check and save
the program after each step to ensure that there are no syntax errors. You also add
comments in the program after each step to document what you have added or
modified.
You first develop the basic framework of the program. You use WorkStation for
Projects to create a Script program. You enter the program code using Script
Editor. You declare the input and output variables, add line labels that represent the
three control states for the dampers, add instructions that set the required damper
output for each state, and add conditional instructions that enables the program to
move from one line label (control state) to the other.
You then refine the program to deal with the requirement that the DprPos output
shall be modulated based on MaTmp and SaTmpSpt when the dampers are in free
cooling mode. To achieve this you use a PID loop function from the Script Editor
code library. You first create a Script function called PIDLoop, open it in Script
Editor, and insert the complete PID loop function from the code library. You then
declare the PIDLoop function in the program and modify the instruction for setting
the DprPos output to call the PIDLoop function instead. You also need to declare
some variables and set their values, which are passed into and out of the PIDLoop
function.
You finish the program by declaring an input variable and by adding and modifying
instructions that ensures that the DprPos output never falls below a lower limit when
the dampers are in the free cooling or recirculation mode. The lower limit is defined
by a minimum position value (MinPos), which can be adjusted outside the program.
Finally, you create the required bindings between the Dampers Control program
and the PIDLoop function, Fan Start Stop program, temperature input points,
temperature setpoint, minimum position value, and voltage output point.
Topics
Logging on to WorkStation for Projects
Opening a Project
Creating a Script Program
Opening a Script Program or Function
Declaring a Variable
Adding a Line
Adding an Instruction
Adding a Comment
Checking and Saving a Script Program
4 Creating and Configuring a Script Program
Our Example
In this chapter, you create a Script program that deals with the easier parts of the
dampers control requirements. The basic framework of the dampers control
program that you develop in this chapter reflects a simplified control matrix, as
shown below. In this control matrix, the damper outputs (DprPos) for the free
cooling and recirculation modes are replaced with temporary values, which are
easier to implement at this stage. You will deal with the remaining and more
complex requirements in the following chapters.
Control Off 0%
You first log on to WorkStation for Projects on the off-site computer and open the
University X Project. You create the new Script program in the Automation Server.
The program is called Dampers Control. You then use Script Editor to enter the
program code.
You declare the required program variables at the beginning of the Script program.
These binding variables will be used to later connect the program to the
corresponding inputs, outputs, and values outside the program.
You add the line labels ControlOff, FreeCooling, and RecirculateMode in the
program to represent the three control states for the dampers. You add an
instruction for each line label that sets the DprPos output for the control state,
according to the above control matrix.
You then add the conditional instructions that will enable the program to move
between the line labels (control states) in response to the changes in the outside air
temperature (OaTmp), return air temperature (RaTmp), and interlock value (DprIntlk)
from the fans start/stop program. The program is a looping type program, which
means the program will continuously execute all instructions that belong to a line
label until the program is instructed to go to a different line label.
Additionally, you add comments to the program.
Finally, you check and save the program to the project database.
Note
The first time you log on to WorkStation for Projects you need to use
the administrator user account to create a project user account. For
more information, see the Creating a Project Configuration Server
User Account topic on WebHelp.
2. In the Password box, type the password. In this example, type “Pete.”
Continued on next page
3. In the Server box, select the hypertext transfer protocol you want to use and
then enter a server name or an IP address. In this example, click HTTPS
and then enter localhost.
4. Select Remember me to have WorkStation for Projects remember your
settings.
5. Click Log on.
To open a project
1. In WorkStation for Projects, in the WorkStation for Projects - Projects
view, select the project that you want to open. In this example, select
University X Project.
4. In the Name box, type a name for the Script program. In this example, type
“Dampers Control.”
5. Click Create.
To declare a variable
1. In Script Editor, declare the variable you want to use in the program or
function:
• Declare the variable using the type keyword Numeric, String, or DateTime
before the name of the variable.
• Declare the variable using the binding keyword Input, Output, or Public
after the type keyword, and before the name of the variable, to enable
bindings to the variable.
In this example, type the variable declarations that are highlighted by the
yellow oval in the following figure.
You have now declared the variables in your Script program or function. These
declarations are then followed by one or more program lines or instructions that
specify the operations to perform.
To add a line
1. In Script Editor, type a line label that is preceded by the Line keyword or
followed by a colon, and then add the instructions that belong to the line label.
In this example, type the line labels and instructions that are highlighted by
the yellow oval in the following figure.
You have now added line labels and instructions in your program.
To add an instruction
1. In Script Editor, type the instruction you want to add. In this example, type
the instructions that are highlighted by the yellow oval in the following figure.
For this example, repeat the procedure to add the If…Then instructions that enable
the program to move from the FreeCooling line label to the other two line labels.
Type the instructions that are highlighted by the yellow oval in the following figure.
Add the If…Then instructions that enable the program to move from the
RecirculateMode line label to the other two line labels. Type the instructions that are
highlighted by the yellow oval in the following figure.
The Dampers Control program should now look like the following figure.
To add a comment
1. In Script Editor, type a single quotation mark (') and then type a comment.
In this example, type the comments that are highlighted by the yellow oval in
the following figure.
You can add a comment at the beginning of the program or function to explain its
purpose. You can also add comments at the end of any statement in a Script
program or function.
Topics
Creating a Script Function
Opening a Script Program or Function
Inserting a Code Library Item in a Script Program or
Function
Checking and Saving a Script Function
Declaring a Variable
Declaring and Calling a Script Function
Adding an Instruction
Adding a Comment
Checking and Saving a Script Program
5 Using a Script Function
Our Example
In this chapter, you refine the Dampers Control program to deal with the
requirement that the damper output (DprPos) shall be modulated based on the
mixed air temperature (MaTmp) and supply air temperature setpoint (SaTmpSpt)
when the dampers are in free cooling mode. You update the program to fulfill the
control requirement that is highlighted in bold in the following table.
Control Off 0%
To achieve the control requirement, you use a PID loop function. The Dampers
Control program calls the function, which calculates the required DprPos output
and returns the result back to program. MaTmp, SaTmpSpt, and the other required
values are passed to the PID loop function through the function call. After the
function has completed its task it shuts down until it is called again.
You first create a Script function in the Automation Server. The function is called
PIDLoop. You enter the code using Script Editor. A complete PID loop function is
provided in the Script Editor code library. You insert the code from the code library
into the PIDLoop function. You check the function before you save it to the project
database.
You then edit the Dampers Control program. You need to declare the PIDLoop
function because the function is external to the program. You modify the
FreeCooling line by replacing the temporary DprPos output value with a call to the
PIDLoop function. You will later create the required binding between program and
the function.
You also need to declare some other variables, which are used to store values that
passed back from the PIDLoop function. You modify the ControlOff and
RecirculateMode lines by adding instructions that set the required values for these
variables.
Additionally, you add comments to document the new instructions.
Finally, you check and save the program to the project database.
4. In the Name box, type a name for the Script function. In this example, type
"PIDLoop".
5. Click Create.
4. Right-click the item and click Insert in editor. In this example, right-click
PIDLoop(Short Version).
The item appears at your insertion point in the Script program or function.
To declare a variable
1. In Script Editor, declare the variable you want to use in the program or
function:
• Declare the variable using the type keyword Numeric, String, or DateTime
before the name of the variable.
In this example, type the variable declarations that are highlighted by the
yellow oval in the following figure.
You have now declared the variables in your Script program or function. These
declarations are then followed by one or more program lines or instructions that
specify the operations to perform.
2. Add the function call. In this example, type the function call that is
highlighted by the yellow oval in the following figure.
You have now declared and called a function in a Script program or another Script
function.
The Dampers Control program should now look like the following figure.
To add an instruction
1. In Script Editor, type the instruction you want to add. In this example, type
the instructions that are highlighted by the yellow oval in the following figure.
For this example, repeat the procedure to add the same instructions to the
RecirculateMode line label. Type the instructions that are highlighted by the yellow
oval in the following figure.
The Dampers Control program should now look like the following figure.
To add a comment
1. In Script Editor, type a single quotation mark (') and then type a comment.
In this example, type the comments that are highlighted by the yellow oval in
the following figure.
You can add a comment at the beginning of the program or function to explain its
purpose. You can also add comments at the end of any statement in a Script
program or function.
For this example, repeat the procedure to add comments at the end of the
instructions you added to the RecirculateMode line label. Type the comments that
are highlighted by the yellow oval in the following figure.
The Dampers Control program should now look like the following figure.
Topics
Declaring a Variable
Adding an Instruction
Adding a Comment
Checking and Saving a Script Program
6 Finishing the Script Program
Our Example
In this chapter, you finish the Dampers Control program. You refine the program to
deal with the requirement that the damper output (DprPos) must never fall below a
lower limit when the dampers are in the free cooling or recirculation mode. The
lower limit is defined by a minimum position value (MinPos), which can be adjusted
outside the program. You update the program to fulfill the control requirements that
are highlighted in bold in the following table.
Control Off 0%
You first declare an input variable, which allows for an adjustable minimum position
(MinPos) for the damper output. This binding variable will be used to later connect
the program to a value that can be adjusted outside the program.
For the FreeColing line label, you modify the instruction for setting the DprPos
output. You use the system function called Maximum to restrict the value of DprPos
to MinPos or greater.
You also modify the corresponding instruction for the RecirculateMode line label by
replacing the temporary value of 0 % with the desired value of MinPos (adjustable).
Additionally, you add comments to explain the purpose of the modified instructions.
Finally, you check and save the program to the project database.
To declare a variable
1. In Script Editor, declare the variable you want to use in the program or
function:
• Declare the variable using the type keyword Numeric, String, or DateTime
before the name of the variable.
• Declare the variable using the binding keyword Input, Output, or Public
after the type keyword, and before the name of the variable, to enable
bindings to the variable.
In this example, type the variable declaration that is highlighted by the
yellow oval in the following figure.
You have now declared the variables in your Script program or function. These
declarations are then followed by one or more program lines or instructions that
specify the operations to perform.
To add an instruction
1. In Script Editor, type the instruction you want to add. In this example, type
the instruction that is highlighted by the yellow oval in the following figure.
For this example, repeat the procedure to modify the instruction that sets the
DprPos output for the RecirculateMode line label so that the AHU is in
RecirculateMode with the output to the dampers at minimum position value
(MinPos). Type the instruction that is highlighted by the yellow oval in the following
figure.
The Dampers Control program should now look like the following figure.
To add a comment
1. In Script Editor, type a single quotation mark (') and then type a comment.
In this example, type the comment that is highlighted by the yellow oval in the
following figure.
You can add a comment at the beginning of the program or function to explain its
purpose. You can also add comments at the end of any statement in a Script
program or function.
For this example, repeat the procedure to add a comment at the end of the
instruction that sets the DprPos output for the RecirculateMode line label. Type the
comment that is highlighted by the yellow oval in the following figure.
Add a comment also at the end of the instruction that sets the DprPos output for
the ControlOff line label. Type the comment that is highlighted by the yellow oval in
the following figure.
The Dampers Control program should now look like the following figure.
Topics
Binding Values in Script Editor Using a Binding Template
Summary
7 Creating Bindings to I/O Points and Programs
Our Example
In this chapter, you create the required bindings between the Dampers Control
program and the PIDLoop function, Fan Start Stop program, temperature input
points, temperature setpoint, minimum position value, and voltage output point.
You create the bindings to establish data flow into and out of the Dampers Control
program. The bindings are needed because the other objects are external to the
program. You use the Bindings view within Script Editor to create the bindings.
To save engineering time, you use binding templates to create the required
bindings. You use a custom binding template named IO Points to create the binding
to the I/O points, and you use the Default name matching template to create the
other bindings.
3. Select the bindings that you want to create. In this example, keep all
bindings selected.
4. Click OK.
5. Verify that all bindings are correctly bound. In this example, verify the
bindings against the table below.
For this example, repeat the procedure to create the bindings between the
Dampers Control program and the I/O points MaTmp, OaTmp, RaTmp, and
DprPos:
• Drag the ...University X ES1/Servers/CPlant AS/IO Bus folder to the IO
Points template.
7.2 Summary
You have now you created and configured a Script program called Dampers
Control, which is used to control the dampers of the AHU. The new program
enables the university to use cool outside air, under certain conditions, for free
cooling of indoor spaces in the School of Business. You created the program off
site using WorkStation for Projects.
The review of the functional description and the previous design work had clarified
the control requirements and connections the program needed to implement. Three
control states were identified: Control Off, Free Cooling, and Recirculate Mode. The
control states and the required damper output for each state were compiled into a
control matrix, which the program needed to reflect.
You developed the program step by step, by successively refining the program until
the control matrix were fully implemented. You checked and saved the program
after each step. You also added comments in the program after each step.
You first developed the basic framework of the program. You used WorkStation for
Projects to create the Script program in the Automation Server. You entered the
program code using Script Editor. You declared the inputs and outputs, added line
labels to represent the three control states for the dampers, added instructions to
set the required damper output for each state, and added conditional instructions
to enable the program to move from one line label to the other.
You then refined the program to deal with the requirement that the damper output
shall be modulated based on the mixed air temperature and supply air temperature
setpoint when the dampers are in free cooling mode. To achieve this, you used a
PID loop function from the Script Editor code library. You first created a Script
function called PIDLoop, opened it in Script Editor, and inserted the complete PID
loop code from the code library. You then declared the function in the program and
modified the instruction for setting the damper output to call the PIDLoop function
instead. You also declared and defined some variables, which are used to store
values that are passed back from the PIDLoop function.
You finished the program by declaring an input variable and by adding and
modifying instructions that deal with the requirement that the damper output must
never fall below a lower limit (an adjustable minimum position value) when the
dampers are in the free cooling or recirculation mode.
Finally, you created the required bindings between the Dampers Control program
and the PIDLoop function, Fan Start Stop program, temperature input points,
temperature setpoint, minimum position value, and voltage output point.
04-15035-01-en
July 2014