0% found this document useful (0 votes)
50 views

PI User Training Manual 2008

This document provides exercises for learning how to use OSIsoft's PI ProcessBook and PI DataLink software. It includes 12 exercises for PI ProcessBook covering basics of the software, building displays and trends, using calculation data sets, ODBC data sets, and Visual Basic for Applications. It also includes 9 exercises for PI DataLink focused on building reports. The exercises provide step-by-step instructions and the objectives for each exercise.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

PI User Training Manual 2008

This document provides exercises for learning how to use OSIsoft's PI ProcessBook and PI DataLink software. It includes 12 exercises for PI ProcessBook covering basics of the software, building displays and trends, using calculation data sets, ODBC data sets, and Visual Basic for Applications. It also includes 9 exercises for PI DataLink focused on building reports. The exercises provide step-by-step instructions and the objectives for each exercise.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 75

Exercises 

PI ProcessBook and PI DataLink 
 

PI Client Fundamentals
Course Workbook
 

Latest Update: October 8, 2008 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 1 
Exercises PI ProcessBook and PI DataLink 
 

Table of Contents

Exercise PB1 ‐ Basics......................................................................................................................................................5 
Exercise PB2 – Building a PI ProcessBook.................................................................................................................... 10 

Exercise PB3 – Building Trends ....................................................................................................................................15 
Exercise PB4 – Inserting static element in displays .....................................................................................................19  
Exercise PB5 – Inserting dynamic element in displays ................................................................................................24  

Exercise PB6 – PI Calculation Data sets .......................................................................................................................27  
Exercise PB7 – ODBC Data sets....................................................................................................................................32 

Exercise PB8 – ODBC Data sets 2 (Optional)................................................................................................................36  
Exercise PB9 – Using Visual Basic for Applications I (Optional)...................................................................................39  

Exercise PB10 – Using Visual Basic for Applications II (Optional)................................................................................42  
Exercise PB11 – Using Add‐Ins (Optional)....................................................................................................................46 

Exercise PB12 – Exporting Displays (Optional) ............................................................................................................48  

Exercise DL1 ‐ Activity Report......................................................................................................................................50 

Exercise DL2 ‐ Inventory Level .....................................................................................................................................54 
Exercise DL3 ‐ Operational Start Up ............................................................................................................................56 
Exercise DL4 ‐ Daily Production ...................................................................................................................................59 

Exercise DL5 ‐ Off‐spec Production..............................................................................................................................61 

Exercise DL6 ‐ Expression Calculation (Archive Value) ................................................................................................63  

Exercise DL7 ‐ Operating Time with Time Filtered.......................................................................................................67  
Exercise DL8 ‐ Tank Level.............................................................................................................................................70 
Exercise DL9 ‐ Advanced Calculated Data (Optional) ..................................................................................................72  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 2 
Exercises PI ProcessBook and PI DataLink 
 
 

PI ProcessBook and PI DataLink Exercises

Introduction

The  following  are  the  PI  ProcessBook,  PI  DataLink  and  RtWebParts  exercises.  Some  of  the  exercises 
cannot be completed unless you have completed the previous ones.  

Solutions are provided at the end of each exercise. All the class material, including data files needed to 
complete  some  of  the  exercises,  can  be  found  at  http://techsupport.osisoft.com  (registration  is 
required). 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 3 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB1 - Basics

Objectives:

• Familiarize yourself with the Common Dialog Windows 
• Familiarize yourself with the PI ProcessBook environment. 
• Learn how to manipulate a trend display using an existing PI ProcessBook. 

Approach:

Follow the task list and try on your own. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 5 
Exercises PI ProcessBook and PI DataLink 
 
 

Exercise PB1A: Exploring the Common Dialog Windows

A. Tag Search Window 

1. Open the Tag Search Window with the ( ) button or with the Tag Search option of the Tools 
menu. 
2. Use b* in the tag mask field and click on the Search button to get all the tags beginning by b. 
3. Click on the first tag name.  Then press the SHIFT key and click on the second tag name.  This will 
select the first two tags.  Click on the Pt. Attr button to access the point attributes of those tags.  
You can move from one tag to another with the arrow keys on your keyboard. 
4. Write * in the tag mask field and *reactor* in the descriptor field, then press Search to find all the 
tags with the string reactor in the descriptor. 
5. Erase the descriptor field and enter 0 (zero) in the Value field, then press Search to find all the tags 
with a snapshot value of 0. 
6. Try to build searches based on multiple search criteria. 

B. Connection Window 

1. Open the Connection Window with the Connections option of the File menu. 
2. Click on Add Server … to add a PI server.  Enter the PI server name specified by the trainer.  Enter 
pidemo as the user name and let the port number at 5450.  Click on OK to create the specified PI 
server. 
3. Highlight this PI Server and click on Connect.  You might be prompted for a password.  If so, enter 
the password specified by the trainer. 

Exercise PB1B: Using PI ProcessBook

Load  the  ProcessBook  called  Pidemo.piw  that  is  located  in  the  installation  directory  (by  default: 
C:\Program Files\PIPC\PROCBOOK).   

• Explore the contents of each tab.  To change from one tab to 
another, simply click on the tab you want to see 
• One at a time, open all 3 displays of the Refinery tab.  To open 
a  display,  you  can  double‐click  on  it  or  click  once  on  the 
display to highlight it and press the Open button.  To close a 
display,  you  can  use  the  Close  option  of  the  File  Menu  or 
press where indicated below.  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 6 
Exercises PI ProcessBook and PI DataLink 
 
Exercise PB1C: Using a trend

Open  the Batch  Reactor  display (see the example below) located on the Refinery tab.  To successfully 


complete this exercise, you must be able to manipulate the Reactor Level trend as follows: 

• Maximize the trend; 
• Zoom in and out of the trend; 
• Go backward and forward in time by one or by several time periods; 
• Change the time scale to 1 day; 
• Find when the maximum value was attained (Hint: use the trend cursor); 
• Revert back to the original time scale. 

Return back to the Batch Reactor display. 

 
 

 
 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 7 
Exercises PI ProcessBook and PI DataLink 
 

Step-by-Step Solution for Exercise PB1C

1. Load the PI ProcessBook file C:\Program Files\PIPC\PROCBOOK\Pidemo.piw.  

2. Take a moment to locate the different components of the menu bar: Title, Menu and Tools.   

3. Open the batch reactor display, (see the example below), located in the Refinery tab. 

4. With the Run mode pointer, display a section of the trend display.  Drag the pointer diagonally to 
draw a rectangle.  This area will be magnified when you release the mouse button.  To return to the 
original time scale, use the View option in the menu bar, then Revert or use this tool ( ). 

5. With the Run mode pointer, expand the trend on the entire display window.  Double‐click within the 
trend. To return at the original time scale, double‐click within the trend again. 

6. Use the time forward and backward buttons to scroll the time range forward or backward on a trend 

( ).  To modify the time range, use the View > Time Range.  Change the time scale to 1 day.   

7. Use a trend cursor to find when the maximum value of the last day occurred (  ). 

8. Return to the original time scale (See step 4). 

9. Alter the Y‐axis scale of a trend by double clicking on the y‐axis.  Use the Trend Scale dialog box to 
change the vertical scale for the tag in the trend.  You do not have to be in Build mode to edit the 
trend. 

10. Return to the original Batch reactor display. 

11. Exit PI ProcessBook without saving. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 8 
Exercises PI ProcessBook and PI DataLink 
 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 9 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB2 – Building a PI ProcessBook

Objectives:

• Learn how to build and modify a PI ProcessBook; 
• Learn the differences between the Run mode and the Build mode; 
• Understand the PI ProcessBook entries hierarchy; 
• Use the Book and Outline views to visualize and modify a PI ProcessBook. 

Approach:

This  section  offers  you  a  guided  tour  of  how  to  create  displays  and  maintain  hierarchy  within  PI 
ProcessBook. You are pleased to go directly to the solution section to start your visit. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 10 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution
You  are  asked  to  create  a  new  PI  ProcessBook  into  which  you  will  insert  new  elements  and  establish 
links to other PI ProcessBook components and applications.  You will also assign a level of hierarchy to 
each element. 

A. Create a new PI ProcessBook using the following steps: 

1. Select File > New. 
2. A new screen appears with three choices: 

∙ ProcessBook (.piw) File; 
∙ ProcessBook Entry; 
∙ ProcessBook Display (.pdi) File.  
3. Select ProcessBook (.piw) File and name it Exercise PB2. 
4. Click on the OK button. A new screen appears with the name Exercise PB2. 
5. Save this ProcessBook with the name Exercise PB2.PIW. 

B. Insert a Text type entry on level 1 and name it Exercises book using the steps below. 

