# Presentation: 302014

## Labview-based User Interface for Beamline Equipment Protection System at the Advanced Light Source 

-  *Hanjing Huang*
*Bob Gunion*
*Ken Woolfe*
- Lawrence Berkeley National Lab

**Notes:**
Advanced Light Source is a national user-facility that generates intense lights. Researchers around the world come to ALS for its sources of ultraviolet and soft x-ray beams. Some components of ALS include the storage ring where the beam is stored, the beamline through which the particles travel, and the end station where scientists do their experiment. It is crucial that these components function properly and the EPS plays an important role in ensuring that.

## What is Equipment Protection System (EPS)

-   A system of hardware and software components used to:
- protect the Storage Ring vacuum from contamination
- protect beamline components from thermal damage
- provide operator control of beamline valves and shutters
- This system is not used for personnel safety

**Notes:**
It is worth noting that at ALS, EPS is not used for personnel safety that deals with radiation hazards associated with accelerator operations.

## Why EPS is different from other scientific control system

- The EPS has to be independent from the data acquisition because it has to be more stable, durable, reliable, and fail-safe. Therefore we use real-time dedicated hardware for EPS.

## Components of EPS

- Hardware control system – PLC
- GUI Unit
- PanelMate hardware box or...
- PC with Labview

**PLC**

**PanelMate**

**Modbus**

**PLC**

**M****odbus**

**PC with Labview Display**

**Notes:**
There are two parts in the EPS, first is the hardware control system which we use  programmable logic controller.  The second part is the GUI unit. It can either be a proprietary HMI hardware box that comes from the vendor. The two parts are connected by a Modbus serial cable. Modbus is a communications protocol designed by Modicon for use with its PLCs. 

## Programmable Logic Controller (PLC) 

-    Device invented to replace the necessary sequential relay circuits for machine control.

**Features:**
- Reliability
- Compact size
- Simple and easy to install
- High speed
- Modular design

**Notes:**
The PLC that I am holding in my hand is the same PLC we use at the ALS.  It is a Modicon 984 compact PLC. It is a special-purpose computer with digital processing capabilities, designed for real time control.  PLCs was invented to replace the necessary sequential relay circuits for machine control. It monitors the state of devices from input modules, solves user logic program, and then send control signals to output modules that are connected to the devices. 

Another nice feature of PLC is its modular design. The PLC and I/O modules are connected on a backplane which allows them to communicate with each other. You can add or subtract I/O modules per each application requirement.

## Real World Applications of PLC

-    machining, packaging, material handling, automated assembly or countless other industries. Examples include:
- Traffic light
- Automatic car wash
- Automatic soft drink dispensers
- Factory floor automation

**Notes:**
For those of you who are not familiar with PLCs, they are actually used in many "real world" applications. Almost any application that needs some type of electrical control has a need for a plc.
PLCs can be found in machining, packaging, material handling, automated assembly.  
Of course, its biggest use is on the factory floor

## Ladder Logic – translating relays into symbols PLC can understand

- industry relay

- schematic diagram

- ladder diagram

**Notes:**
The program that gets stored in the PLC is called ladder logic. It is a highly graphical, easy-to-use programming language that uses relay-equivalent symbology. 
A typical industry relay is shown here.  We represent it as an electromagnetic switch on the schematic diagram.  Apply a voltage to the coil and a magnetic field is generated. The magnetic field sucks the contacts of the relay in. Thus a connection between the two points is made and current can flow through them.

In this schematic diagram, we want to turn on a bell (Lunch time!) whenever a switch is closed. We have 3 real-world parts. A switch, a relay, and a bell. Whenever the switch closes, a current is applied to a bell causing it to sound.  Now we translate the schematic diagram into ladder diagram.  In ladder logic, two vertical bars represents a contact while a circle represents a coil. The relay is split into two parts – a coil and a contact. When the switch is closed, the relay is energized, causing current to pass to the bell. Notice the use of a physical relay is eliminated here.

## Ladder Logic Programming Software – Proworx

**Notes:**
The software used to program ladder logic is called Proworx. It is graphical-based programming system. To add a logic component, simply drag and drop it into development environment. Here is a screenshot of part of the ladder logic for EPS. The controller begins solving logic left to right, top to bottom.  Each node is solved in the order it is encountered in the logic scan. 

## Hardware Control System -- PLC

- HMI – Human Machine Interface

**Notes:**
Now we have a system that safely monitors and controls the beamline components, we need to have a way for user interaction. HMI – human machine interface. 

## Display Hardware and Software

- PanelMate

