520 likes | 634 Views
Using EPICS for Beamline Control and Data Acquisition. Mark Rivers GeoSoilEnviroCARS, Advanced Photon Source University of Chicago. Acknowledgements. Many slides borrowed from the “Getting Started with EPICS” lecture series held over past year at APS. All talks are online
E N D
Using EPICS for Beamline Control and Data Acquisition Mark Rivers GeoSoilEnviroCARS, Advanced Photon Source University of Chicago
Acknowledgements • Many slides borrowed from the “Getting Started with EPICS” lecture series held over past year at APS. All talks are online • Ned Arnold, APS, Introduction to EPICS • Ken Evans, APS, MEDM • Tim Mooney, APS, Beamline controls
Outline • Goals for Beamline Control and Data Acquisition (BCDA) systems • Brief Overview of EPICS • Advantages of using EPICS for BCDA • Where is EPICS being used for BCDA today • What’s available for EPICS BCDA • The synApps module from APS • Cover some basics today • More details in talks on detectors, feedback tomorrow • What needs to be done
Characteristics of an Ideal Beamline Control and Data Acquisition System • Easy to use • Intuitive Graphical User Interface (GUI) • Customized for the specific experiment • Fast, efficient • Expert users don’t want to navigate GUI • Powerful, able to accomplish any task, even if it has never been done before • Able to use existing applications that have substantial development and user familiarity (Blu-Ice, SPEC, Photon Factory EXAFS program, etc.) • Can use different applications to run the same equipment for different experiments (i.e. not tied into Labview or SPEC drivers) • Available off-the-shelf, no development required (you wish!)
Introduction: What is EPICS? • A collaboration of the controls groups of many research organizations that use the EPICS tool-kit. • A distributed architecture that supports a wide range of solutions from small test stands to large integrated facilities. • A set of tools that reduces software application and maintenance costs by providing: Configuration tools in place of programming A large installed base of tested software A modular design that supports incremental upgrades Well defined interfaces for extensions at every level
What is EPICS? • A Collaboration • A Control System Architecture • Network-based “client/server” model (hence the EPICS logo) CA CA Client Client CA CA Server Server • For EPICS, client and server speak of their Channel Access role • i.e. Channel Access Client & Channel Access Server
What is EPICS? StripTool MEDM • Channel Access clients are programs that require access to Process Variables to carry out their purpose CAC CAC CAS CAS Process Variables Process Variables • The “service” that a Channel Access server provides is access to a Process Variable* * A Process Variable (PV) is a named piece of data.
What is EPICS? • Process Variable • A Process Variable (PV) is a named piece of data associated with the beamline (e.g. status, readback, setpoint, parameter) • Examples of PV names and values: • 13IDA:cc43.2e-08 torr (Cold cathode gauge 4) • 2IDA:m1.RBV 0.323 mm (Motor 1 actual position) • 13IDA:MonoEnergy 12.454 keV (Mono energy set point) • S:SrCurrentAi 101.2 mA (APS ring current) • APS:Mode ‘Stored Beam’ (APS storage ring mode) • 13IDC:mca1{0, 0, 1, 1, 1, 102, 210, 262, 0, 0, …} (MCA spectrum)
What is EPICS? • Process Variable • A Process Variable is a named piece of data with a set of attributes • Examples of Attributes: • Alarm Severity (e.g. NO_ALARM, MINOR, MAJOR, INVALID) • Alarm Status (e.g. LOW, HI, LOLO, HIHI, READ_error) • Timestamp • Number of elements (array) • Normal Operating Range • Control Limits • Engineering Unit Designation (e.g. degrees, mm, MW)
CAS CAS Process Variables Process Variables CAS CAS Process Variables Process Variables CAS CAS CAS CAS Process Variables Process Variables Process Variables Process Variables CAS CAS Process Variables Process Variables What is EPICS? • A Control System Architecture • Network-based “client/server” model where the basic data element is a Process Variable • The Channel Access Protocol defines how Process Variable data is transferred between a server and client • The entire set of Process Variables establish a Distributed Real-time Database of machine status, information and control parameters
What is EPICS? My Special Data Collection Program StripTool MEDM • Any tool/program/application that abides by the Channel Access protocol could be described as “EPICS Compliant”. CAC CAC CAC • EPICS can be viewed as a “toolkit” of EPICS compliant programs. One can select the appropriate tool for their need or develop their own. CAS CAS CAC CAS CAC My Accelerator Simulator Code (PVs) iocCore (PVs) LabView (PVs)
Typical Realizations of an EPICS System IOC IOC IOC CAS IOC CAS Driving a motor with EPICS circa 1995 circa 2002 Commercial Instruments Custom Chassis/Panels Technical Equipment
CA Server CA Client Channel Access in One Slide “connection request” or “search request” “get” or “caGet” “put” or “caPut” “set a monitor” Who has a PV named “S1A:H1:CurrentAO”? Change its value to 30.5 Notify me when the value changes What is its value? Channel Access Client Channel Access Server I do. 25.5 AMPS OK, it is now 30.5 It is now 20.5 AMPS It is now 10.5 AMPS It is now -0.0023 AMPS Process Variables: “put complete” “post an event” or “post a monitor” S1A:H1:CurrentAO S1:P1:x S1:P1:y S1:G1:vacuum 30.5 is too high. It is now set to the maximum value of 27.5. or You are not authorized to change this value or
IOC Software in One Slide Network (Channel Access) [IOC Software] EPICS “iocCore” services and routines [EPICS-supplied] Application Specific Database [of Records] Application Specific Programs [e.g. State Notation Language] Record Record Record Record Record Record Record Record Record Record Record Record Record Record Record Record Record Record Record Record Device/Driver Support [EPICS-supplied/user-extensible] New Device Support “Supported” Instruments “New” Equipment “Supported” Instruments “Supported” Instruments “Supported” Instruments Shared/Provided Required Optional
Standalone CA Clients (from EPICS Website) • ADT: Array Display Tool • ALH: Alarm Handler • AR: Data Archiver (the original, deprecated) • BURT: Backup and Restore Tool • CAEX: Channel Access Examples • CASR: Host-based Save/Restore • CAU: Channel Access Utility • Channel Archiver (SNS) • Channel Watcher (SLAC) • DM2K: Display Manager 2000 (BESSY) • EDD/DM: Editor and Display Manager (LANL) • EDM: Extensible Display Manager (ORNL) • HistTool: Data Histogramming Tool • JoiMint: Java Operator Interface and Management INtegration Toolkit (DESY) • Jprobe: Java Version of Probe, a Channel Monitoring Program • MEDM: Motif Editor and Display Manager • Probe: Motif Channel Monitoring Program • StripTool: Strip-chart Plotting Tool • Yviewer: Data Visualization Tool
EPICS Programming/Scripting/Display Languages • C, C++ • tcl/TK • Visual Basic • Labview • IDL • Python • JAVA • Matlab • Unix shells • Any other language with the ability to call C functions in a shared library or DLL
Key Features of IOC software … • Two primary application specific components: • The real-time database of records (required) • State Notation Language programs used to implement state oriented programs (finite-state machine) • Machine status, information and control parameters are defined as “records” in the application specific database. • The data within a record is accessible via Process Variables. • Records have some functionality associated with them (scaling, filtering, alarm detection, calculations, etc). Different record types have different functions and uses. • Records are frequently associated with I/O equipment that requires unique “device support” for that instrument.
Ten really neat things about EPICS • It’s free • It’s 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 • A good contribution becomes internationally known • By following a few simple rules, you get a lot for free
Ten really neat things about EPICS for BCDA • There are lots of beamlines using it (next slide) • Most record types for beamline components and common operations already exist • Motors, monochromators, multi-channel analysers, A/D, D/A, digital I/O, scanning, save/restore, save_data, etc. • Lots of device support and drivers for commercial devices in these classes already exists • There are high-level applications available for free (e.g. EXAFS) or commercially (e.g. SPEC) • There is a lot of expertise available close by because Australian Synchrotron accelerator will use EPICS • You can have a basic beamline up and running very quickly with supported hardware, add features as time permits • I converted 4 NSLS beamlines from CAMAC/VMS to EPICS in less than 1 week
Synchrotron Beamlines Using EPICS • Almost all beamlines (> 30) at the Advanced Photon Source • Growing number of beamlines at NSLS (>10) • All beamlines at the Swiss Light Source (?) • Probable for beamlines at Diamond • Canadian Light Source (just beginning, not using APS beamline code) • A few beamlines at the ALS at Berkeley (?)
Client Tool CA Client CA Server DB Common Record Support Device Support Driver Support IO bus Hardware device EPICS Software Architecture for I/O Control Optional
Record Support • Provides implementation for a record type • Lots of records come with standard EPICS • Some have been added in the synApps beamline control package Example records • ai (analog input, .VAL field is single number) • ao (analog output, .VAL field is a single number) • motor (lots of fields, e.g.) • .VAL = target position • .RBV = readback position • .VELO = desired velocity • .DMOV = done moving flag • MCA (multichannel analyser, lots of fields, e.g.) • .VAL = histogram array • .PRTM = preset real time • .STRT = start acquisition when set to 1 • .ACQG = acquire busy flag
Overview of synApps • A collection of EPICS applications for synchrotron-beamline users. Collaboration between APS BCDA group and other beamlines at APS and elsewhere http://www.aps.anl.gov/aod/bcda/synApps • EPICS modules and build/configuration tools: • Modules: autosave, calc, camac, ccd, dac128V, dxp, ip, ip330, ipUnidig, love, mca, motor, optics, quadEM, sscan, std, vme, xxx • Build/config: config and utils directories • 160,000 lines of code (C, SNL, databases), hundreds of medm screens • Related clients, libraries, and visualization tools: • IDL: scanSee, mca display, ezcaIDL, ezcaScan, ez_fit, HDF translator/browser, Ascii-format plotter, image processors, etc. • CA-Server based CCD control
synApps modules • Modules contain the following kinds of support: • Compiled code; libraries • E.g., record and device support • State-Notation-Language programs • EPICS databases and autosave-request files • A database is a program written in a high-level language. • One or more copies of a database can be run, each with its own private variables (PV’s). • The database designer recommends PV’s to be autosaved by naming them in a .req file; you can override with a private copy of the file. • MEDM-display files • The default user interface • Documentation
Other EPICS modules used by synApps • asyn (driver/device support) • ipac (Industry Pack support) • seq (State Notation Compiler) • genSub (General subroutine record) • vxStats (IOC statistics) • allenBradley (PLC support)
autosave module • Records latest values of selected EPICS PVs; restores those values when the ioc restarts. • not an archiver; only the latest value is saved • not the same as saveData, which writes scan data • When a list list of PV’s is saved, the entire list is written, even if only one PV has changed. • Can save/restore any scalar or array-valued PV
...autosave module • PV lists can use include files (e.g., <database_name>.req), include path. • Database developer can supply default include file with database. • User can override with custom include file. • Save triggers: • on change of any PV in the list • periodically • on change of a trigger PV • manual • User can reload save sets. • User can choose to save redundant filesAutosave reports status via EPICS PV’s
calc module • Support for evaluation of string or numeric expressions entered at run time (or at database-configure time) • Records • sCalcout – like calcout, but also supports string expressions; user can specify wait-for-completion. • swait – like calcout, but uses recDynLink (no “PP MS” link attributes) • transform – like 16 calcout records that share a PV data pool • Other code • string-calc engine • sCalcout soft device support (with wait-for-completion option) • interpolation routines for genSub record • (yet another) averaging routine for sub record
ccd module • Support for area detectors (CCD’s and image plates) • Supported devices • MAR 165 CCD • MAR 345 image-plate reader • Roper (all WinView-supported CCD’s, including former Princeton and most former Photometrics devices) • Bruker SMART CCD • Can control, at minimum • exposure time • file name • data-acquisition start • wait for acquisition to complete • much more for most devices • Details in talk tomorrow
dac128V module • device support, database, and MEDM displays for dac128V IndustryPack module • 8-channel, 12-bit DAC • Support exists to run a DAC channel manually, or according to an algorithm written at run time, or as a scan positioner, or as part of a PID feedback loop. • Good model for D/A converter support, even if you use different hardware
dxp module • record, device support, databases, and MEDM displays for XIA DXP and Saturn spectroscopy systems • dxp record for setting DXP parameters • device support for the mca record • More details in talk tomorrow
ip module • device support, SNL code, databases, and MEDM displays for many message-based devices • Supports lots of benchtop RS-232/GPIB instruments, e.g. • Keithley multimeters • Stanford Research Systems current amplifiers • MKS ion gauge controllers • Physical Instruments ion pump controllers, TSPs • Lakeshore temperature controllers • … • deviceCmdReply • Used to write support at run time for one command/reply message • sCalcout to format output string • asyn record to write/read device • sCalcout record to parse reply • devXxStrParm device support • Generic support for many record types (ai, ao, bi, bo, etc.) with message based devices
ip330 module • device support, databases, and MEDM displays for the IP330 ADC IndustryPack module • 16/32 channel, 16-bit ADC • ip330Scan for periodic, averaged reads of ADC channels • ip330Sweep, with the MCA record, for using ip330 as a waveform-digitizer • ip330PID for using the ip330 in a fast-feedback loop • Good model for A/D converter support, even if you use different hardware
ipUnidig module • device support, databases, and MEDM displays for the IPUnidig digital I/O IndustryPack module • Interrupt can call any driver, which is useful for devices that do not have interrupts themselves • Good model for digital I/O modules, even if you use different hardware
mca module • Support for multichannel analyzers, multichannel scalers, and other array-valued detectors • mca record • device support • Canberra 556 AIM module (MCA and ICB controller) • DSA-2000 Ethernet MCA • various Canberra-ICB modules for spectroscopy • SIS 3801 (Struck STR7201) MCS • (DXP support in dxp module) • (IP330 support in ip330 module) • (quadEM support in quadEM module) • More details in talk tomorrow
motor module • Motor record and device support • Motors are the single most important component of beamline control • Provides: • stepper and servo motors • VME, CAMAC, RS-232, GPIB, Ethernet controllers • More than 20 types at present • soft-motor support • Put motor “face” on, e.g., a DAC channel • Drive a hard motor through a nonlinear transform of 1 or more real motors • user/dial/raw coordinates • backlash-takeout algorithm • pre/post move commands • many more features
optics module • Slits and mirrors • Four virtual positioners; two real motors • Automatic sync to motor positions • Completion reporting • Monochromators • Nondispersive double-crystal • Geometries: (Y1, Z2), (Y2, Z2) • Crystal species: Si, Ge, Diamond, Si (77K) • Miller indices, allowed reflections • Operational modes: • Use/Set • Manual/Auto • Managing the vertical beam offset • Automatic sync to motor positions
…optics module • …Monochromators • Spherical grating • Geometrical variables: • 1) Grating line density; radius • 2) Tangent-arm length • 3) Diffraction order • 4) Input/output slit distances • Operational modes: • Use/Set • Manual/Auto • Grating-stripe list • Manual sync to motor positions
…optics module • Optical table • Table record supports a six-degree-of-freedom optical table. • User/client can write either to (x, y, z, qX, qY, qZ), or to underlying motor records. • Table rotates about user-specified point. • Table database includes a list of rotation points, selected by menu. • Can recover table position from motor positions • Partial support for fewer than six degrees of freedom
…optics module • Optical table • Geometries • SRI • GeoCARS • Newport • PNC GEOCARS PNC SRI NEWPORT - Calibration/sync • Use/Set – changes to [X, Y, ..]. move table / change calibration • Zero – redefine current [X, Y, …] as zero • Sync – update [X, Y, …] from motors, honoring calibration • Init – clear calibration and sync to motors • Table record sets motor speeds so that motors start/stop together.
sscan module • Support for user-programmable data-acquisition • sscan and busy records • saveData • recDynLink • A one-dimensional scan: • Do NPTS times: • Set conditionse.g., move motors; wait for completion • Trigger detectorse.g., start scaler; wait for completion • Acquire dataread detector signals; store in arrays • Write data to NFS file • Multidimensional scan: • Same as a 1-D, but detector trigger executes inner-loop scan. • saveData monitors a set of sscan records, determines scan dimension when scan starts, and writes data as it is acquired.
...sscan module • scan features: • Three 1-D scan types: constant-step-size, table-driven, fly • Unlimited number of data points, scan dimensions • 0-4 positioners, 0-4 detector triggers, 0-70 detector signals • Acquisition from scalar and 1-D-array-valued PV's • Detector/client wait, data-storage wait • Pause/resume, abort • Double buffered: can write 1-D acquired data during next 1-D scan • saveData writes self-describing XDR-format (“.mda") files to NFS-mounted disk (vxWorks only, at present). • A positioner can have private scan parameters (scanparm record). • After-scan actions include move to peak, valley, and edge. • scanparm record + after-scan action = automated 1-D alignment, so you can easily implement an “Align” button.
…sscan module • The sscan record • performs 1-D scan • before-scan link – optional completion callback • positioner: any writable, numeric, scalar PV (menus, enums are ok) • detector trigger: any writable, numeric, scalar PV • detector signal: any readable, numeric, scalar or 1D array PV • array detectors: exactly <scanRecord>.NPTS elements are acquired • array trigger: callback indicates array data are ready to read • after-scan link – optional completion callback • pause/resume • abort (<scanRecord>.EXSC -> 0) wait for callbacks, cleanup • kill (two aborts in a row) abandon callbacks • handshake with multiple display / data-acquisition clients • handshake with data-storage client
Other data-acquisition-related software • Data-visualization tools for use with synApps • Run-time look at scan data • Offline tools for data-file manipulation • Supports 1-3 dimensional data • Distributed independently of ioc software • See lecture “Data Visualization.” • CCD data-acquisition tools • CCD module (see lecture “Detectors and Feedback”) • Portable CA Server based CCD support, and related software • http://www.aps.anl.gov/aod/bcda/dataAcq/index.php • Both of these solutions allow an EPICS CA client to drive data acquisition. • Both support ca_put_callback(), as required by the sscan record.
std module • Epid record • Extended PID record – more details tomorrow • Scaler record • Controls a set of counters with a common clock, gate, and trigger • String-sequence record • Like the seq record in base, but works for strings and numbers • Can choose to wait for completion after each step in sequence • Soft-motor database • Run-time programmable soft-motor/transform/hard-motor database • Quick solution for driving a motor through a nonlinear transform • Timestamp record [SLAC] • needed by SNS’ vxStats; currently not available in a module • 4-step database • Up to four steps of (set condition; read data) with an end calculation • Originally developed for dichroism experiments
vme module • VME record • Provides run-time access to VME bus • Great for testing hardware • Run-time programmed control of an unsupported VME board • Device support for VME hardware, includes: • Joerger scaler • APS bunch-clock generator • APS machine-status interface • Heidenhain encoder interpolator • Generic A32 VME interface • HP Laser interferometer • VMI4116 16-bit DAC • Acromag 9440 16-bit digital input
xxx module • Prototype user directory • Builds everything in synApps into a load module • Contains command files to load/configure everything in synApps • Contains sample top-level MEDM-display file • Contains sample script to set environment variables and start up the sample user interface • Contains table of recommended address/interrupt configuration for selected VME and IndustryPack hardware • Two ways to use this module • Make copies; run changePrefix; build; customize; run a beamline • this is the recommended use • detailed instructions in support/documentation 2) Reference/grab bag
A Couple of Anecdotes Single-crystal energy dispersive diffraction at high pressure • Good programmer, EPICS novice, IDL novice • Wanted to write code to collect single-crystal Laue diffraction with area detector, then rotate sample to put Laue spots into energy-dispersive detector • Got job done in weeks, amazed how easy to move motors, trigger CCD detector, read energy-dispersive detector MCA spectrum. He could concentrate on scientific problem • It runs at APS and at NSLS, since they both use EPICS, motor record, mca record
A Couple of Anecdotes Stress/strain measurements at high-pressure • Novice programmer, EPICS novice • Wanted to script a common operation that was keeping users at beamline overnight • Remove slits, install imaging CCD detector, take strain CCD image • Install slits, remove imaging CCD detector, take diffraction CCD pattern with diffractio CCD detector • Repeat above hundreds of times • Got job done in an hour, amazed how easy to move motors, trigger CCD detectors, saving data to user-specified file names, etc.