1. In Build mode, select Insert > Text. A new screen appears in which you must supply additional 
information. 
2. Type a label like Exercises book. 
3. As this is your first entry, its hierarchy level is 1 and it may not be modified. 
4. Click on the OK button. A title corresponding to Exercise book appears in the ProcessBook file 
created earlier. 

C. Insert a Display type entry on level 2 and name it Exercise PB2C – Plant Status. 

1. In Build mode, select Insert > Display. A new screen appears in which you must supply additional 
information. 
2. Type a label named Exercise PB2C – Plant Status. 
3. Choose a hierarchy level of 2. 
4. Click on the OK button. This will create and open a display.  You can add a trend into it or simply 
close it by selecting File > Close. 
5. Save the display; it will be saved inside the Exercise PB2.PIW ProcessBook file. A title on the second 
hierarchy level corresponding to Exercise PB2C – Plant Status appears in the PI ProcessBook file 
created earlier. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 11 
Exercises PI ProcessBook and PI DataLink 
 
 

D. Add a Linked Display type entry on Level 3 and name it Exercise PB2D – Batch Reactor. 

1. To link a display from another ProcessBook file, the file must be opened (open the file 
PIDEMO.PIW). 
2. In Build mode, select Insert > Link / OS Command. A new screen appears in which you must supply 
additional information. 
3. Type a label name Exercise PB2D – Batch Reactor. 
4. Choose a hierarchy level of 3. 
5. Press the arrow next to the Browse button and select Display Search. Select the Batch Reactor 
display from the PIDEMO.PIW ProcessBook file. (Hint:  Do not forget to open the ProcessBook 
where the display resides.). 
6. Click on the OK button. This will link the display and open it.  You can close it by selecting File > 
Close. A title on the third hierarchy level corresponding to Exercise PB2D – Batch Reactor appears 
in the PI ProcessBook file created earlier. 

E. Insert a Linked ProcessBook type entry on level 2 and name it Exercise PB2E – External Plant. 

1. In Build mode, select Insert > Link / OS Command. A new screen appears in which you must supply 
additional information. 
2. Type a label named Exercise PB2E – External Plant. 
3. Choose a hierarchy level of 2. 
4. Press the arrow next to the Browse button and select ProcessBook file. Browse to and select the 
PIDEMO.PIW ProcessBook used in exercise PB1. 
5. Click on the OK button. This will link the ProcessBook and open it.  You can close it by selecting File 
> Close. A title on the second hierarchy level corresponding to Exercise PB2E – External Plant 
appears in the ProcessBook file. 

F. Insert an Operating System Command type entry on level 2 and name it Calculator. 

1. In Build mode, select Insert > Link / OS Command. A new screen appears in which you must supply 
additional information. 
2. Type a label named Calculator. 
3. Choose a hierarchy level of 2. 
4. Press the arrow next to the Browse button and select Applications. Browse to select the calc.exe 
file from the c:\winnt\system32 directory for Windows NT4/2000, or c:\windows\system32 
directory for Windows 95/98/XP/ME/2003. 
5. Click on the OK button. This will create the OS command and open the calculator.  You can close it 
by selecting File > Close. A title on the second hierarchy level corresponding to Calculator appears 
in the PI ProcessBook. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 12 
Exercises PI ProcessBook and PI DataLink 
 
 

G. Modify your PI ProcessBook.  Change the order in which the entries appear and modify the hierarchy 
to resemble the next figure. 

1. In Build mode, select View > Outline.  Use the four arrows located in the upper left corner of the 
window. The signs + and – are used to expand or collapse the hierarchy level of the selected 
entry. Numbers 1 – 9 are used to display different levels of hierarchy in the PI ProcessBook. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 13 
Exercises PI ProcessBook and PI DataLink 
 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 14 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB3 – Building Trends

Objectives:

• Build trends. 
• Familiarize students with the different trend building options. 

Problem PB3A Description:

You are now ready to create a trend with PI tags.  To place the trends in the PI ProcessBook you created 
during exercise PB2, you must open the PI ProcessBook and then double click on Display 1 entry. 

The goal of this exercise is to build a trend similar to the figure below using the following steps: 

• Add  a  trend  containing  the  SINUSOID  tag.    Use  the  trend  item  from  the  tool  bar.  (Hint:  make 
sure you are in build mode). 
• Edit the trend to show the last 5 days of values. 
• Edit the trend so the title reads Exercise PB3A. 
• Close the trend configuration and save the file. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 15 
Exercises PI ProcessBook and PI DataLink 
 
 

Problem PB3B (Multiple trends display) Description:

Add  a  new  display  entry  in  the  ProcessBook  you  just  created  in  exercise  PB2.    Place  it  on  level  2  and 
name it Exercise PB3B.  Create three (3) trends arranged per the figure below.  

 
Using Multiple Trends 
Trends show units of each tag as well as their names and descriptions.  Refer to the next characteristics 
to create these trends. 

• Trend 1 displays BA:LEVEL.1 tag with a green color for y‐scale located outside the trend.  
Change the line weight and use a different marker type; 
• Trend  2  displays  BA:CONC.1  tag  with  a  blue  color  for  y‐scale  located  inside  the  trend.  
Change the line style and use a different marker type; 
• Trend  3  displays  CDT158  tag  with  a  yellow  color  for  y‐scale  located  inside  the  trend.  
Change the line weight or line style, and use a different marker type. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 16 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution for Exercise PB3A

1. Open Display 1 display. 

2. In Build mode, use the Trend tool ( ). Drag diagonally to create a rectangular area to contain the 
trend.  When you release the mouse button, the Trend definition dialog box is displayed. 

3. Enter the following information in the General tab: 

∙ Type the trend name in the plot box: Exercise PB3A; 
∙ Use the Tag Search button to locate and select the SINUSOID tag.  To facilitate the query, use a 
mask like SIN*; 

∙ Specify the time range to display the last 5 days in the plot time section by setting the style to Full 
time stamp, the start field to *‐5 Day and the end field to *; 

∙ Click on the OK button to create the trend. 
4. Save the trend object by saving the display using File > Save. 

Step-by-Step Solution for Exercise PB3B

1. Add a new display entry in the ProcessBook you created during exercise PB2, its level will be 2 and 
name it Exercise PB3B.  Refer to exercise PB2 – Building a PI ProcessBook. 

2. In Build mode, use the Trend tool ( ).  Drag the mouse diagonally to create a rectangular area to 
contain the trend.  When you release the mouse button the Trend definition dialog box is displayed. 

3. Enter the following information in the General tab: 

∙ Type the trend name in the Plot box: Trend 1; 
∙ Use the Tag Search button to locate and select the BA:LEVEL.1 tag; 
∙ Click on New Plot button. The plot name is updated to Plot‐1 and there is now no tag in the Tags 
field in Plot area; 

∙ Type the name for the second trend in the Plot box: Trend 2; 
∙ Use the Tag Search button to locate and select BA:CONC.1 tag and click on the OK button; 
∙ Click on the New Plot button; 
∙ Type the name for the third trend in the Plot box: Trend 3; 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 17 
Exercises PI ProcessBook and PI DataLink 
 

∙ Use the Tag Search button to locate and select CDT158, then click on the Display Format tab.  
4. In Display Format: 

∙ Modify display format of Trend 1 to show Y‐scale outside the trend; 
∙ Click on Trace Format tab. 
5. In Trace Format:  

∙ Assign green to Trend 1; 
∙ Assign blue to Trend 2; 
∙ Assign yellow to Trend 3, and then click on Layout tab.  
6. In Layout: 

∙ Enter the trends arrangement: [Row : 1 x Col : 2]  [ExRow : 1 x ExCol : 1].  An overall view is shown 
in the preview area; 

∙ Trends are finished.  Click on the OK button.  It is important to note that the Layout tab will not 
appear after you have edited these trends. Be sure that you have arranged trends properly before 
you exit this configuration screen.  

7. Save and exit the display.  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 18 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB4 – Inserting static element in displays

Objectives:

• Learn to add static elements to your displays. 

Problem Description:

The  goal  is  to  represent  a  process  as  a  schematic  to  make  it  easy  for  all  personnel  to  identify  its 
components.  Drawing tools are available to create schematics. 

In  this  exercise,  you  are  to  create  a  simple  schematic  to  represent  a  tank,  an  agitator  and  a  valve  as 
presented in the figure below.   

Approach:

In the ProcessBook you created in exercise PB2, add a new display entry that will be named Exercise 
PB4.   