**Notes:**
Originally, the ALS used a proprietary system from Modicon called PanelMate. A picture of PanelMate is shown here. It is kind of bulky, about this wide, and this deep. It has touch panels at the bottom and on the side. The bottom buttons corresponds to the components on the screen. The side buttons let you operate on that component. Pretend this is a shutter. To open it, press on the corresponding button below to highlight it. Then press the button on the side to open it.
As you can see, not a lot of components can fit onto one screen, so you will have to jump between pages. To switch page, again press the button on the touch pad which highlight the component “switch page”, then select the “goto page 2” button on the side. As you can tell, this is not a very intuitive system. 

## PanelMate Display 

- High cost -- $5000-$6000 (repair cost $1500)
- Very limited display features, graphics, or animations
- Outdated technology
- Difficult to troubleshoot
- Cumbersome display, spreading over multiple pages

**Notes:**
PanelMate has some serious shortcomings. First, the purchase price of a Panel mate is from 5000-6000. The cost to repair a PanelMate alone cost $1500. The PanelMates at ALS have been running for more than 10 years and if they start to break down one by one, the replacement cost can be significant. 
As I showed earlier, PanelMate has limited display features with minimal graphics and animations. It is an outdated technology and difficult to troubleshoot.  For even a simple beamline, the display is spread across multiple pages. Let’s take a quick look at a simple beamline Beamline 8.0. The PanelMate has an overview page, a branchline page, and an end station page. It looks like a lot of information. But in fact all these three pages of information can be easily fit into a single Labview Page from here to here. The Labview display has the added information about the front end inside the shield wall as well. 

## Slide 12

## Slide 13

## Slide 14

## Switching from PanelMate to Labview

- Advantages of Labview:
- Runs on low-cost PC
- Single-page display of entire beamline
- Minimum software cost – free Labview runtime license
- Flexibility in content of displays
- Labview programming expertise widespread

**Notes:**
During the past three years, Bob Gunion, Ken Woolfe, and I have been working on switching the EPS at the ALS from the PanelMate to Labview display. Some advantages of Labview are listed here. First Labview runs on PC so there is no expensive hardware box involved. As we’ve seen earlier, an entire beamline can be displayed on a single page. 
Software cost is minimal since Labview runtime license is free versus PanelMate’s license cost of an extra $1500. Content of displays is flexible. There are lots of animation and graphics to choose from for beamline components. Labview programming expertise is widespread. There are lots of Labview programmers at the lab who can contribute to the system.

## Slide 16

**Notes:**
Now let’s take a quick look at the new EPS.  Some of the typical components on the beamline include shutters, valves, ion gauges, water flow switches. Optical components include the mirror tank, monochromater, and switching mirrors that switches between various endstations.  Everything inside the shield wall plus the first isolation valve is called the Front End. We designed it in such a way that a red valve means a closed valve and a green valve means an open valve. When there is beam, pipes become red.  Most users require just a very short overview since this is such an intuitive system.

## Advantages of New EPS I

- Intuitive and friendly HMI
- Easy software simulation for testing and debugging
- No hardware involved
- Simulated inputs and outputs
- Simulate device faults and behavior or valves and shutters

**Notes:**
The new EPS is intuitive and friendly.  Another  big advantage is that now we can do all the simulation in software with no hardware involved. I wrote a software simulator that feeds simulated inputs and outputs to the PLC. It simulates device faults and also normal behaviors of valves and shutters. For example, when the simulator detects a open command of a valve goes low, it takes away the open position signal and makes the close position signal true. This way, I can fully test the software before installing it at ALS without any hardware involved.

## Advantages of New EPS II

- In-house Backend Server Capability
- CORBA-based network interface allows remote monitoring and control
- Data logging allows postmortem analysis
- Requested by users and operators
- Events are logged into MySQL database
- Player = Display program + play panel

**Notes:**
Over the years, Bob Gunion has written a backend server that handles both corba remote functionality and data logging nicely. For those of you who may be interested, Bob is giving a brief introduction to CORBA in his talk right after this one.

This has brought tremendous convenience to the users and operators.  By installing a remote Corba client program, they can sit at their office and monitor and control the beamline without going to the ALS floor. 
Data logging is a another  important feature of the new EPS. Often times, we are asked by the users –Why did my shutter closed at 2am yesterday? Was there an ion gauge fault? What happened? The new EPS has incorporated the data logging capabilities. Every event, be it an ion gauge trip, a water flow fault, a status change for the valve or shutter, is logged into the database. We have a separate player program that can play back what has happened in the past. 
The player has an almost identical look and feel as the display program except it has an added play panel. This simplifies software development.

## Slide 19

