Date post: | 26-Dec-2015 |
Category: |
Documents |
Upload: | oliver-blankenship |
View: | 213 times |
Download: | 0 times |
Elke Zimoch, 3. October 2011
Found on http://www.semanticmetadata.net/category/comic/
Wir schaffen Wissen – heute für morgen
Elke Zimoch, 3. October 2011
Paul Scherrer InstitutElke Zimoch
Introduction to EPICS
Elke Zimoch, 3. October 2011
Acknowledgment
Some slides in this talk came form the„Getting started with EPICS“ lecture series of APS.
My special thanks go toNed Arnold
andJohn Maclean
from the Advanced Photon Source.The original talks can be found on
www.aps.anl.gov/epics/docs/GSWE.php
More people to thank for support:Timo Korhonen, Detlef Vermeulen, Dirk Zimoch
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture• What is EPICS?• Examples from the EPICS tool box• What are Records?• How to set up an IOC?• Conclusion
Afternoon: Hands-on training• Implementation of a Cooling System (IOC)• Some simple clients (medm)• Some more exercises
Elke Zimoch, 3. October 2011
What is EPICS?
EPICS is:• A collaboration• A software tool kit• A control system
architecture
EPICS is an abbreviation for:Experimental Physics and Industrial Control System
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
Elke Zimoch, 3. October 2011
Who uses EPICS?
Some members of the collaboration (very incomplete!): – ANL (APS Accelerator, APS Beamlines, IPNS), Chicago, USA– LANL, Los Alamos, USA– ORNL (SNS), Oak Ridge, USA– SLAC (SSRL, LCLS), Standford, USA– JLAB (CEBAF), Newport, USA– DESY, Hamburg, Deutschland– BESSY, Berlin, Deutschland– Gemini 8m-Telescope, Hawaii, USA– PSI (SLS, SwissFEL), Villigen, Switzerland– KEK, Tsukuba, Japan– DIAMOND Light Source (Rutherford Appleton Laboratory),
Oxfordshire, England– Australian Synchrotron, Melbourne, Australia– Iter (Test Fusion Power Plant), South France– ESS (European Spallation Source), Lund, Sweden
Elke Zimoch, 3. October 2011
History
• In 1989 started a collaboration between Los Alamos National Laboratory (GTA) and Argonne National Laboratory (APS)(Jeff Hill, Bob Dalesio & Marty Kraimer)
• 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 and webpage:
http://www.aps.anl.gov/epics/• Two collaboration meetings every year (spring and autum)
in turns in America, Asia, and Europa• Collaborative efforts vary
– Assistance in finding bugs– Add manpower: Share tools, schemes, and advice
GTA: Ground Test AcceleratorAPS: Advanced Photon Source
Elke Zimoch, 3. October 2011
Are there alternatives to EPICS?
System Name:• EPICS• TANGO
• DOOCS• Tine
• PVSS(Cern)
Pro:Bugs are already found
Contra:Complicated to adaptto your problems
Pro:Your problems solvedperfectly
Contra:You are on your own(no one can help)
Pro:Outsource your problems
Contra:Expensive
Collaborations:Used at more than one Lab
Single Site Systems:Developed and used in one Lab
Commercial System
Elke Zimoch, 3. October 2011
The architecture of EPICS
• For EPICS, client and server refer to their Channel Access 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
Network based Client/Server Model (hence the EPICS logo):
EPICSClient
CAClient
CA
ServerCA
ServerCA
Client Layer
Server Layer
Connection Layer
Elke Zimoch, 3. October 2011
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
Process
Variables
CAS
Process
Variables
CAS
Process
Variables
CAS
Process
Variables
CAS
Process
Variables
CAS
Process
Variables
CAS
Process
Variables
CAS
EPICS Database
Elke Zimoch, 3. October 2011
Some Details of Channel Access
CA Client
CA Server 1 CA Server 2 CA Server 3
Network
1. Query: Broadcast (UDP)
2. Reply: direct connection (UDP)
3. All further queries and replies work directly (Point-To-Point) (TCP)
Default UDP ports: 5064 and 5065Default TCP ports: 5064 and 5065
Defined in environment variablesNeed to be free in firewall!
Elke Zimoch, 3. October 2011
Channel Access Commands
Process Variables:
Channel Access Server
S1A:H1:CurrentAO
S1:P1:x
S1:P1:y
S1:G1:vacuum
Channel Access ClientWho has a PV named “S1A:H1:CurrentAO”?
I do.
What is its value?
25.5 AMPS
Change its value to
30.5
“connection request” or “search request”
OK, it is now 30.5
30.5 is too high. It is now set to the maximum value of 27.5.
You are not authorized to change this
value
Notify me when the value changes
It is now 20.5
AMPS
It is now 10.5
AMPS
It is now 0.0023 AMPS
“put” or
“caput”
“get” or
“caget”
“set a monitor”
“post an event”
or
“post a monitor”
“put complete”
or
or
CA Server
CA Client
For all fuctionality see
http://www.aps.anl.gov/epics/docs/ca.php
for EPICS R3.14
Channel Access
Reference Manual
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture• What is EPICS?• Examples from the EPICS tool box• What are Records?• How to set up an IOC?• Conclusion
Afternoon: Hands-on training• Implementation of a Cooling System (IOC)• Some simple clients (medm)• Some more exercises
Elke Zimoch, 3. October 2011
Examples from the EPICS software tool boxO
utp
ut
Inp
ut
CA Server IOC
Control Room
CA Client CA Client
CA ServerServer Programs:(user programs)
iocCoreRecords
Client Programs:alarmhandler
Striptool, medm,many more …
(user programs)
Cannel Access:(UDP/TCP)
4th Layer
Hardware: maybe
controllers and PLCs
Elke Zimoch, 3. October 2011
What is an IOC?
• 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) or 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
IOC means
Input Output Controller
We will come back to
details of EPICS
Records later
Elke Zimoch, 3. October 2011
Some EPICS Client Programs
(from the EPICS Website – very incomplete, selection is no assessment)• ALH: Alarm Handler • BURT: Backup and Restore Tool • CASR: Host-based Save/Restore • CAU: Channel Access Utility • Channel Archiver (SNS) • CSS and BOY: Control System Studio and Best OPI,Yet• Channel Watcher (SLAC) • EDM: Extensible Display Manager (ORNL) • JoiMint: Java Operator Interface and Management INtegration Toolkit
(DESY) • Knobs: Knob Manager and KnobConfig, an Interface to SunDials • MEDM: Motif Editor und Display Manager • StripTool: Strip-chart Plotting Tool • and many more …
+ Command line tools (caget, caput, …)
Elke Zimoch, 3. October 2011
Client Program: Command line tools
• Read a PV named <NAME>
caget NAME
• Write a PV named <NAME>
caput NAME value
• Get information about that Record
cainfo NAME
• Start a monitor
camonitor NAME (Cancel with [Ctrl] + [c])
>caget ARIDI-PCT:CURRENTARIDI-PCT:CURRENT 350.56>
>caput ARIDI-PCT:CURRENT 401.5Old: ARIDI-PCT:CURRENT 350.56New: ARIDI-PCT:CURRENT 401.5>
>cainfo ARIDI-PCT:CURRENTARIDI-PCT:CURRENT State: connected Host: sls-cagw-1 Access: read, no write Data type: DBR_DOUBLE Element count: 1>
>camonitor ARIDI-PCT:CURRENTARIDI-PCT:CURRENT 250.542ARIDI-PCT:CURRENT 250.537ARIDI-PCT:CURRENT 250.533ARIDI-PCT:CURRENT 250.525>
Elke Zimoch, 3. October 2011
Client Program: medm
Elke Zimoch, 3. October 2011
Client Program: StripTool
time
channelvalues
Elke Zimoch, 3. October 2011
Client Program: Alarmhandler
• Records have predefined alarm states (SEVR):– NO_ALARM– MINOR– MAJOR– INVALID– not connected
to the client (no Record state)
everything okwarningalert (non controls problem) CA server ok, hardware errorNo server!
Tree structure of Records
Guidance
Panel with moreInformation
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture• What is EPICS?• Examples from the EPICS tool box• What are Records?• How to set up an IOC?• Conclusion
Afternoon: Hands-on training• Implementation of a Cooling System (IOC)• Some simple clients (medm)• Some more exercises
Elke Zimoch, 3. October 2011
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
XYZ1234
Employee : James Bond
Badge Number: 007
Address : Whitehall, London
Salary : £70070.07
unique name
fields Data
Elke Zimoch, 3. October 2011
Configured by developer
Make a Record from a Measured Value
VAL SEVR TIME
295,5with a unit mA
17.2.2005 14:21:16
NO_ALARM
with technical limits 0 bis 400
with graphical limits 0 bis 370
with a description „Beam current in SR“
A value with a data type
with a unique name ARIDI-PCT:CURRENT
ai
record (ai, "ARIDI-PCT:CURRENT") {
with a time stamp
Readback from hardware/driver
with a severity (alarm status)
field (EGU, "mA")field (EGUF, "400")field (EGUL, "0")field (HOPR, "370")field (LOPR, "0")field (DESC, "Beam current in SR")field (DTYP, "HY8401")field (INP, "#C3 S0 @")
}
Elke Zimoch, 3. October 2011
Records and Channel Access Process Variables
• A PV name is comprised of two parts– The record name, and– the name of a field belonging to that record
• For example…
A record name
ARIDI-PCT:CURRENT
A field name
EGU.
A dot to join them
A Process variable name
• No dots allowed in Record names!
• 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”
that means:
most record fields
can be accessed
individually
Elke Zimoch, 3. October 2011
What do Records do?
•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
• Depends on
1. Record Type
2. 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
incomplete
list!
Elke Zimoch, 3. October 2011
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
means:
Trigger Record to do what it
is configured to do.
Elke Zimoch, 3. October 2011
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): html: http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref-1.html
pdf: http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref.pdf
• More Records exist.For example Motor Record (part of synApps package):http://www.aps.anl.gov/bcda/synApps/index.php
Elke Zimoch, 3. October 2011
Example: Measure a Value
Operator
Value (34 °C)
CA Client: medm
Driver
Device Support
Record Support record … field (SCAN, “.1 second”) field (DTYP, “Hy8401”) field (INP, “#C3 S0 @”) field (VAL, “34”)
every 0.1 seconds the recordasks the driver for a valueand the driver reports back
medm sets a CA monitor
every time the value changesrecord triggers callback
IOC
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture• What is EPICS?• Examples from the EPICS tool box• What are Records?• How to set up an IOC?• Conclusion
Afternoon: Hands-on training• Implementation of a Cooling System (IOC)• Some simple clients (medm)• Some more exercises
Elke Zimoch, 3. October 2011
IOC Overview: What has to be done?
EPICS base
some functions: dbLoadDatabase dbLoadTemplate iocInit
driver(optional)
seq (snl code)(optional)
your own C-code(optional)
make startup script: st.cmdcall iocCore functions
text file
dbd files:xxxApp.dbd(data base definitions)EPICS Version dependent!additional files for drivers
text files
substitutionfiles template filetemplate file
template file
text files
database files (db)
text files
configureRecords
comes withEPICS baseor drivers
configureswhat theIOC does
iocCore
xxxApp
Elke Zimoch, 3. October 2011
Steps towards your IOC (1/4)
• What you need before you start– Build tools: gcc, make, tar, gzip– Perl scripting language– Development package of readline– Development packages of X11 and Motif– A text editor (e.g. nedit, kwrite, emacs)
• Browse EPICS home http://aps.anl.gov/epics– Get latest Base– Get Extensions:
Config files 3.14, medm
for EPICS extensions like
medm
the latest is not always best: have a look at techTalk, read
“Known Problems” and “Release Notes”
read “Installation Instructions” (Read Me) as well …
We use
baseR3.14.12-1
today
On MS Windows
you need cygwin
in addition
Elke Zimoch, 3. October 2011
Steps towards your IOC (2/4)
• Extract Base and Extension packagestar xvfz baseR3.14.12-1.tar.gz
tar xvfz extensionsTop_20070703.tar.gz
tar xvfz medm3_1_5.tar.gz –C extensions/src
• Build Baseexport EPICS_HOST_ARCH=linux-x86
cd base-3.14.12-1
make
export PATH=~/base-3.14.12-1/bin/linux-x86:$PATH
• Test the installationsoftIoc
vxWorks-ppc604win32cygwin-x86
Elke Zimoch, 3. October 2011
Steps towards your IOC (3/4)
• Build Extensions (here: medm)cd extensions/configure
– Edit the RELEASE filenedit RELEASE• Set correct path to EPICS Base, e.g.
EPICS_BASE=/home/epics/base-3.14.12-1
make
cd ../src/medm3_1_5
make
export PATH=~/extensions/bin/linux-x86:$PATH
• Test the installation
medm
This is something you often have to do
with EPICS components
Elke Zimoch, 3. October 2011
Steps towards your IOC (4/4)
• Make environment variables permanent– Edit ~/.basrc and add variables:
export EPICS_HOST_ARCH=linux-x86export EPICS_BASE=/home/epics/base-3.14.12-1export EPICS_EXTENSIONS=/home/epics/extensionsexport PATH=$EPICS_BASE/bin/$EPICS_HOST_ARCH:\
$EPICS_EXTENSIONS/bin/$EPICS_HOST_ARCH:$PATH
• EPICS can also be installed centrally (and maybe should)– e.g. /opt/epics/base-3.14.12 and
/opt/epics/extensions– or /usr/local/epics/…
Elke Zimoch, 3. October 2011
How does an st.cmd file look like (on Linux)?
set environmenton the IOC
load dbd filesand register them
load records
start IOC
configure hardware(depends on driver)
start Application
“trainingIOC” should be meaningful (not exampleIOC or myIOC)
more IOC functions in EPICS Application Developer's Guide:
http://www.aps.anl.gov/epics/base/R3-14/12-docs/AppDevGuide.pdf
Elke Zimoch, 3. October 2011
How to create a record 1: db file
Record Type Record Name
Driverinformation
periodicRecordprocessing
Records can be created in any editorGraphical creation with VDCT (not used at PSI)
Elke Zimoch, 3. October 2011
How to create a record 2: substitutions and templates
• 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 motors db file gets lengthy– If the device not only needs one record but
more(BPM with at least x, y, and intensity)db file gets even more lengthy and confusing [spell maintenance nightmare]
• Solution provided by EPICS:substitution (with macro definition) and template files
Elke Zimoch, 3. October 2011
How to create a record 2: substitutions and templates
DEVICE = MTRT1$(DEVICE)-TEMP:READ
MTRT1-TEMP:READ
there is no standard file
extension for substitution and
template files in EPICS!
At PSI:
xxx.subs and yyy.template
Elke Zimoch, 3. October 2011
IOC System in real … step by step
1. Prepare Application (make EPICS base + driver)2. Write startup script (st.cmd file)3. Write records (db file or substitution + template files)4. Save to boot directory5. Set boot parameters of VME computer6. Reboot
– Load and start operating system (vxWorks)– Load and start st.cmd
• Load dbd files• Configure hardware• Load records• Start IOC (iocInit) and create records
7. Test functionality8. Debug files and go to step 6
IOC Development: configure text files (no code, no make)
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture• What is EPICS?• Examples from the EPICS tool box• What are Records?• How to set up an IOC?• Conclusion
Afternoon: Hands-on training• Implementation of a Cooling System (IOC)• Some simple clients (medm)• Some more exercises
Elke Zimoch, 3. October 2011
10 really neat Things about EPICS
1. It is free
2. It is Open Source
3. There are lots of users
4. All a client needs to know to access data is a PV name
5. You can pick the best tools out there …
6. … or build your own
7. The boring stuff is already done
8. There is a lot of expertise available close by
9. A good contribution becomes internationally known
10. It does not matter, if you need 10 or 10 million PVs(it is scalable)
11. It is fun (but maybe do not tell this to your management)
Elke Zimoch, 3. October 2011
Where to learn more?
• EPICS home pagehttp://www.aps.anl.gov/epics/
• Tech Talk: listen (and learn)http://www.aps.anl.gov/epics/tech-talk/index.php
• Getting Started with EPICS lecture serieshttp://www.aps.anl.gov/epics/docs/GSWE.php
• Collaboration Meeting (twice a year)http://www.aps.anl.gov/epics/meetings.php
Elke Zimoch, 3. October 2011
Contents
Morning: Introduction to EPICS Lecture• What is EPICS?• Examples from the EPICS tool box• What are Records?• How to set up an IOC?• Conclusion
Afternoon: Hands-on training• Implementation of a Cooling System (IOC)• Some simple clients (medm)• Some more exercises
Elke Zimoch, 3. October 2011
Problem:
In the LINAC we have a water chiller that must be turned ON whenever the average temperature of two temperature sensors rises above a set point. The set point is nominally 45 degrees centigrade.
Example: Cooling System
Binary out
MTRT1-LI:COOL-SW
Calculation
MTRT1-LI:CALC
CALC: ( (A+B)/2 ) > C
C: 10
SCAN: 10 second
Analog In
MTTR1-LI:TEMP1
EGU: deg C
VALINP
EGU: deg C
VALINP
INPB
INPA
VAL DOL OUT
T2Sensor
SensorT1
IOC
DatabaseADC
ADC
Binary I/O
ChillerAnalog In
MTRT1-LI:TEMP2
Elke Zimoch, 3. October 2011
• files prepared in directoryTraining/vxWorks
• Installation directory:/home/ioc/MTEST-VME-T1
• Installation:copy (cp) st.cmd and db filecp st.cmd /home/ioc/MTEST-VME-T1cp COOLER.db /home/ioc/MTEST-VME-T1
Elke Zimoch, 3. October 2011
medm – say it with Pictures
MTRT1-LI-COOL:TEMP1
Elke Zimoch, 3. October 2011
IOC System in real … step by step
1. Prepare Application (make EPICS base + driver)2. Write startup script (st.cmd file)3. Write records (db file or substitution + template files)4. Save to boot directory: /home/ioc/<IOC-NAME>5. Set boot parameters of VME computer6. Reboot: type reboot in minicom window
– Load and start operating system– Load and start st.cmd
• Load dbd files• Configure hardware• Load records• Start IOC (iocInit) and create records
7. Test functionality8. Debug files and go to step 6