• In this display, reproduce the stirred tank drawn below.  If you wish, you can activate the 
Snap to Grid option from the Arrange menu. 
• Using the Symbol Library tool (from the toolbar), create the tank.  If you wish, you can 
modify the color or fill pattern using the Options button of the symbol library.  Select the 
tank category and the Flat vessel 7 symbol. 
• Create the feed and the outlet pipes. 
• Write stirred tank in the tank. 
• Using  the Symbol Library  tool (from the toolbar),  create the agitator.  If you  wish, you 
can  modify  the  color  or  fill  pattern  using  the  Options  button  of  the  symbol  library.  
Select the mixer category and the Mixer blade symbol. 
• Using the Symbol Library tool (from the toolbar), create the valve.  If you wish, you can 
modify the color or fill pattern using the Options button of the symbol library.  Select the 
valve category and the Hand valve 2 symbol. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 19 
Exercises PI ProcessBook and PI DataLink 
 

 
Inserting Static Elements in Displays 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 20 
Exercises PI ProcessBook and PI DataLink 
 
Step‐by‐Step Solution 

1. It can be easier to arrange and align objects when the grid is activated. Select Arrange > Snap to grid 
option.  

2. Draw the tank with by selecting Draw > Symbol Library.  Once this option is selected, use the left 
button of the mouse to select the area where you want the symbol.  Select the tank category, then 
the Flat vessel 7 symbol.  Click on Options if you want to change the color or fill pattern of the tank.  
Note that the color can only be changed if the fill mode is Shaded, Solid or Hollow. 

3. Add the feed and outlet pipes.  

∙ Start by modifying the line width with the Line Width button ( ).  Note that you may also change 
the ending of lines to obtain arrows.  It is possible to draw lines first and change their ends later. 

∙ Draw lines by selecting Draw > Line.  Select the lines and modify their ends with the Line Width 
button.  An option is to use the Poly‐Line button ( ) and draw a line with multiple sections. 

4. Add the agitator in the tank. 

∙ Draw the agitator by selection Draw > Symbol Library.  Once this option is selected, use the left 
button of the mouse to select the area where you want the symbol.  Select the mixer category, 
then the Mixer blade symbol.  Click on Options if you want to change the color or fill pattern of 
the tank.   

∙ Write in the tank: Stirred tank by selecting Draw > Text. 
5. Add a valve on the outlet pipe. 

∙ Draw the valve by selecting Draw > Symbol Library.  Once this option is selected, use the left button 
of the mouse to select the area where you want the symbol.  Select the valve category, then the 
Hand valve 2 symbol.  Click on Options if you want to change the color or fill pattern of the tank. 
You can create the symbol yourself using the basic drawing tools. 

6. Save and exit the display. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 21 
Exercises PI ProcessBook and PI DataLink 
 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 22 
Exercises PI ProcessBook and PI DataLink 
 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 23 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB5 – Inserting dynamic element in displays

Objectives:

Learn how to enhance your displays by adding live elements whose properties change in time.  These 
elements consist of the following ProcessBook objects: 

• Bar Graph; 
• Value of a PI Tag; 
• Multi‐State Symbol; 
• Command Button. 

Problem Description:

Dynamic  elements  allow  displaying  changes  of  operating  conditions  in  time,  which  facilitates  the 
understanding of the use of dynamic elements in schematics. 

With this exercise, you use the display created in exercise PB4, add a level indicator and an alarm display 
(low and high).  Modify the design of the tank so that it graphically shows the level.  

Approach:

Reuse the exercise PB4 to add dynamic elements. To add these elements, follow these steps: 

• Insert a level indicator using the Value tool. 
• Add a low and high visual alarm.  (Draw two circles; then modify their properties using 
Multi‐state Symbol). 
• Write the text associated with each alarm as shown in the figure below. 
• Create a bar graph over the tank body and make it the same size as the tank.  This might 
be easier if the Snap to Grid option of the Arrange menu is not activated. 
• Insert a command button in your display from the button icon.  A configuration dialog 
box appears.  In the text item, enter Calculator.  Select Operating system command as 
its type.  Finally, in the action item, enter the command line that will start the calculator 
(Typically: C:\WINDOWS\SYSTEM32\CALC.EXE or C:\WINNT\system32\calc.exe). 
• Keep  the  propeller  and  the  text  inside  the  tank,  in  front  of  the  bar  graph.    (Hint:  use 
Arrange > Bring to front). 
• Save the display you created in PDI format with Exercise PB5.PDI by selecting File > Save. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 24 
Exercises PI ProcessBook and PI DataLink 
 

 
Inserting dynamic Elements in Displays 
 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 25 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the display created in exercise PB4. 

2. Insert a level indicator. Select Draw > Value to insert the BA:LEVEL.1 tag value.  Write Level (%) above 
the value by selection Draw > Text.   

3. Add a low and high visual alarm. 

∙ By selecting Draw > Ellipse, draw two small circles, they will be activated to become visual alarms; 
∙ In the Build mode, select the high‐level circle and then click on Multi‐State button ( ).  Select 
BA:LEVEL.1 tag.  Set the number of states to 2.  Define the limit of the first state to <= 90.  Set the 
color of the first state to green, and second state to red; 

∙ Repeat the same thing to add the low‐level alarm using the same tag.  Set the number of states to 
2.  Define the limit of the first state at <= 10.  Set the color of the first state to red, and second 
state to green. 

4. Create a bar graph to replace the tank. 

∙ Use Draw > Bar to create a bar graph.  Draw a rectangle over the tank body and make it the same 
size as the tank body.  This might be easier if the Snap to Grid option of the Arrange menu is not 
activated; 

∙ Set the graph’s parameters.  Select the BA:LEVEL.1 tag.  Keep the default values of upper and lower 
limits, and the start value.  Click on the OK button to complete the bar graph; 

∙ In Build mode, right‐click on the Bar Graph and choose Format Color.  Choose the proper fill color.  
Use None for the background and line color. 

5. Move the agitator drawing on the bar graph. Use the Bring to front option from the Arrange menu to 
move the agitator out from under the bar graph. 

6. Add a command button Calculator. Use Draw > Button to add a command button.  In the Define 
Button dialog box, put in a name for the button: Calculator. In the action item, enter the command 
line that will start the calculator.  You will find the calculator (calc.exe) in the 
C:\WINDOWS\SYSTEM32 or C:\WinNT\system32 according to the operating system used.  

7. Save your display as PDI file with the Save as option. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 26 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB6 – PI Calculation Data sets

Objectives:

• Learn how to use dynamic elements based on data sets; 
• Learn how to obtain statistics from PI data archives; 
• Learn how to define equations with PI points. 

Pre-requisites:

The following items must be installed on your system: 

• LabData_2008.MDB (a Microsoft Access data file); 
• The ODBC Data Source configured in your system; 
• ODBC tags.xls (with the PI‐SMT menu in Microsoft Excel). 

The last element in the above list reflects three tags that must be created for this exercise to work.  You 
can  create  them  individually  or  use  the  free  SMT  download  Tag  Configurator  for  Microsoft  Excel  to 
export them into your PI database.  Each of these tags makes use of standard interfaces and needs only 
be created to begin functioning.   

Problem PB6A Description:

In  the  ProcessBook  you  created  in  exercise  PB2,  add  a  new  trend  on  the  hourly  minimum  value, 
maximum value and the tank level average for the last 12 hours. The trend shows stair step trace. Also, 
add a value item to show the percentage of good values. Use the SINUSOID PI tag to do this exercise.  
The figure below illustrates the resulting trend. 

Problem PB6B Description:

Two different products (A and B) feed a tank.  You want to illustrate in a trend the product’s percentage 
use  per  30  minutes.    The  synchronization  of  the  calculations  starts  at  00:00:00  AM  (every  30  minutes 
starting at midnight).  The trend willshow the results for the last 8 hours in a stair step trace.  Use the 
tag name CDT158 as product A and BA:TEMP.1 as product B.  Define a column named %Product A for 
the results of the calculation.  Use the following expression:  

'CDT158'*100/('CDT158'+'BA:TEMP.1')
Place the trend in a new display entry named DataSet2 in the ProcessBook created in Exercise PB2.  The 
figure below presents the resulting trend. 

Add  a  tank  (static  drawing  +  bar  object)  that  will  show  the  two  products  at  the  inlet  and  the  usage 
percentage of product A at the outlet.  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 27 
Exercises PI ProcessBook and PI DataLink 
 

 
Tank level display 
 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 28 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution for Exercise PB6A

1. Create a new display type entry titled DataSet1 in the ProcessBook you created in Exercise PB2 and 
open it. 

2. Create a data set by following Tools > Data Sets > New > PICalculation. 

3. Enter the following parameters in the PI Calculation Data dialog: 

∙ Name: Level 
∙ Description: Tank level  
∙ Refresh interval: 1 min 
∙ Step Plot: yes 
∙ Server: select a server 
∙ Tag name: SINUSOID 
∙ Interval: 1 h 
∙ Synchronization: 00:00:00 
4. Build a new trend named Tank level. Click PI Calculation from the dropdown menu to select the 
curves. 

