EPICS (Experimental Physics and Industrial Control System) is a set of Open Source software tools, libraries and applications developed collaboratively and used worldwide to create distributed soft real-time control systems for scientific instruments such as a particle accelerators, telescopes and other large scientific experiments. Light Sources in the US (e.g. APS, NSLS-II, SLAC) and around the world (e.g., Diamond Light Source (UK), BESSY (Berlin), Swiss Light Source) use EPICS for their beamline controls.
It mostly consists of servers (called Input/Output Controllers or IOCs) who perform real-world I/O and local control tasks, and publish this information to clients using the Channel Access (CA) that can be accessed through the network using Process Variables (PV.)
{image of example of IOC} --- {image of example of channel access}
Notes:
the latest version of EPICS is EPICS v7, which started when ideas from EPICS v3 and EPICS v4 merged (there is no EPICS v5 or v6)
EPICS works best on a Linux machine (e.g. Ubuntu 26.04, even on a Raspberry Pi.) EPICS is not straightforward to install on a Windows machine but it can be done use Windows WSL
help can be summoned at tech-talk@aps.anl.gov and in the Matrix Channel
There is no graphical user interface, but many motors can be conveniently displayed using medm (or CS-Studio Phoebus)
Here's an example on how to create a small interactive window for a generic motor with a PV name DMC02:E :
medm -x -macro “P=DMC02:, M=E” ~/bin/bl531/display-files/adl/motorx_all.adl
SynApps is a collection of software tools that help to create a control system for beamlines. It contains beamline-control and data-acquisition components for an EPICS based control system. It has a lot of IOC readily available for common motors.
EPICS works best when the motors and sensore are on a ethernet subnet, but some motors do work with USB, it may be a good idea to create a dedicate server to run the IOC next to the device: EPICS on Raspberry Pi
Practical EPICS Training, IOC Basics (Kevin Peterson, X-ray Science Division Beamline Controls and Data Acquisition, Argonne National Laboratory, 2023)
https://www.aps.anl.gov/BCDA/EPICS-Process-Variable-Naming-Conventions
https://wiki.bnl.gov/nsls2controls/index.php/Standards-Naming_Convention_Signal_Names
download pdf
Bluesky (https://blueskyproject.io/bluesky/) is a data collection framework in python. it can be installed this way using pip:
pip install bluesky
Its main component is the RunEngine, which is basically a continuous loop that runs your experiments in a simple maner. When everything is set up (python objects for motors and sensors, and tiled for data storage – see below, here's how a basic experiment loop looks like:
uid = RE(scan([basler_camera], voltage_motor_AO0, 0, 10, 2)
where RE is the RunEgine, scan is a bluesky plan (from a list of standard scan, e.g. 1D scan, 2D scan, etc.), basler_camera and voltage_motor_AO0 are ophyd object controlling some device in the experiment, and uid is a unique id associated to the scan, so that the data can be recalled later on.
The bluesky runengine need important subcomponents to work properly, mainly ophyd (which is how you interface with the motors and the sensors) and tiled, which is used to store and recall the data data.
Ophyd (https://blueskyproject.io/ophyd/) is a wrapper for motors and sensors in python. It works natively wtih EPICS, where it will turn any EPICS PV string into a python object that can control a motor or a sensor:
o_motor_x = ophyd.EpicsMotor('ALS531:motor.x_pos_mm', name='tth')
If you have a python library that allows you to control a motor, you can create an ophyd class to wrap it so that it can be used. Here's an example borrowed from Hugo Delgado-Calederon for an Attocube laser interferometer: attocube_ophyd_driver.py
Note that ophyd is inherently synchronous, meaning that you have to wait for a motor to stop before you can do anything else. In many case (e.g. fast acquisition >10Hz or fly scans), you want to create aysnchronous classes, and used ophyd-async instead:
https://blueskyproject.io/ophyd-async/main/index.html
Tiled (https://blueskyproject.io/tiled/) is a data access service for data-aware portals and data science tools. Tiled has a Python client and integrates naturally with Python data science libraries, but nothing about the service is Python-specific; it also works from a web browser or any Internet-connected program.
Bluesky Queue Server (https://blueskyproject.io/bluesky-queueserver/) is a set of tools that provide alternative method for executing Bluesky plans. Traditionally Bluesky was used interactively from IPython environment as demonstrated in Bluesky tutorials. A session would start by loading startup scripts that define beamline-specific devices and plans and then interactively running plans one-by-one from IPython prompt or executing a script that runs a sequence of plans. Interactive IPython workflow is currently the most common way to use Bluesky.
Alternatively, the Queue Server allows to run Bluesky in a dedicated Python process (Run Engine worker environment). The worker environment is created and managed by Run Engine (RE) Manager (see start-re-manager), which could be run as an application or a service. Bluesky plans are executed by populating and starting the plan queue maintained by RE Manager. The queue is editable and can be modified by users at any time: queue items may be added to the queue, replaced (edited), moved to different positions and removed from the queue.
Beamline optimization (blop) is a python package that allows to perform automated beamline alignment using the bluesky framework. It is maintaineed by Tom Morris and Max Rakitin from National Synchrotron Light Source II at Brookhaven National Laboratory.
https://nsls-ii.github.io/bloptools/
python3 -m pip install bloptools
Bloptools hands-on workshop (Tom Morris, August 11, 2023)
sirepo-bluesky is a python package that allows you to switch between a real beamline controls and a surrogate
https://nsls-ii.github.io/sirepo-bluesky/