**Notes:**
Now let’s do a quick comparison between the display program and the player program. First of all, the background color is different, mainly to keep myself from getting confused.  More importantly, the player program has added a player panel which allows you to specify the date and time that you are interested, the desirable display speed, and offers the capability to step through each event at your own pace.

## 6.0.2

- 6.1.2

- 6.3.1

- MB

- MB

- MB

- Master

- BRFE

- MB

- Sector Control

- MySQL Database

- Player

- BLFE

- Branchlines

- Front-end

- Remote GUI

- Server

- Write

- Read

- MB+

**DB**

- CORBA

- Read

**Notes:**
A typical sector setup is shown here. Each Front End has a set of two PLCs and one HMI while each branchline has one PLC and one directly connected HMI. The red line is the proprietary Modbus+ network that communicate between these PLCs. Note that we have a master PLC on the network as well. Its sole purpose is to collect information from all other PLCs on the MB+ network and feed the data to the sector server which sits on the sector HMI. As we mentioned earlier, the server has two purposes. It provides information to remote clients. It logs events into the MySQL database and later queries the database for the player to read. 

## Simulation Setup in Hanjing’s Office

- 6.0.2

- MB

- Master

- BRFE

- MB

- Sector Control

- Demo
- Player

- BLFE

- Demo EPS

- Write

- Read

- MB+

**DB**

- Simulator

**DB**

- MySQL Test Database

- Test
- Server

- Read

- CORBA

**Notes:**
I’ve bragged enough about the new EPS. I’d like to show you how it works in real life. In theory, I could just run a remote Corba client which talks to one of the beamlines at the ALS. The Problem is that I may get angry calls from users if I open and close their shutters at random.  Luckily, I have a full simulation setup in my office which sits across the hill. With this setup, I can do a demonstration freely without upsetting anyone. Here is the simulation setup in my office. It looks very similar to the previous slide. PLCs are all connected via MB+ network. Here is a test server and test database. This is the demo display program and this is the demo player program sitting on this laptop. The main difference here is – instead of connecting the PLC I/O modules to real devices, the simulator feeds inputs and outputs to the PLC. 

## So are you ready? Here comes the demo EPS program. This is a demo EPS program for BL6.0.2. Beamline 6.0.2 is fully functional and operational at the ALS. Ken Woolfe here is going to play with the simulator. Remember how much trouble you have to go through just to open a valve in PanelMate – switch pages to find the valve, then press the touch pad on the bottom to select it, then press the radio button on the side to operate on it? With the new EPS, it is a snap. You just click on the valve and a popup menu appears which allows you to open or close a valve. I am going to go ahead and open the valve (I hope the program is talking to the right server otherwise I will be in trouble). I am going to open a bunch more and you can see the hot red beam running down the pipe. Now the scientist is happily taking beam for his experiment. But suddenly there is an air leak and IG203 is tripped. Notice the ion gauge goes from green to red and both the valves upstream and downstream of it are closed for vacuum protection. The shutter is also closed so that the hot beam won’t burn our valves. Note there is a little red not-symbol next to the valves and shutters. This tell us this device cannot be operated. Click on the not-symbol and it tells you exactly why you cannot operate it. After some damage control, vacuum is back to normal and IG203 is on again. We have a reset required alert here which tells us that a fault happened but it is now OK. We acknowledge the fault and reopen the valves and shutter. Next thing we know, a water flow stopped turning. This caused the shutter to close since this shutter needs water cooling. Click on the not-symbol for the shutter, sure enough, it says shutter is not openable because the water flow switch is faulted. Let’s clear the fault and open up everything. Sometimes a valve can fault too – when there is open command but the valve is not open; it takes too long to open or close; the cables are unplugged accidentally so the valve is neither open nor closed. The simulator is capable of simulating valve faults too. Let’s fault VVR202 and see what happens. Now we fix the valve faults. We also have an alarm page which dutifully logs recent faults. Let’s open it and take a look. Sure enough, all our faults are listed in it.

**Notes:**
OK, enough about the EPS display program.  Does any of you remember the sequence of events I did? First, an ion gauge trip, then a water flow switch fault followed by a valve fault.  Since I mentioned data logging before, you probably are wondering if those events were being logged into the database. Let’s find out by looking at the player program.

Here is my player program. Again, it looks a lot like the display program with a different background and an added play panel. When it first starts up, it just shows you the current status of the beamline. Now I want to find out what happened ever since my talks started at 1:30pm. I specify the date and time, and then say go. Here we go, an ion gauge trip, valves are all open, water flow trip...

It all worked. I am beyond surprised myself.  Now I am ready for questions.