5. Select the data set you just created. Select the Average, Minimum and Maximum columns by holding 
down the CTRL key.  Return to the Define Trend dialog by clicking on the OK button. 

6. Set the plot time: 

∙ Start: *‐12h; 
∙ End: *. 
7. Set the display and trace formats as you want and click on the OK button. 

8. Add the percent good values by selecting Draw > Value. 

9. Click on the PI Calculation button from the dropdown menu and choose the PctGood column. 

10. Set the value’s format to general; select a tag name position from the drop‐down list and click on the 
OK button. 

11. Save the display in PDI format. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 29 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution for Exercise PB6B

A. Add Trend 

1. In the PI ProcessBook of exercise PB2, create a display type entry named DataSet2 and open it. 
2. Create a data set by following Tools > Data Sets > New > PICalculation. 
3. Enter the following parameters in the PI Calculation Data dialog: 

∙ Name: ProductA 
∙ Description: % Product A 
∙ Refresh interval: 1 m 
∙ Step Plot: yes 
∙ Server: select a server 
∙ Expression: 'CDT158'*100/('CDT158'+'BA:TEMP.1') 
∙ Interval: 30m 
∙ Synchronization: 00:00:00 
∙ Column: %ProductA 
4. Create a new trend named % Product A.  Click on PI Calculation on the dropdown menu. 
5. Choose the data set Product A and select the column %ProductA.  Return to the Define Trend 
dialog. 
6. Set the plot time: 

∙ Start: *‐8h; 
∙ End: *. 
7. Set the display and trace formats as you want and click on the OK button. 

B. Add Tank 

1. Draw a tank with two inlet pipes and an outlet pipe as seen in the figure below. 
2. Type the products’ names and add the CDT158 tag value as product A and the BA:TEMP.1 tag 
value as product B. 
3. Type %ProductA = at the tank’s outlet and add the value and the timestamp of column %ProductA 
of the Product A data set. 
4. Save the Display and the PI ProcessBook. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 30 
Exercises PI ProcessBook and PI DataLink 
 

 
Trend « % Product A » 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 31 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB7 – ODBC Data sets

Objectives:

• Demonstrate your ability to construct an ODBC Connection and an ODBC Data Set. 

Problem Description:

You  want  to  trend  test  values  from  a  database  used  and 
maintained  by  your  laboratory  that  looks  like  the  right  upper 
figure. 

Approach:

We will use an ODBC data set that uses a SQL Query 
to  filter  the  data  from  the  lab  database.    In  that 
query,  we’ll  use  placeholders  to  send  the  start  time 
and  end  time  of  the  graph  through  with  the  SQL 
query.    As  the  trend  updates,  the  query  will  update 
automatically. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 32 
Exercises PI ProcessBook and PI DataLink 
 
Step-by-Step Solution

1. Create a new ProcessBook display and select Tools > Data Sets > New > ODBC. 

2. Enter a name and a description for the new data set 

3. Choose LabData from the Data Source list (if LabData is not available in the choice list, you will have 
to create it to point to LabData_2008.mdb). 

4. Next we have to build the query; you can type it manually or use the Microsoft Query application (if 
available) by clicking on the Design… button. The request is built as follows: 

SELECT
TEST_DATA.TIME_TAKEN, TEST_DATA.VALUE
FROM
TEST_DATA
WHERE (TEST_DATA.TIME_TAKEN >= ?
AND TEST_DATA.TIME_TAKEN <= ?)
The screen resembles the figure below. 

5. The question marks represent Parameters which will be fed from PI ProcessBook itself.  In the query 
above, we wish to look for data beginning at the start time of the trend and ending at the end time of 
the trend.  Hit the Placeholders button to define how each of the question marks will be treated. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 33 
Exercises PI ProcessBook and PI DataLink 
 
Placeholder 1 must be set as Type=Start Time (don’t forget to press Set button after choosing this type 
from the dropdown list) and Placeholder 2 will be Type=End Time.  Parameters will appear to you as 
presented next on the figure below. Click on the OK button. 

6. Hit Check Syntax, PI ProcessBook will test the query and once it finds it syntactically correct, it will 
allow you to click on the OK button. 

7. Back on the blank display, create a trend (use the last 24 hours as a range) using the data set you just 
created.  Trend the Value element. 

Note:

Notice here that we can edit the data set (SQL query, placeholders, etc.) from this window; if we do so it 
will be edited for all elements that use it. 

8. Hit the OK button, finish the trend as usual and the data from the Access database will now be visible 
in your trend – you can mix it with PI Data if desired! 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 34 
Exercises PI ProcessBook and PI DataLink 
 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 35 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB8 – ODBC Data sets 2 (Optional)

Objectives:

• Demonstrate the ability to construct an ODBC Connection and data set.  In this exercise quality 
specifications for various grades of paper are stored in an Access database. 

Problem Description:

The control system reports the current grade of paper to PI 
as a tag named GRADEINDEX. This number can change from 
0  to  10  depending  on  the  current  grade  of  paper.  Each 
grade  has  its  own  target,  high  reject  limit,  and  low  reject 
limit.    These  specifications  are  stored  in  a  database 
maintained by the laboratory, LabData_2008.mdb, and the 
table that interests us looks like this. 

Approach:

The purpose of this exercise is to retrieve the laboratory specs from MS Access, conditionally based on 
the value of the grade index tag (GRADEINDEX).  We will then compare the current values of a tag called 
BASISWEIGHT to those upper and lower limit specifications.  By doing this, we can trend the real‐time 
basis  weight  and  at  the  same  time  show  what  the 
target  basis  weight  and  reject  limits  were  as 
different  grades  of  paper  were  made  on  the  same 
machine. 

This  time,  we’ll  set  up  a  placeholder  based  on  a  PI 


Tag:  GRADEINDEX.    That  tag  name  will  be  passed 
along  with  the  SQL  query  so  that  the  proper  specs 
are retrieved for the proper product. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 36 
Exercises PI ProcessBook and PI DataLink 
 
Step-by-Step Solution

1. Open a new display file. 

2. We need to define a new data set.  Select Tools > Data Sets… > New > ODBC. 

3. Define a new data set using these parameters: 

∙ Name:  SpecsByGrade; 
∙ Description:  Specs retrieved by grade index; 
∙ Data Source: Select LabData from the dropdown list.  It will be already set up on your machine. 
4. Next we need to define the query.  Enter the following SQL query: 

SELECT
SPECS.LOWER_LIMIT, SPECS.LOWER_REJECT,SPECS.TARGET,
SPECS.UPPER_LIMIT, SPECS.UPPER_REJECT
FROM
GRADES GRADES, SPECS SPECS
WHERE
SPECS.GRADE_CODE = GRADES.GRADE_CODE
AND GRADES.GRADE_INDEX = ?
5. Note the single placeholder ? this will provide the value of the current grade from the control system. 
Once the placeholder has been defined, hit OK and check the syntax of the query.  PI ProcessBook 
will tell you that everything is fine.  The data set is ready to use. 

  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 37 
Exercises PI ProcessBook and PI DataLink 
 
6. To build the trend, we’ll select ODBC from the dropdown menu in the Trend Definition Window.  Use 
the CTRL key with the mouse to target and the limits.  We’ll also add the real tag for the basis weight 
(tag name:  BASISWEIGHT) to the trend.  The trend definition is as follows: 

Note:

How the order of the items will control how they are ordered in the list on the trend control. 

7. Once you have defined the trend, hit OK and you will see a powerful trend of real‐time data mixed 
with specification data! 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 38 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB9 – Using Visual Basic for Applications I


(Optional)

Objectives:

• Add functionality to your ProcessBook displays by using Visual Basic for Applications; 
• Program a function that runs automatically when a new value is received by PI ProcessBook. 

Problem Description:

You want to monitor the level of the reactor created in previous exercises and notify an operator if the 
level gets too high or too low.  Also, the operator is to enter a comment when the level is too high or too 
low and to display the comments. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 39 
Exercises PI ProcessBook and PI DataLink 
 

Step-by-Step Solution

1. Open the display from Exercise PB5 and save it as Exercise_PB9.PDI.  

2. Insert the Microsoft Forms 2.0 listbox control (ActiveX) in your display.  To do so, insert control by 
selecting Draw > Control and select a region on the display in which you wish to insert it 
(approximately: 3 inches wide by 2 inches high). 

3. In Build mode, select the new control and show its properties by clicking the right button on the 
mouse.  Note the control name that is used in the VBA function.  

