Transcript EPICS Training @ SLS
EPICS Training @ PSI
Controls Section PSI 2015
Acknowledgment
Some slides in this talk came form the „Getting started with EPICS“ lecture series of APS.
My special thanks go to Ned Arnold and John Maclean from the Advanced Photon Source.
The original talks can be found on www.aps.anl.gov/epics/docs/GSWE.php
EPICS Training @ PSI
Contents
• What is EPICS • The Parts of EPICS • What are Records • An Example for a Record • How to Solve Problems with EPICS
EPICS Training @ PSI
What is an Accelerator Control System?
The Accelerator Control System connects the Operator in the control room with the accelerator hardware. The control room might not be near the accelerator Operator
Our Control System is called EPICS EPICS Training @ PSI
Accelerators
What does EPICS Control?
For example Swiss Light Source (SLS at PSI) Accelerator components to control: ca. 200 computers ca. 600 magnets (+power supplies) 300 vacuum pumps 9 cavity structures ca. 150 beam position monitors 21 beamlines (together) ca. 300 computers 10 undulator magnets more than 1200 motors Distances between components (storage ring with 130 m diameter): 50 km power cable and more than 500 km signal cable
EPICS Training @ PSI
What is EPICS?
EPICS is
an abbreviation for:
E
xperimental
P
hysics and
I
ndustrial
C
ontrol
S
ystem •
EPICS is:
A collaboration
EPICS
• • A software tool kit A control system architecture
EPICS:
• supports distributed control systems for large research facilities like accelerators • uses Client/Server and Publish/Subscribe methods • uses the Channel Access (CA) network protocol
EPICS Training @ PSI
The History
–In1989 started a collaboration between Los Alamos National Laboratory (GTA) and Argonne National Laboratory (APS) (Jeff Hill, Bob Dalesio & Marty Kraimer)
GTA
: Ground Test Accelerator
APS
: Advanced Photon Source –More than 150 licenses agreements were signed, before EPICS became Open Source in 2004 –Team work on problems, for example over “Tech Talk” mailing list –Two collaboration meetings every year (spring and autumn) in turns in America, Asia, and Europe –Collaborative efforts vary • Assistance in finding bugs • Share tools, schemes, and advice
EPICS Training @ PSI
EPICS – Who is Using That?
Some members of the collaboration (not complete!): – ANL (APS Accelerator, APS Beamlines, IPNS) in Chicago, USA – LANL in Los Alamos, USA – ORNL (SNS) in Oak Ridge, USA – SLAC (SSRL, LCLS) in Standford, USA – JLAB (CEBAF) in Newport, USA – DESY in Hamburg, Deutschland – BESSY in Berlin, Deutschland – PSI (SLS, HIPA, PROSCAN, SwissFEL) in Villigen, Schweiz – KEK in Tsukuba, Japan – DIAMOND Light Source Oxfordshire, England
(
Rutherford Appleton Laboratory) in – Iter (Test Fusion Power Plant), South France – ESS (European Spallation Source), Lund, Sweden
EPICS Training @ PSI
Are There Alternatives to EPICS?
• • System Name:
EPICS TANGO
• • •
DOOCS Tine ACS
•
PVSS (Cern)
Collaborations: Used at more than one Lab Pro: Bugs are already found Contra: Complicated to adapt to your problems Single Site Systems: Developed and used in one Lab Pro: Your problems solved perfectly Contra: You are on your own (no one can help) Commercial System Pro: Outsource your problems Contra: Expensive
EPICS Training @ PSI
The Architecture of EPICS
Network based Client/Server Model (hence the EPICS logo):
CA Client
EPICS
CA Client
A
Server
provides information and service A
Client
uses the service or asks for the information
CA Server CA Server
• For EPICS, client and server refer to their
C
hannel
A
ccess role: i.e. Channel Access Client and Channel Access Server • This standard control system architecture is often called 3 tier architecture or 3 layer model
EPICS Training @ PSI
What is Channel Access?
• A protocol how to transfer data over network • A single data unit is called
Process Variable
• A Process Variable has a unique name, which is used to refer to the data (Naming convention needed!) • The detailed operation of Channel Access is unimportant for most programmers (it already works…) • Channel Access is not dependent on a single programming language (native library in C/C++, Java, and C# available) • The entire set of Process Variables establish a
Distributed Real-time Database
of machine status, information and control parameters
EPICS Database Process Variables EPICS Training @ PSI Process Variables CAS Process Variables
Channel Access Network Flow
CA Client
1. Query: Broadcast 2. Answer: direct connection 3. All further queries and answers work directly (Point-To-Point)
Network CA Server 1 CA Server 2 CA Server 3 EPICS Training @ PSI
Channel Access Commands
Channel Access Client CA Client Who has a PV named “S1A:H1:CurrentAO”?
CA Server Channel Access Server Process Variables: I do.
S1A:H1:CurrentAO S1:P1:x S1:P1:y S1:G1:vacuum
“connection request” or “search request” “get” or “caget”
What is its value?
“put” or “caput”
Change its value to 30.5
“set a monitor”
Notify me when the value changes 25.5 AMPS OK, it is now 30.5
or or “put complete”
30.5 is too high. It is now set to the maximum value of 27.5.
You are not authorized to change this value EPICS Training @ PSI It is now 20.5 AMPS It is now 10.5 AMPS
“post an event” or “post a monitor”
It is now 0.0023 AMPS
How is it Done?
Channel Access Client Channel Access Client
Operator
Channel Access Server Process Variables:
Network (Channel Access Protocol)
S1A:H1:CurrentAO Computer Interface Power Supply S1:P1:x S1:P1:y S1:G1:vacuum Computer Interface Computer Interface Beam Position Monitor Vacuum Gauge EPICS Training @ PSI Channel Access Client
Machine
What is EPICS - Conclusion
• EPICS is a control system architecture • EPICS is the connection between accelerator and operator • EPICS is based on a transfer protocol named Channel Access • Channel Access works with data sets called Process Variables • EPICS is used by many institutes all over the world
EPICS Training @ PSI
Contents
• What is EPICS • The Parts of EPICS • What are Records • An Example for a Record • How to Solve Problems with EPICS
EPICS Training @ PSI
Parts of EPICS
CA Client CA Client Control Room CA Server
EPICS Training @ PSI
Client Programs: alarmhandler Striptool, caQtDM, many more … (user programs) Cannel Access: (UDP/TCP) Server Programs: (user programs) Realtime Control
Records
VME Computer
• VME is an abbreviation for VERSAmodule Eurocard • Industry Computer • Developed since 1980 •
It is not a PC
• Real-time capable (i.e. delays are calculable) • Operating system was VxWorks from Wind River company – will be real time Linux (at PSI) • Very expensive (search for new solutions in EPICS community)
EPICS Training @ PSI
What is an IOC?
IOC means
I
nput
O
utput
C
ontroller • A special CA Server and CA Client (IOCs can “talk” to each other) • A computer running the “
IOC Core
” program (at least once) • This computer may be: - VME based, operating system vxWorks (only possibility for old EPICS Versions up to 3.14), Linux, RTEMS - PC, operating system Windows, Linux, RTEMS - Apple, operating system OSX - UNIX Workstation, operating system Solaris • An IOC normally is connected to input and/or output hardware (otherwise called softIOC) • An IOC runs a record database, which defines what this IOC is doing
EPICS Training @ PSI
Some CA Clients
(from the EPICS Website - incomplete) •ALH: Alarm Handler •BURT: Backup and Restore Tool •CASR: Host-based Save/Restore •CAU: Channel Access Utility •Channel Archiver •Channel Watcher •EDM: (SNS) (SLAC) Extensible Display Manager (ORNL) •JoiMint: Java Operator Interface and Management INtegration Toolkit (DESY) •Knobs: Knob Manager und KnobConfig, eine Schnittstelle zu SunDials •MEDM: Motif Editor und Display Manager •StripTool: Strip-chart Plotting Tool •Command line tools (caget, caput, …) •and many more …
EPICS Training @ PSI
Client Program: Command Line Tools
• Read a PV named
caget NAME
• Write a PV named
caput NAME value
• Get information about that Record
cainfo NAME
>caget ARIDI-PCT:CURRENT ARIDI-PCT:CURRENT 350.56
> >caput ARIDI-PCT:CURRENT 401.5
Old: ARIDI-PCT:CURRENT 350.56
New: ARIDI-PCT:CURRENT 401.5
> >cainfo ARIDI-PCT:CURRENT ARIDI-PCT:CURRENT State: connected Host: sls-cagw-1 Access: read, no write Data type: DBR_DOUBLE • Start a monitor
camonitor NAME
(Cancel with [Ctrl] + [c]) ARIDI-PCT:CURRENT 250.537
ARIDI-PCT:CURRENT 250.533
ARIDI-PCT:CURRENT 250.525
>
EPICS Training @ PSI
Some CA Clients
(from the EPICS Website - incomplete) •ALH: Alarm Handler •BURT: Backup and Restore Tool •CASR: Host-based Save/Restore •CAU: Channel Access Utility •Channel Archiver •Channel Watcher •EDM: (SNS) (SLAC) Extensible Display Manager (ORNL) •JoiMint: Java Operator Interface and Management INtegration Toolkit (DESY) •Knobs: Knob Manager und KnobConfig, eine Schnittstelle zu SunDials •MEDM: Motif Editor und Display Manager •StripTool: Strip-chart Plotting Tool •Command line tools (caget, caput, …) •and many more …
EPICS Training @ PSI
Example: ALH
EPICS Training @ PSI
Alarms and Colours
NO_ALARM Green Everything ok MINOR MAJOR INVALID Not connected Yellow Red Warning Error (no Controls Problem) White White block or Pink Device not reachable Record not known
EPICS Training @ PSI
Example: ALH
Tree structure of Records Panel with more Information Guidance Usefull for users who know the environment (for example operators in the main control room)
EPICS Training @ PSI
Some CA Clients
(from the EPICS Website - incomplete) •ALH: Alarm Handler •BURT: Backup and Restore Tool •CASR: Host-based Save/Restore •CAU: Channel Access Utility •Channel Archiver •Channel Watcher •EDM: (SNS) (SLAC) Extensible Display Manager (ORNL) •JoiMint: Java Operator Interface and Management INtegration Toolkit (DESY) •Knobs: Knob Manager und KnobConfig, eine Schnittstelle zu SunDials •MEDM: Motif Editor und Display Manager •StripTool: Strip-chart Plotting Tool •Command line tools (caget, caput, …) •and many more …
EPICS Training @ PSI
Examples: StripTool
channel values EPICS Training @ PSI time
Some CA Clients
(from the EPICS Website - incomplete) •ALH: Alarm Handler •BURT: Backup and Restore Tool •CASR: Host-based Save/Restore •CAU: Channel Access Utility •Channel Archiver •Channel Watcher •EDM: (SNS) (SLAC) Extensible Display Manager (ORNL) •JoiMint: Java Operator Interface and Management INtegration Toolkit (DESY) •Knobs: Knob Manager und KnobConfig, eine Schnittstelle zu SunDials •MEDM: Motif Editor und Display Manager •StripTool: Strip-chart Plotting Tool
caQtDM: Display Manager
•and many more …
EPICS Training @ PSI
Examples for caQtDM
EPICS Training @ PSI
Contents
• What is EPICS • The Parts of EPICS • What are Records • An Example for a Record • How to Solve Problems with EPICS
EPICS Training @ PSI
Close Look at a Measured Value
Value with a data type
295,5
with a unit
mA
with a time stamp
17.2.2005 14:21:16
with a severity (alarm state)
NO_ALARM
with technical limits
0 to 400
with graphical limits
0 to 370
with a description „
Beam current in SR“ A measured value is an object with multiple related information that have different data types EPICS Training @ PSI
What are Records?
A Record is an object with – a unique name – properties (fields) that contain information (data) different data types can appear in different fields – the ability to perform actions on that data unique name
XYZ1234 Employee : James Bond Badge Number: 007 Address : Whitehall, London Salary : £70070.07
fields data
EPICS Training @ PSI
Make a Record from a Measured Value
with a unique name
ARIDI-PCT:CURRENT
A value with a data type
mA
")
295,5 ai
with a unit
mA
field (EGUL, "
0
") field (HOPR, "
370
") with a severity (alarm status)
0
")
NO_ALARM
field (DESC, "
Beam current in SR
") field (DTYP, "
HY8401
")
0 to 400
field (INP, "
#C3 S0 @
")
developer Read back from hardware/driver
with a description „
Beam current in SR“
VAL SEVR TIME
EPICS Training @ PSI
A Process Variable Name
• A PV name is comprised of two parts – The record name, and – the name of a field belonging to that record • For example… ARIDI-PCT:CURRENT .
EGU A Process variable name • A record name A dot to join them A field name Note that if no field name is given, Channel Access will default to using the .VAL field “
ARIDI-PCT:CURRENT
” is interpreted as “
ARIDI-PCT:CURRENT .VAL
”
EPICS Training @ PSI
View of a Record
record(ao,"DemandTemp") { field(DESC,"Temperature") field(ASG,"") field(SCAN,"Passive") field(PINI,"NO") field(PHAS,"0") field(EVNT,"0") field(DTYP,"VMIC 4100") field(DISV,"1") field(SDIS,"") field(DISS,"NO_ALARM") field(PRIO,"LOW") field(FLNK,"") field(OUT,"#C0 S0") field(OROC,"0.0e+00") field(DOL,"") field(OMSL,"supervisory") field(OIF,"Full") field(PREC,"1") field(LINR,"NO CONVERSION") field(EGUF,"100") field(EGUL,"0") field(EGU,"Celcius") } EPICS Training @ PSI field(DRVH,"100") field(DRVL,"0") field(HOPR,"80") field(LOPR,"10") field(HIHI,"0.0e+00") field(LOLO,"0.0e+00") field(HIGH,"0.0e+00") field(LOW,"0.0e+00") field(HHSV,"NO_ALARM") field(LLSV,"NO_ALARM") field(HSV,"NO_ALARM") field(LSV,"NO_ALARM") field(HYST,"0.0e+00") field(ADEL,"0.0e+00") field(MDEL,"0.0e+00") field(SIOL,"") field(SIML,"") field(SIMS,"NO_ALARM") field(IVOA,"Continue normally") field(IVOV,"0.0e+00")
What do Records do?
• • • Depends on 1.
2.
Record Type Field values Records are active, they do things – Get data from other records or from hardware – – Perform calculations Check values are in range and raise alarms – Put data to other records or to hardware – – Activate or disable other records Wait for hardware signals (interrupts) record do nothing until they are
processed
EPICS Training @ PSI
•Analog in •Analog out •Binary in •Binary out •Calculation •Calculation out •Compression •Data fanout •Event •Fanout •Histogram •Motor •Multi bit binary input •Multi bit binary output •PID control •Pulse counter •Pulse delay •Scan •Select •Sequence •String in •String out •Subarray •Subroutine •Waveform
Record Processing
Record processing can be
periodic
or
event driven
: •
Periodic
: Standard scan rates are… – 10, 5, 2, 1, 0.5, 0.2 and 0.1 seconds – Custom scan rates can be configured up to speeds allowed by operating system and hardware – No precise timing!
•
Event driven
: Events include – Hardware interrupts – Request from another record via links – EPICS Events – Channel Access Puts
EPICS Training @ PSI
The Record Reference Manual
• Explains records from the EPICS base release • Explains database concepts, record types, and record fields • New Version as Wiki: http://www.aps.anl.gov/epics/wiki/index.php/RRM_3-14 • Old Version (R3.13): pdf: http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref.pdf
• More Records exist.
For example Motor Record (part of synApps package)
EPICS Training @ PSI
Contents
• What is EPICS • The Parts of EPICS • What are Records • An Example for a Record • How to Solve Problems with EPICS
EPICS Training @ PSI
Example Record
Process Temperature Sensor Normal Operation 5 - 50
°
C 0 – 100
°
C 0 – 10V
IOC
Analog to Digital Converter 8 bit ADC 0 – 10V 0 – 255 bits
Database
record (ai, “MTRT1-TEMP:READ”) { field (EGU, “deg C”) field (EGUL, “0”) field (EGUF, “100”) field (HSV, “MAJOR”) field (HIGH, “51”) field (SCAN, “.1 second”) field (DTYP, “Hy8401”) field (INP, “#C3 S0 @”) }
EPICS Training @ PSI
Example Record
caQtDM sets a CA monitor every time the value changes record triggers callback IOC Record Support
Value (34 °C) CA Client: caQtDM
Device Support Driver every 0.1 seconds the record asks the driver for a value and the driver reports back
EPICS Training @ PSI
record (ai, “MTRT1-TEMP:READ”) { … field (SCAN, “.1 second”) field (DTYP, “Hy8401”) field (INP, “#C3 S0 @”) field (VAL, “34”) … }
Get a Values from a Record
• Switch on VME (on every VME a Record is created, which is connected to the first potentiometer) • Type into a terminal:
caget MTRT1-TEMP:READ
(change the 1 to the number of your training station) • Move the potentiometer • Ask for another values
EPICS Training @ PSI
CA Commands
• Read a PV named
caget NAME
caget MTRT1-TEMP:READ • Get information about that Record
cainfo NAME
cainfo MTRT1-TEMP:READ • Start a monitor
camon NAME
camon MTRT1-TEMP:READ (Cancel with [Ctrl] + [c]) • Without argument all commands show some help caget
EPICS Training @ PSI
Create a Graphical User Interface (GUI)
1. To start the Qt Designer: (editor to create new GUI)
caqtdm_designer &
2. To start an existing GUI (configuration file already exist):
caqtdm .ui &
EPICS Training @ PSI
Create a caQtDM window (1/4)
select “Main Window” create
EPICS Training @ PSI
Create a caQtDM window (2/4)
EPICS Training @ PSI
Create a caQtDM window (3/4)
MTRT1-TEMP:READ
EPICS Training @ PSI
Create a caQtDM window(4/4)
Temperature.ui
EPICS Training @ PSI
Create a Graphical User Interface (GUI)
1. To start the Qt Designer: (editor to create new GUI)
caqtdm_designer &
2. To start an existing GUI (configuration file already exist):
caqtdm .ui &
EPICS Training @ PSI
Running a caQtDM Window
EPICS Training @ PSI
Files for the Temperature Example
• Change into local directory:
cd G/TRAINING/T
1
• Open the files in an editor:
G_TRAINING_T
1
_TEMPERATUR.template
MTEST-VME-T
1
_example.subs
For example use
nedit & (click on file -> open)
EPICS Training @ PSI
Inside the Files
substitution file template file EPICS Training @ PSI
Why Substitution and Template Files?
• What to do if you have more than one instance of a device?
– Multiply the record and change the name works ok – If you have 20 devices the file gets lengthy – If the device not only needs one record but more (BPM with at least x, y, and intensity) the file gets even more lengthy and confusing [spell maintenance nightmare] • Solution provided by EPICS: substitution (with macro definition) and template files
EPICS Training @ PSI
Inside the Files
DEVICE = MTRT1 $(DEVICE)-TEMP:READ MTRT1 -TEMP:READ EPICS Training @ PSI
Exercise: a Second Record
• Imagine we have a second temperature sensor – we need a second record Edit the substitution file (MTEST-VME-T1_example.subs)
EPICS Training @ PSI
How to get the Record to the VME
New records can only be created during restart of an IOC (for VME this means reboot) Linux PC install files Central Server get files during reboot Trainings VME
EPICS Training @ PSI
Installing an EPICS Database
• Everything written correctly?
• Install to the boot directory of the IOC swit –V -ioc IOC-NAME (enter command in the local directory which contains the files to be installed) swit -V -ioc MTEST-VME-T1 • Reboot IOC: Log into the IOC using rmc IOC-NAME and type in (soft reboot) reboot rmc MTEST-VME-T1
MTEST-VME-T1> reboot EPICS Training @ PSI
What Happens at Booting
• Boot Info (memory) VME-IOC: where to find the startup.script
•
Load startup.script
• In startup.script: list of .subs files •
Load .subs files
• In .subs files: List of .template files •
Load .template files with substitutions
• Create all loaded records
EPICS Training @ PSI
Commands on the VME Computer
• Get a list of all installed records (on this IOC)
dbl
• Get the number of installed records
dbnr
• View interesting fields of a record
dbpr "MTRT1-TEMP:READ",1
• To get a list of VxWorks commands
help
EPICS Training @ PSI
SLS Naming Convention
Records need unique names 1. X=Beamline, A=Machine, M=Test (1 character) 2. Project abbreviation (4 characters), e.g. 06SA, TEST, RI=Ring, DI=DIAGNOSE 3. Optional: Device, Group, Component, e.g. OP, ID 4. Device, e.g. MO 5. Optional: Function (max. 11 characters), z.B. TRY1-SET
[1][2] – [3] – [4] : [5]
Length of [3]+length of [4] ≤ 12 characters
older EPICS: Names have 27 characters at maximum EPICS Training @ PSI
Name for the Temperature Sensors
M = Test TR = Training T1, T2, T3, T4 = Training IOCs TEMP = Temperature READ = Record for reading For a second sensor: TEMP1 for the first, TEMP2 for the second: MTRT1-TEMP1:READ und MTRT1-TEMP2:READ
EPICS Training @ PSI
Exercise: caQtDM Application
• Create an caQtDM GUI, which shows: – Your own Records – All Records of the course – The alarm states of all records • More to do: Create a second GUI, which displays all records with names starting like MTEST-VME-T running on your IOC.
EPICS Training @ PSI
IOC Status
On every IOC there are some Status Records created automatically: caqtdm -macro IOC=MTEST-VME-T1 /work/sls/config/qt/G_IOCMON_ioc_status.ui
EPICS Training @ PSI
Contents
• What is EPICS • The Parts of EPICS • What are Records • An Example for a Record • How to Solve Problems with EPICS
EPICS Training @ PSI
Solve a Problem in EPICS
Sensor T1 ADC
IOC Database Analog In
MTTR1-LI-COOL:TEMP1
INP
Problem:
VAL
Calculation
EGU:
deg C
Binary out
MTRT1-LI-COOL:CALC
In the LINAC we have a water chiller that must be
ADC
Analog In
MTRT1-LI-COOL:TEMP2
CALC:
( (A+B)/2 ) > C
SCAN:
10 second
INP EGU: VAL
deg C Sensor T2 Binary I/O Chiller
EPICS Training @ PSI
The subs File
• Name of the file: MTEST-VME-T1_example.subs
# means this line is a comment
EPICS Training @ PSI
Different Styles of subs files
few instances many instances
Files are written for programmers not for computers!
EPICS Training @ PSI
The Template File
• Predefined records in the file G_TRAINING_T
1
_COOLER.template
EPICS Training @ PSI
Useful Scripts
• Is everything spelled correctly?
externalLinks subs-File externalLinks MTEST-VME-T1_example.subs
• What was the name of this record? findrecord Name-Part findrecord MTRT1-LI • When was this IOC booted last time? bootinfo IOC-Name bootinfo MTEST-VME-T1
EPICS Training @ PSI
Steps of Development
1. Change your files 2. Save your files 3. Check syntax with externalLinks externalLinks MTEST-VME-T1_example.subs
4. Install IOC files swit -V -ioc MTEST-VME-T1 5. Reboot IOC (in rmc window: reboot) 6. Test
EPICS Training @ PSI
10 Really Neat Things About EPICS
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
It is free It is Open Source There are lots of users All a client needs to know to access data is a PV name You can pick the best tools out there … … or build your own The boring stuff is already done There is a lot of expertise available close by A good contribution becomes internationally known It does not matter, if you need 10 or 10 million PVs It is fun (don’t tell the management)
EPICS Training @ PSI
EPICS Web Page
The central site for EPICS information - Documentation - CA Clients - Device support (driver) - Tech-talk (mailing list and archive)
http://www.aps.anl.gov/epics
EPICS Training @ PSI