4. To add visual basic code to your display, you must enter in the Visual Basic Editor.  To do so, select 
Tools > Macro > Visual Basic Editor.  

5. Select THISDISPLAY in the VBA project.  To insert code, go to View > Code. 

6. In the GENERAL drop‐down list, select the Value object.  In the Event drop‐down list, select 
DATAUPDATE.  All the code that will be written in this procedure will be executed when a new value 
appears in the Value object. 

7. The first step in building your procedure is declaring the variables. 

'Variable declaration
Dim sngValue As Single
Dim strComments As String
Dim dtmDateTime As Date
Dim strDateTime As String
Dim strAddLine As String

8. The next step is to obtain the latest value. 

'Obtain latest value


sngValue = Value1.GetValue(Now(), 0)
'Format value Format Fixed - 0.00)
sngValue = FormatNumber(sngValue, 2)

9. The last step is to add the code to verify if we are in alarm conditions.  If so, you need to prompt the 
user for a comment.  Finally, we add the timestamp, value and comment in the list box: 

'Verify alarm limits


If sngValue > 90 Or sngValue < 10 Then
'If value is in alarm the user is prompted for a comment.
strComments = InputBox("Enter a comment", "Value out of Spec")

'Get current date and time


dtmDateTime = Now()

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 40 
Exercises PI ProcessBook and PI DataLink 
 
'Format date and time to PI time stamp format
strDateTime = FormatDateTime(dtmDateTime, vbGeneralDate)

'Concatenate together Timestamp, value and comment


strAddLine = strDateTime & " " & sngValue & " " & strComments

'Add information to list box


ListBox1.AddItem (strAddLine)

'Check if the list box has more than 10 items


If ListBox1.ListCount > 10 Then
'If the list box has more than 10 items then remove the first
item
ListBox1.RemoveItem (0)
End If

End If

10. Close the VBA Editor. 

11. Each time the value is outside the specified limits, an input box appears to notify that a value is out 
of spec and to enter a comment. Save the display. 

 
Level Supervision 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 41 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB10 – Using Visual Basic for Applications II


(Optional)

Objectives:

• Add functionalities to PI ProcessBook by using Visual Basic for Applications; 
• Change the display showing when in Run mode. 

Problem Description:

Modify the Exercise_PB10_Template.PDI file in order to allow the addition or removal of a curve from a 
trend without going into the Build mode. 

The three functions required are already included in the Exercise_PB10_Template.PDI file, but they are 
incomplete.  To complete them, Visual Basic code needs to be added. 

Approach:

Complete missing Visual Basic code from the template file. To add visual basic code to controls already 
include you must use the Visual Basic Editor.  To do that, select View > Code. 

Select THISDISPLAY in the VBA project.  To insert the code, select the Code item in the View menu. 

In the procedure cmdAddTag_Click(), add the code that allows the addition of a curve to the trend.  
When the button Add a curve is selected this procedure associates the tag name, located in the text box, 
to a new curve. The tag name must be preceded by the PI server name, example: \\NT08\BA:CONC.1.  
Use the Tag Search tool to validate the proper syntax of a tag name. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 42 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Add cmdAddTag_Click() method and set up the task like this: 

Private Sub cmdAddTag_Click()

' Variables declaration


Dim intCount As Integer
Dim txtTagName2 As String

'Errors verification
On Error GoTo ErrorVBA

'Capture of the tag name in the text box


txtTagName2 = Me.txtTagName.Text

'Capture of the number of curves


intCount = Me.Trend.TraceCount

'Verify if the number of curves is greater than 7


If intCount > 7 Then
MsgBox "Maximum number of curves is reached",
vbInformation
'Add the curve
Else
Me.Trend.AddTrace (txtTagName2)
End If
Exit Sub

'Error Handling
ErrorVBA:
Select Case Err
Case 8322
MsgBox "Invalid tag name", vbInformation
Resume Next
Case Else
Call MsgBox("Error appends", vbInformation)
Resume Next
End Select
End Sub

2. In the procedure cmdRemoveFirst_Click(), add the code that allows the removal of the first curve in 
the trend.  This procedure is executed when the Delete first curve button is clicked.   

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 43 
Exercises PI ProcessBook and PI DataLink 
 
Private Sub cmdRemoveFirst_Click()

'Variables declaration
Dim intCount As Integer

'Count the number of curves in the trend


intCount = Me.Trend.TraceCount

'Verify if there is more than one curve in the trend


If intCount > 1 Then
'Remove the first curve
Me.Trend.RemoveTrace (1)
Else
MsgBox "You cannot remove the last curve", vbInformation
End If
End Sub

3. In the procedure cmdRemoveLast_Click(), add the code that allows the removal of the last curve in 
the trend.  This procedure is executed when the Delete last curve button is clicked.  

Private Sub cmdRemoveLast_Click()

'Variables declaration
Dim intCount As Integer

'Count the number of curves in the trend


intCount = Me.Trend.TraceCount

'Verify if there is more than one curve in the trend


If intCount > 1 Then
'Remove the last curve
Me.Trend.RemoveTrace (intCount)
Else
MsgBox "You cannot remove the last curve", vbInformation
End If
End Sub

4. Close the VBA Editor. 

5. Save your display in PDI format (Exercise PB10.PDI) by using File > Save As. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 44 
Exercises PI ProcessBook and PI DataLink 
 

 
Modifying a Trend in Run Mode 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 45 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB11 – Using Add-Ins (Optional)

Objectives:

• Use an ActiveX Control in a ProcessBook Display. 

Problem Description:

You  need  to  have  a  method  of  manual  entry  for  your  user.    Create  a  new  display  file  and  insert  the 
ActiveX Control given by the instructor into your display. Create a trend or dynamic value to show the 
values. 

Pre-requisites:

 You will need to create a manual entry tag to accept the values.  Normally this tag would be created by 
your system manager. The first step is to create a simple tag to use for the example.  We suggest for the 
purposes of this exercise that it is a tag with pointsource = L,  tagname = MyManualTag, and read/write 
data access for the user pidemo. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 46 
Exercises PI ProcessBook and PI DataLink 
 

Step-by-Step Solution

1. Install the control.  The instructor will show you where the installation kit is located. 

2. Open a new display.   

3. In Build mode, select Draw > Control.  Trace a rectangle by 
pressing the left mouse button.   

4. Select OSIDevNetManualInput.PIManInpt.  If the control is not 
there, you can find it at this URL: http://osidn.osisoft.com, 
within the ActiveX Controls section under the name Manual 
Point Data Entry Control v2.3. 

5. In Build mode, right‐click the inserted control and select Properties. 

6. Enter the point name used earlier in the PITagname field.  Close this window and put PI ProcessBook 
into Run mode. 

7. You can now enter combinations of tag values and timestamps to write into the database. 

8. Trend the tag and enter some values.  The final result will appear as the example pictured below. 

s  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 47 
Exercises PI ProcessBook and PI DataLink 
 

Exercise PB12 – Exporting Displays (Optional)

Objectives:

• Convert a ProcessBook Workbook file into a form usable for PI ActiveView or other web 
client. 

Problem Description:

You  need  to  deploy  the  ProcessBook  Workbook  file  across  your  organization.    The  organization  has 
elected to use PI ActiveView instead of PI ProcessBook.  Break apart your workbook file for posting on 
the web server. 

Pre-requisites:

PI ActiveView software must have installed prior to this exercise. 

   

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 48 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the PIDEMO.PIW file, located in the \PIPC\Procbook folder. 

2. Open the file EXPORT.PDI, located in the\PIPC\AcView\WebDev to extract the individual components 
to the temporary directory C:\Activeview as shown below.  Click through any errors you may get, as 
they can be repaired later. 

 
If you browse to your destination directory you will find three types of files: 

• The display (.pdi) files from the workbook (.piw) file separated ; 
• .htm wrapper files; 
• A graphic file for the links. 

PI ActiveView creates a simple frames page that will hold your display files and a menu file containing 
the links.  Open the PBHome.htm file to see your ProcessBook displays in a browser. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 49 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL1 - Activity Report

Objectives:

Learn to extract single values from the PI database using the following functions: 

• Current value; 
• Archive value; 
• Tag attribute. 

Problem Description:

Use the PI add‐in to extract single value data from the PI archive: 

• Using the items in the PI menu; 
• Entering the formulas manually (optional).  

Approach:

We will use the Current Value, Archive Value and Tag Attribute features to fill in a template of an activity 
report. Remember that we should base our PI DataLink queries on cell references whenever possible. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 50 
Exercises PI ProcessBook and PI DataLink 
 

Step-by-Step Solution

1. Open the file Exercise_DL1_Template.xls. 

2. To find the tag description of the tag whose name is in the cell A7 you need to follow these steps: 

a. Click on the cell B7. 
b. Select PI > Tag attributes… 
c. Fill the field Tagname by selecting the cell A7. 
d. Select Descriptor from the attribute field (selected by default). 
e. Click on the OK button. 
To find the tag description of the other tags (whose names are in cells A8, A9, A10 and A11), repeat 
what you did for the last tag.  

Note:

 You can save some time in PI Datalink by selecting a range of cells instead of a single cell.  In this 
example, the Current Value, Archive Value, and Tag Attribute functions allow you to select multiple tags.  

3. Repeat step 2 and add the engineering units in column C.  Select the engunits attribute from the Tag 
Attribute function. 

4. In column D and E, display the current values time stamp for all five tags.  Click on cell D7 and select 
PI > Current value…  Use the Tagname field and select cell A7.  Also, check Time at left option then 
click on the OK button. 

5. In the second table of the template, use PI > Archive value….  Place the cursor in cell B19 and use the 
interpolated for retrieval mode.  In the tag name, select a range from A19 to A23 and cell D14 as 
timestamp.  Finally, check the Time at left option, and then press on the OK button. 

6. Repeat step 5 for the previous and next retrieval modes, respectively, in cells D19 and F19. 

7. Again from PI > Archive value… use the Exact time for Retrieval mode in cell H19.  Select cell H14 as 
timestamp then press OK.  With exact time retrieval mode, a timestamp is not returned. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 51 
Exercises PI ProcessBook and PI DataLink 
 
 

Note 1:

Notice that you can use the PI Data Link Functions without the dialog box.  Simply type in the formulas 
as follows: 

Tag attribute: 

Syntax     =PITAGATT("TAGNAME","NAMEOFATTRIBUTEYOUWANT","PISERVER")

Example  =PITAGATT($A$7,"DESCRIPTOR",)OR =PITAGATT("SINUSOID","UNITS",)

Current Value:  

Syntax    =PICURRVAL("TAGNAME",OUTCODE, "PISERVER")

Example  =PICURRVAL($A$7,1,)

Archive value:  

Syntax    =PIARCVAL("TAGNAME","DATE",OUTCODE, "PISERVEUR","MODE")

Where MODE = Interpolated or previous or next 

Example  =PIARCVAL($A$7,$D$13,1,, "INTERPOLATED")

Exact Time Value:  

Syntax    =PIEXTIMEVAL("TAGNAME","DATE","PISERVER")

Example  =PIEXTIMEVAL($A$7,$H$25,)

Note 2:

We have seen that it is possible to enter a formula by entering one tag at a time (step 2).  However, it is 
possible to save time by selecting a tag name range instead of a single tag name (step 5).  Finally, the 
copy/paste function of MS Excel can also be used.  You must edit the formula and remove any 
unnecessary $character (absolute cell references) before using MS Excel copy/paste function. 

Note the impact of the point type and step attributes when you use archive value.  For digital tags, the 
interpolated and previous values are equal and have the same timestamp because no interpolation is 
possible between states. 

Finally, note the importance of the engineering units in a report.  Without them, it is difficult for other 
users to decipher the report. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 52 
Exercises PI ProcessBook and PI DataLink 
 

 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 53 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL2 - Inventory Level

Objectives:

Learn to extract multiple values from the PI database using the following 
functions: 

• Sampled data; 
• Compressed data (start time/end time). 

Problem Description:

Plot  the  level  of  a  tank  in  time  for  a  10‐hour  period,  using  the  PI  add‐in  and 
generate  a  report  like  the  one  below.  You  will  use  the  PI  menu,  enter  the 
formulas  manually.  What  is  the  difference  between  sampled  data  and 
compressed data? 

Approach:

We  want  to  see  the  same  data  represented  two  ways.    We’ll  start  by  importing  the  values  at  evenly‐
spaced interpolated values and then we’ll bring in the real values.  Finally, we’ll graphically compare the 
two. 

Note:

There is a fundamental difference between sampled data and compressed data.  When the Sample data 
function is used, the PI add‐in calculates a value by linear interpolation.  When the Compressed data 
functions are used, the series of archived events that represent the time range are retrieved.   

All PI functions from the add‐in do linear interpolations, with the exception of: Archive Value (Exact 
time), Compressed Data (start time/end time), Compressed Data (start time/number). 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 54 
Exercises PI ProcessBook and PI DataLink 
 
Step-by-Step Solution

1. Open the file Exercise_DL2_Template.xls. 

2. Use the Sampled data function to fill in the section entitled sampled data.  Enter the tag name, the 
start date & time, the end date & time and the time interval.  You can either type the value yourself 
(e.g.: SINUSOID for the tag name) or type in/reference the field (e.g.: $B$2 for the tag name). Don’t 
forget to check the Show timestamps checkbox, so that the time stamps will be inserted in the first 
column. 

3. Fill the other section using Compressed data (start time/end time) function.  Note that this time you 
do not have to enter a time interval.  Check the Hide count check box. 

Optional:  To enter the Sampled Data function manually, clear the data you entered in steps 1 and 2.  
Since the sampled data call returns a series of cells, it uses an MS Excel Array Function, which must be 
handled differently: 

1.  Select the range (rows and columns) where the result will appear and type:  

=PISAMPDAT("TAGNAME","STARTDATE","ENDDATE","TIMEINTERVAL",DISPLAYCODE,)

2.  Press CTRL+SHIFT+ENTER simultaneously to effect the changes in the edited cell in the selected 
range of cells. 

 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 55 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL3 - Operational Start Up

Objectives:

• Learn to retrieve process data using the Compressed Data (start 
time/number) function. 

Problem Description:

Your start up every morning needs to be monitored for the correct action. It is 
critical that the values be monitored during this period of time.  First shift starts 
every morning at 6:30 am.  You want to create a spreadsheet that will show you 
the values every morning for your unit.  You would like to compare that to the 
previous day’s values. 

Approach:

We need to create a spreadsheet that will show the first 30 values of the day for the tag CDT158.  We 
also want to compare those values with the previous day’s starting 30 values. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 56 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the file Exercise_DL3_Template.xls. 

2. Get the latest 30 values from the PI Server for the tag CDT158 beginning at 6:30 am the previous day.  
Select cell A10 and use the Compressed data (start time/number) function with cell references for 
Tagname(s), Start Time, and Number of Values.  Be sure to check the show timestamps checkbox. 

3. Select cell D10 and perform the same query, substituting Yesterday’s Start Time with Today’s Start 
Time. 

4. Compare the two columns using the formula (in cell G10): 

=E10/B10
5. Drag this formula down to fill all 30 rows with data. 

6. Use the formula below to make a value judgment about the deviation beginning in cell I10.  Values 
with a deviation greater than 10 percent over/under the previous days’ values will be reported as 
“over range” and “under range.”   

=IF (E10/B10 < 0.90, "under range", IF (E10/B10 < 1.10,


"nominal", "over range"))
7. Drag this formula down to fill all 30 rows with data. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 57 
Exercises PI ProcessBook and PI DataLink 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 58 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL4 - Daily Production

Objectives:

• Learn to extract calculated values using Calculated data function. 

Problem Description:

You are the production manager and want to create a report showing last week’s 
daily  production  totals.    You  want  to  display  the  total  production,  average, 
minimum and maximum and standard deviation for that week.  Also, you would 
like to present this data on a daily basis. 

Approach:

We’ll use the built‐in PI Calculated Data functions to show the above stats for the entire week (no time 
interval needs to be specified) and each day of the week (time interval of 24h).  

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 59 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the file Exercise_DL4_Template.xls. 

2. First, fill out the Weekly Total section of the report.  Select the cell B16 and use PI > Calculated Data 
to get the total.  Fill out the dialog box with this information: 

∙ Tagname: Cell $B$3 
∙ Start time: Cell $B$4 
∙  End time: Cell $B$5; 
∙ The interval argument here is not needed, as we need a single result for the time range. 
Note:

For totals you must select the appropriate conversion factor.  As shown in the template, units are GPM 
(gallons per minute).  As PI will assume the rate is in units/day, a conversion factor of 1440 minutes/day 
needs to be applied. 

3. Find the average, minimum, maximum and the range for that week by repeating step 1 and modifying 
the calculation mode.  For the last calculation in the section (range) check the show percent good 
option to check that the data existed for the whole calculation period. 

4. For the daily production section repeat step 1 and 2, but include a time interval of 1 day (select the 
cell reference). 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 60 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL5 - Off-spec Production

Objectives:

• Learn  to  apply  filters  to  select  the  values  to  extract  using  the  Filter 
Expression option of the Sampled data function. 

Problem Description:

As  a  quality  control  manager,  you  need  to  know  when  the  on‐line  analyzer 
detects an off‐spec product.  Apply a data filter to generate a report like the one 
below that will show only off‐spec readings for a given period of time. 

Approach:

Use PI Datalink’s Sampled Data function to get evenly spaced data.  Because we 
only want to see data that are outside of the norm, we’ll apply filters to show high values, low values, 
and a list including both. 

Note 1:

The MS Excel Today() function returns the serial number of the current date.  The serial number is the date‐time code 
used by Microsoft Excel for date and time calculations.  Microsoft Excel stores dates as whole number of days starting at 
1900.  Dates and times are values and therefore can be added, subtracted, and included in other calculations.  

Syntax:    =TODAY()

Example:     =(TODAY() –10 + 16/24) is today minus 10 days at 4 PM 

When you enter a date in Microsoft Excel 97 and you enter only two digits for the year, Microsoft Excel enters the year 
as follows: The years 2000 through 2029 if you type 00 through 29 for the year.  For example, if you type 5/28/19, 
Microsoft Excel assumes the date is May 28, 2019.The years 1930 through 1999 if you type 30 through 99 for the year.  
For example, if you type 5/28/91, Microsoft Excel assumes the date is May 28, 1991. 

Note 2:

For PI 2 users:  you must use the short tag name rather than the long tag name in the syntax of your filter expression.  

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 61 
Exercises PI ProcessBook and PI DataLink 
 
Step-by-Step Solution

1. Open the file Exercise_DL5_Template.xls. 

2. Enter time information using the Today() function. 

3. Type the following filter expressions for the Lower and Upper limit.   

∙ For the upper limit, type: ''TAGNAME' > 70 where TAGNAME is the tag to filter on; 


∙ For the lower limit, type: ''TAGNAME' < 1 where TAGNAME is the tag to filter on. 
The apostrophe is a special character in MS Excel which indicates a string.  This is why 2 apostrophes are 
needed before the first tag name.  The first one is removed by MS Excel. 

4. Fill the Above specification and Below specification sections using Sampled data.  When the pop‐up 
window appears, fill the section entitled Filter Expression using the filters you entered in step 3. 

5. Use the CONCATENATE function of MS Excel to build a filter expression that will return both the 
above and below specification values. Use an OR logical operator between the upper and lower 
limits.  The expression is the following: 'TAGNAME' < 12 OR 'TAGNAME' > 70 

=CONCATENATE(B7," Or ",E7)

 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 62 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL6 - Expression Calculation (Archive Value)

Objectives:

• Learn to carry out a calculation for the current value of an expression; 
• Use MS Excel’s Conditional Formatting to make your PI Data Link reports 
more useful. 

Problem Description:

As a Shift Team Leader in a bottling plant, you want to produce a real time report 
that shows the average speed of the bottle filler for the past hour.  You also wish 
to compare this average to the average of the 3 hours before, to know whether 
you are positively impacting production speed for your shift or not. The speed of 
the bottle filler is measured by the tag SINUSOID. 

Approach:

Using the built‐in function TagAvg, calculate and display the average for the filler speed tag (SINUSOID) 
for the last hour. Using the built‐in functions Sgn and TagAvg, calculate whether your hourly production 
rate is better or worse than that for the three hours prior. Use MS Excel’s conditional formatting to get a 
quick view of your performance. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 63 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the file Exercise_DL6_Template.xls. 

OSIsoft Drink Company


2 Litre Lime Line
Filler Speed, 1 hour average
Expression:

bottles/minute

Getting better or worse?


Expression:

0
 

2. We need to formulate an expression which will, when calculated, return the value for the average 
speed of the filler for the last hour.  We’ll use the predefined PI function TagAvg.  The start time is 
one hour in the past.  The end time is now.  Therefore, in cell B9, type the following: 

TagAvg('SINUSOID', '*-1h', '*')


3. With the cursor in cell B11, select PI > Archive 
Value.  In the popup window, select the radio 
button for Expression. 

4. In the Expression(s) field, reference the cell in 
which you typed your expression.  

5. For the Timestamp, enter *.  This will calculate 
the expression in real time each time we press 
CTRL-SHIFT-ALT-F9. 

6. Check that your window looks like the one shown 
here, before clicking OK.  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 64 
Exercises PI ProcessBook and PI DataLink 
 
 

7. Next, we wish to determine if we are improving our filler speed with respect to the three hours prior.  
There are plenty of ways of going about this, but one simple way is to check the sign (positive or 
negative) of the difference between the last hour’s average and the average of the three hours 
before.  In other words, we will check which one is bigger.  In cell B16, type the following 
expression: 

Sgn(TagAvg('SINUSOID', '*-1h', '*') - TagAvg('SINUSOID',


'*-4h', '*-1h'))
This will deliver us a +1 if the filler speed is increasing or a ‐1 if it is decreasing, relative to the three 
hours before. 

8. With the cursor in cell B18, select PI > Archive 
Value.  Select the radio button for Expression. 

9. For the Expression(s) field, reference the cell in 
which you typed your expression. 

10. For the Timestamp, enter *.  This will 
calculate the expression in real time each time 
we press CTRL-SHIFT-ALT-F9. 

11. Check that your window looks like the one 
shown here, before clicking OK.  

12. We have a ‐1 or a +1 in cell B18.  Click on cell 
H2, which is a group of cells merged together.  
In this cell’s formula window, enter =B18
and hit return key. 

13. Still in cell H2, select from MS Excel Format > Conditional Formatting.  This is where we will choose a 
cell’s format based on its value.  We need to differentiate between an increase in speed (+1) and a 
decrease in speed (‐1).  Let’s use green for an increase and red for a decrease. 

14. In the entry for Condition 1, set the lists to Cell Value Is and equal to, and in the last field, enter the 
number 1 (to represent an increase in speed).  Select Format, and on the Patterns tab, select a green 
for the cell fill.  Click OK.  The first condition is defined. 

15. Now select Add from the Conditional Formatting dialog box.  For this condition, when the cell is not 
equal to 1, make its pattern red.  Check to make sure your dialog box resembles the one shown here, 
and click OK to save the conditional formatting. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 65 
Exercises PI ProcessBook and PI DataLink 
 

16. Your worksheet will resemble as the example shown below, behind the bottle will appear in red if 
your line is underperforming and in green if you are making headway! 

OSIsoft Drink Company


2 Litre Lime Line
Filler Speed, 1 hour average
Expression:
TagAvg('sinusoid','*-1h','*')
95.4 bottles/minute

Getting better or worse?


Expression:
Sgn(TagAvg('sinusoid','*-1h','*')-TagAvg('sinusoid','*-4h','*-1h'))

1 1
 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 66 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL7 - Operating Time with Time Filtered

Objectives:

• Calculate an operating time with the function Time Filtered. 

Problem Description:

As  the  person  in  charge  of  the  maintenance  program,  you  want  to  know  the 
operating  time  for  a  specific  pump.    Find  the  amount  of  time  the  pump  was 
“Active” using the function Time Filtered.  Compare this method to that used in 
Exercise DL3.  This method performs the calculation in a single step; saving the 
step of doing the filtering with the IF function in MS Excel. 

Approach:

The Time Filtered function returns the amount of time that an expression is true.  Use Time Filtered 
results to perform an analysis of the time that your machine state was ACTIVE. The report should allow 
the user to select the time unit to display. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 67 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the file Exercise_DL7_Template.xls. 

2. Enter the following expression in the Operation Expression field on the template file: 

''BA:ACTIVE.1' = "ACTIVE"
Note: The first two (2) characters are single quote. 

3. In cell C9, select Data > Validation. For the validation criteria, select Allow List and enter for the 
source:  SECONDS, MINUTES, HOURS, DAYS 

4. Select the cell in the upper left hand corner of the data output. 

5. Select PI > Time Filtered. 

6. Fill the function dialog boxes with the calculation start and end times, interval between calculations, 
and the expression to calculate the time the expression was met. 

7. Select the Show Timestamps option. 

8. Make a cell reference to cell C9 for the time units. 

Note:

An expression can contain multiple conditions using the logical operators OR and AND.    As an example, 
enter the following expression: ''BA:ACTIVE.1' = "ACTIVE" AND 'SINUSOID' > 30  

Note the difference in the calculation of time when this condition was met.  Also try: 
''BA:ACTIVE.1' = "ACTIVE" OR 'SINUSOID' > 30  

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 68 
Exercises PI ProcessBook and PI DataLink 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 69 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL8 - Tank Level

Objectives:

• Learn  to  use  the  Insert  Trend  function  with:  Data  from  MS  Excel 
worksheet and PI data. 

Problem Description:

Plot three tank levels for an eight (8) hour period using the Insert Trend function.  

Approach:

Use a PI Trend in MS Excel to display real‐time data alongside MS Excel data.  We 
could use MS Excel’s graphing capability; however we would not have automatic 
refreshing. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 70 
Exercises PI ProcessBook and PI DataLink 
 
 

Step-by-Step Solution

1. Open the file Exercise_DL8_Template.xls. 

2. For the first trend display, use the Insert Trend function with the option Data from PI.   

a. Choose the tag name (SINUSOID) and the appropriate server name, click on the Add button and 
then click on the Next button.   
b. On the second screen, enter the start time and end time and click on Next button.  Name the trend 
Tank #1 and select cell C7 to align the trend, and then click on Finish button. 
c. Right click on the trend and choose the Format option.  Choose Trace 1 and Format, and then 
change the pen color to blue. 

3. For the second display, use the Insert Trend function with the option Data on worksheet. 

a. When the popup menu opens, input the cells A24:B33 in the cell range containing data field.   
b. Click on first element is trace name option and include all cells in array then click on the Add 
button.  
c. Use the option Data from PI, choose the tag name (BA:LEVEL.1) and the appropriate server, click 
on the Add button, and then click on the Next button. 
d. Verify that the time range is the same as for the manually entered data and click on Next button.   
e. Name the trend Tank #2 & #3 and select cell C22 for the output, then click on Finish button.   
f. Right click on the trend and choose the Format option.  Use a blue pen for trace 1 and a red pen for 
trace 2. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 71 
Exercises PI ProcessBook and PI DataLink 
 

Exercise DL9 - Advanced Calculated Data (Optional)

Objectives:

• Learn to perform operations on tags using Advanced Calculated Data. 

Problem Description:

As  the  section  head  of  a  small  sawmill,  you  are  responsible  for  the  quality  and 
the quantity of board produced.  You wish to create a PI DataLink report to help 
your weekly analysis of shift performance. 

BA:CONC.1  represents  the  length  of  board  produced,  and  each  archived  value 
represents another full board.  Boards fewer than 5 feet in length are considered 
scrap, which means they should not be included as production.  Accounting has 
determined that scrap production costs $2 for every foot. The plant starts up on Monday at 8:00 am and 
goes idle at 4:00 pm on Friday.  Shifts are 8 hours long and run 24 hours per day. 

Produce a report for last week, by shift, of the following: 

• The number of boards produced, excluding scrap; 
• The average board length produced, excluding scrap; 
• The cost of scrap. 

Approach:

We will combine a number of functions in the Advanced Calculated Data.  We want to determine for a 
given interval, how many events were archived event (a board being produced is an archived event), the 
boards’ average length (using an event‐weighted expression), as long as they were over a certain length.  
Afterwards, we’ll run a calculation to determine how much production was lost to scrap. 

All of this will be done per interval, which this time is our shift schedule for all last week. 

   
Try to do this exercise on your own before proceeding to the step‐by‐step solution. 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 72 
Exercises PI ProcessBook and PI DataLink 
 
Step-by-Step Solution

1. Open the file Exercise_DL9_Template.xls. 

2. For the produced board length (feet) tag, enter BA:CONC.1 in cell B4. 

3. For the start time (cell B5), enter monday‐7d+8h for Monday of last week at 8:00am, the time the 
plant started up.  (Why do we not use monday+8h?) 

4. For the end time (cell B6), enter saturday‐8h for Friday of last week, the time the plant shut for the 
weekend.  (Bonus: why wouldn’t we enter friday+16h?) 

5. For the shift length (cell B7), enter 8h.  This will be used as the time interval for the expression 
evaluation. 

6. Enter the filter to use in calculations involving only good production, i.e. boards with length greater 
than 5 feet.  The filter will be:  

''BA:CONC.1' > 5
7. Calculations involving only scrap will require a different filter.  The easiest way to do this will be to 
enter in cell B10 the filter will be: 

''BA:CONC.1' > 5
8. Enter a dollar value for the cost of scrap (cell B12).  According 
to the problem definition, the cost per foot of scrap material 
is $2. 

9. Look at the result of the formula in cell B13.  This is an MS 
Excel concatenation which will be used to calculate the value 
of the material lost to scrap, in other words all the boards less 
than 5 feet in length. 

10. Next, with the cursor in cell A16, select PI > Advanced 
Calculated Data.  To fill in the various boxes, use these 
guidelines to calculate the total number of saleable boards 
produced: 

a. With PI Tag option selected, reference to the appropriate 
cells for the Tag name, Start Time, End Time and Time 
Interval. 
b. In the Filter Expression field enter reference to cell B9.  
This will limit the count of saleable boards to those above 
5 feet. 
c. We are performing a Count of events that have been 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 73 
Exercises PI ProcessBook and PI DataLink 
 
written to the server, so set the Calc. Mode to count.  The conversion factor must, therefore, be 
equal to 1. 
d. Set Expression Sampling to pt. compressed.  This will assure that only the archived values are 
counted. 
e. Since we are looking for the total number of boards produced, select event‐weighted in the 
Calculation Basis field. 
f. The first column (Column A) of the spreadsheet will serve as our shift end times and therefore we 
will want to check show end time. 
g. Hit OK to view the results. 

11. With the cursor in cell C16, select PI > Advanced Calculated Data.  To fill in the various boxes, use 
these guidelines to calculate the average length of saleable boards produced: 

a. With PI Tag selected reference to the appropriate cells 
for the Tagname, Start Time, End Time and Time 
Interval. 
b. In the Filter Expression field enter a reference to B9.  
This will limit the average of saleable boards to those 
above 5 feet. 
c. We are performing an average of the value of the 
events that have been written to the server, so set the 
Calc. Mode to Average.  The conversion factor must, 
therefore, be equal to 1. 
d. Set Expression Sampling to pt. compressed.  This will 
assure that only the archived values are averaged. 
e. Since we are looking for the average of the event values 
(i.e. boards produced), select event‐weighted in the 
Calculation Basis box. 
f. Do not show timestamps, they are identical to those 
produced in Column A. 
g. Hit OK to see the results. 
 

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 74 
Exercises PI ProcessBook and PI DataLink 
 
12. With the cursor in cell D16, select PI > Advanced Calculated Data.  To fill in the various boxes, use 
these guidelines to calculate the total value of scrap produced: 

a. With PI Expression selected reference to the appropriate cells 
for the Expression, Start Time, End Time and Time Interval.  
The Expression is the cost of a foot of scrap multiplied by the 
measurement for each board. 
b. In the Filter Expression field, enter a reference to B10.  We 
want the value of all boards less than 5 feet to calculate the 
scrap value. 
c. We are performing a Total of the value of the expression every 
time a board less than 5 feet is produced, so set the Calc. 
Mode to Total.  The conversion factor is equal to 1 since these 
are not “per time” measurements. 
d. Set Expression Sampling to Compressed.  This will assure that 
the expression is only evaluated when a board has actually 
been produced. 
e. Since we are looking for the total based upon event values (i.e. 
boards produced), select event‐weighted in the Calculation 
Basis box. 
f. Do not show timestamps, they are identical to those produced 
in Column A. 
g. Hit OK to see the results.  

13. The final 
spreadsheet will 
Sawmill Production Report
be like the  Advanced Calculated Data
figure presented 
Produced Board Length (ft) tag: BA:conc.1
beside.   Start time of Report: monday-7d+8h
End time of Report: saturday-8h
Shift Length: 8h
 
Filter for saleable board: 'ba:conc.1'>5
Filter for scrap board: 'ba:conc.1'<5
 
Unit cost of scrap: 2 $/foot
Formula for cost of scrap: 'BA:conc.1'*2

Shift End Time Saleable boards produced Average Length of Saleable boards Total Value of Scrap
29-Mar-04 16:00:00 30 28.16 $ 6.83
30-Mar-04 00:00:00 28 28.16 $ 8.45
30-Mar-04 08:00:00 29 28.83 $ 9.24
30-Mar-04 16:00:00 27 30.21 $ 25.98
31-Mar-04 00:00:00 29 27.62 $ -
31-Mar-04 08:00:00 28 29.23 $ 15.15
31-Mar-04 16:00:00 29 27.56 $ -
01-Apr-04 00:00:00 27 29.65 $ 25.34
01-Apr-04 08:00:00 28 29.38 $ 19.02
01-Apr-04 16:00:00 29 28.04 $ 9.67
02-Apr-04 00:00:00 28 29.19 $ 6.92
02-Apr-04 08:00:00 29 29.07 $ 8.59
02-Apr-04 16:00:00 26 31.20 $ 25.93

The information contained in this guide is confidential and may be subject to revision. No
part of this publication may be reproduced or transmitted, in any form or by any means
without prior permission of OSIsoft Canada. All rights reserved, OSIsoft © 2008

Page 75 

You might also like