Difference between revisions of "EPICS 101"
Tguruswamy (talk | contribs) m (Adjust link text) |
|||
(24 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
== What is EPICS? == | == What is EPICS? == | ||
Line 6: | Line 4: | ||
EPICS is a '''distributed''' control system, which means that the IOC (software) can run on a different computer as the user interfaces. | EPICS is a '''distributed''' control system, which means that the IOC (software) can run on a different computer as the user interfaces. | ||
This page is dedicated to the definition of basic EPICS components ([ | This page is dedicated to the definition of basic EPICS components ([[EPICS_101#What_is_an_IOC.3F|IOC]], [[EPICS_101#What_is_a_PV.3F|PV]], [[EPICS_101#What_is_a_record.3F|record]], [[EPICS_101#What_is_a_database.3F|database]]). To build your own EPICS support, you can skip directly to [[IOC_101|How does one create an IOC]]. | ||
== What is an IOC? == | == What is an IOC? == | ||
Line 14: | Line 12: | ||
Any client, locally or on the network, can read and/or write a process variable using either '''channel access''' (CA) or '''PVaccess''' (PVA) network protocols. Clients might be another IOC, a GUI display manager (medm/caqtdm/CSS), or any other program with support for the EPICS protocols. Only the name of the process variable (in the form <code>'''prefix:record_name.field_name'''</code>) is required to read or write a PV. | Any client, locally or on the network, can read and/or write a process variable using either '''channel access''' (CA) or '''PVaccess''' (PVA) network protocols. Clients might be another IOC, a GUI display manager (medm/caqtdm/CSS), or any other program with support for the EPICS protocols. Only the name of the process variable (in the form <code>'''prefix:record_name.field_name'''</code>) is required to read or write a PV. | ||
Note | <u>Note</u>: | ||
* IOCs used to run on VMEs, but nowadays it runs on anything. | * IOCs used to run on VMEs, but nowadays it runs on anything. | ||
* IOCs usually talks to hardware, but that isn’t a requirement. | * IOCs usually talks to hardware, but that isn’t a requirement. | ||
Line 21: | Line 19: | ||
This script tells the IOC what database files to load and where those files are. When the IOC is told to load a database, it basically parses that database file, identifying the records that are contained within, and then generating the actual epics PVs that a user will interact with. | This script tells the IOC what database files to load and where those files are. When the IOC is told to load a database, it basically parses that database file, identifying the records that are contained within, and then generating the actual epics PVs that a user will interact with. | ||
'''Records''' and '''databases''' (lists of records) are configuration files describing the initial setup for '''PVs''' | '''Records''' and '''databases''' (lists of records) are configuration files describing the initial setup for '''PVs'''; the '''IOC''' is the software that manages the behavior of PVs and communication to get/set their values. | ||
== What is a PV? == | == What is a PV? == | ||
Line 29: | Line 27: | ||
Most of the interactive parts of user displays have PVs associated with them. | Most of the interactive parts of user displays have PVs associated with them. | ||
== What is a record? == | == What is a record? == | ||
Line 34: | Line 33: | ||
Records are the building blocks of EPICS: | Records are the building blocks of EPICS: | ||
* There is a lot of different types of record, and each type is designed to perform a specific function | * There is a lot of different types of record, and each type is designed to perform a specific function | ||
* Records are customizable via fields that allow users to configure how they behave and monitor their state (see [[# | * Records are customizable via fields that allow users to configure how they behave and monitor their state (see [[EPICS_Cheat_Sheet#Noteworthy_fields|Noteworthy Fields]] & [[#How to find more info about record fields]] to know how to learn about record fields) | ||
* Records do nothing until they are processed (see [[#SCAN, PROC & FLNK fields]]) | * Records do nothing until they are processed (see [[#SCAN, PROC & FLNK fields]]) | ||
* Records vary significantly in complexity (see [[#More about records]]) | * Records vary significantly in complexity (see [[#More about records]]) | ||
* It is rare for new records to be created, now that ''asyn'' device support exists | * It is rare for new records to be created, now that [https://github.com/epics-modules/asyn''asyn''] device support exists). | ||
Line 77: | Line 76: | ||
=== What is a record field? === | === What is a record field? === | ||
Record fields are controllable or informative properties of a record. For a list of noteworthy fields, see [ | Record fields are controllable or informative properties of a record. For a list of noteworthy fields, see the [[EPICS_Cheat_Sheet#Noteworthy_fields|EPICS cheat sheet]]. | ||
==== SCAN, PROC & FLNK fields ==== | ==== SCAN, PROC & FLNK fields ==== | ||
Line 105: | Line 104: | ||
<u>Note</u>: | <u>Note</u>: | ||
* If a record’s SCAN field is not specified in a database, it defaults to <code>Passive</code>. | * If a record’s '''SCAN''' field is not specified in a database, it defaults to <code>Passive</code>. | ||
* The '''SCAN''' field is common to ''all'' record types and the options can be selected by index | * The '''SCAN''' field is common to ''all'' record types and the options can be selected by index or by string. | ||
* <code>I/O Intr</code> processes a record when the driver gets a new value, but is device/driver dependent and isn’t guaranteed to work | * <code>I/O Intr</code> processes a record when the driver gets a new value, but is device/driver dependent and isn’t guaranteed to work | ||
=== Record link types === | === Record link types === | ||
Line 114: | Line 112: | ||
Much of the power of EPICS comes from the ability to link EPICS records together. | Much of the power of EPICS comes from the ability to link EPICS records together. | ||
There are two link implementations: standard and dynamic. | There are two link implementations: standard and dynamic. | ||
* Dynamic links (pink) are found on ''userCalc'' ('''swait''' records) and ''scan'' ('''sscan''' records) screens; this type of link accept only a PV name. | * Dynamic links (pink in standard BCDA screens) are found on ''userCalc'' ('''swait''' records) and ''scan'' ('''sscan''' records) screens; this type of link accept only a PV name. The role of the process command (see below) is taken in a separate field. | ||
* Standard links (purple) are found everywhere else. | * Standard links (purple in standard BCDA screens) are found everywhere else. | ||
''inlinkHelp'' and ''outlinkHelp'' are accessible from userTransform screens and scaler screens (for the later only). | ''inlinkHelp'' and ''outlinkHelp'' are accessible from userTransform screens and scaler screens (for the later only). | ||
Line 136: | Line 134: | ||
Here are the possible process commands for an output link: | Here are the possible process commands for an output link: | ||
* <code>NPP</code> - Just write a value; don't process the target record; this is a default command. | * <code>NPP</code> - Just write a value; don't process the target record; this is a default command. | ||
* <code>PP</code> - Write a value and then process the target record. To be | * <code>PP</code> - Write a value and then process the target record. To be used if you want EPICS to wait for completion. When the target record get processed, EPICS will trace it. | ||
* <code>CA</code> - Write a value; let the target record decide whether or not to process (as it would if you typed the value by hand); if the processing does occur, EPICS will not trace it. | * <code>CA</code> - Write a value; let the target record decide whether or not to process (as it would if you typed the value by hand); if the processing does occur, EPICS will not trace it. | ||
<u>Note</u>: | <u>Note</u>: | ||
* The default link process command, <code>NPP</code>, is '''almost never the desired behavior''' for output links. Change <code>NPP</code> to <code>PP</code> immediately and revert if problems are discovered. | * The default link process command, <code>NPP</code>, is '''almost never the desired behavior''' for output links. Change <code>NPP</code> to <code>PP</code> immediately and revert if problems are discovered. | ||
* If the target PV is itself a link field, you must specify the command <code>CA</code>; if you want to wait for completion in this case, you must use either the '''sseq''' or the '''sCalcout''' record, select <code>CA</code> and set the link's '''WAIT''' field to <code>Wait</code> | * If the target PV is itself a link field, you must specify the command <code>CA</code>; if you want to '''wait for completion''' in this case, you must use either the '''sseq''' or the '''sCalcout''' record, select <code>CA</code> and set the link's '''WAIT''' field to <code>Wait</code> | ||
* ''outlinkHelp'' is accessible from userTransform and scaler screens. | * ''outlinkHelp'' is accessible from userTransform and scaler screens. | ||
==== Forward Links ==== | ==== Forward Links ==== | ||
Forward | Forward links look like output links; they are purple on user displays, but they don't auto-populate with process & alarm commands. | ||
Forward | Forward links cause the linked record to process when the record containing the forward link is processed: | ||
* Linked record is in the same IOC ('''PROC''' field for linked record is optional): | * Linked record is in the same IOC ('''PROC''' field for linked record is optional): | ||
** <code>record_name.FLNK = linked_record_name</code> | ** <code>record_name.FLNK = linked_record_name</code> | ||
Line 159: | Line 156: | ||
* When omitting the '''PROC''' field of a linked record in a different IOC, nothing will happen but you won't get any error message. | * When omitting the '''PROC''' field of a linked record in a different IOC, nothing will happen but you won't get any error message. | ||
* Always specify the '''PROC''' field to avoid problems. | * Always specify the '''PROC''' field to avoid problems. | ||
=== More about records === | === More about records === | ||
Line 180: | Line 176: | ||
To find documentation for a specific field you need to know/find answers to the following questions: | To find documentation for a specific field you need to know/find answers to the following questions: | ||
* Is the field common to all or input/output record types? | * Is the field common to all record or only input/output record types? | ||
* If not, does the record come from EPICS base or a different EPICS module (synApps)? | * If not, does the record come from EPICS base or a different EPICS module (synApps)? | ||
** The [https://epics.anl.gov/base/R7-0/7-docs/RecordReference.html EPICS base record reference documentation] is the best place to find information about record types that come from EPICS base. <br>Field documentation appears in multiple locations: | ** The [https://epics.anl.gov/base/R7-0/7-docs/RecordReference.html EPICS base record reference documentation] is the best place to find information about record types that come from EPICS base. <br>Field documentation appears in multiple locations: | ||
Line 189: | Line 185: | ||
** synApps record reference documentation | ** synApps record reference documentation | ||
*** In each module's documentation directory | *** In each module's documentation directory | ||
**** | **** https://github.com/epics-modules | ||
**** <code>/APSshare/epics/synApps_X_Y/support</code> | **** <code>/APSshare/epics/synApps_X_Y/support</code> | ||
== What is a | == What is a database? == | ||
A database is just a text file with a '''.db''' (or '''.template''') extension containing a collection of records that are related. | A database is just a text file with a '''.db''' (or '''.template''') extension containing a collection of records that are related. | ||
Line 225: | Line 221: | ||
{adam2, serial1,02} | {adam2, serial1,02} | ||
}</code> | }</code> | ||
== What's next? == | |||
To learn how to create your own IOC, go to [[IOC 101]]. | |||
== External links == | == External links == | ||
* [https://epics.anl.gov/base/R3-16/2-docs/AppDevGuide/DatabaseDefinition.html#x7-2630006.6 https://epics.anl.gov/] | * [https://epics.anl.gov/base/R3-16/2-docs/AppDevGuide/DatabaseDefinition.html#x7-2630006.6 https://epics.anl.gov/] | ||
* [https://epics.anl.gov/base/R7-0/7-docs/RecordReference.html EPICS base record reference documentation] | * [https://epics.anl.gov/base/R7-0/7-docs/RecordReference.html EPICS base record reference documentation] |
Latest revision as of 02:52, 23 December 2023
What is EPICS?
EPICS (Experimental Physics and Industrial Control System) is a control system built around programs serving Process Variables (PVs) over a computer network. It is free, open source, and in active development and used in a number of large industrial and research facilities around the world. EPICS is a distributed control system, which means that the IOC (software) can run on a different computer as the user interfaces.
This page is dedicated to the definition of basic EPICS components (IOC, PV, record, database). To build your own EPICS support, you can skip directly to How does one create an IOC.
What is an IOC?
An EPICS IOC (Input/Output Controller) is a program which processes and serves a database. A database consists of many records each with their own fields which may contain data or change the record behavior. Each of these elements (fields) is known as a process variable (PV). Databases may be written from scratch for the IOC or composed from pre-written EPICS module databases and record types.
Any client, locally or on the network, can read and/or write a process variable using either channel access (CA) or PVaccess (PVA) network protocols. Clients might be another IOC, a GUI display manager (medm/caqtdm/CSS), or any other program with support for the EPICS protocols. Only the name of the process variable (in the form prefix:record_name.field_name
) is required to read or write a PV.
Note:
- IOCs used to run on VMEs, but nowadays it runs on anything.
- IOCs usually talks to hardware, but that isn’t a requirement.
You interact directly with a running IOC via the EPICS shell (iocsh), or indirectly by reading and writing Process Variables. Starting an IOC on a general purpose computer (a softIOC, as opposed to running on dedicated hardware like VME) involves running a binary along with a startup script of iocsh commands (usually called st.cmd). This script tells the IOC what database files to load and where those files are. When the IOC is told to load a database, it basically parses that database file, identifying the records that are contained within, and then generating the actual epics PVs that a user will interact with.
Records and databases (lists of records) are configuration files describing the initial setup for PVs; the IOC is the software that manages the behavior of PVs and communication to get/set their values.
What is a PV?
PV (Process Variable) is a the field from a record:
PV = record_name + . + field_name
Most of the interactive parts of user displays have PVs associated with them.
What is a record?
Records are the building blocks of EPICS:
- There is a lot of different types of record, and each type is designed to perform a specific function
- Records are customizable via fields that allow users to configure how they behave and monitor their state (see Noteworthy Fields & #How to find more info about record fields to know how to learn about record fields)
- Records do nothing until they are processed (see #SCAN, PROC & FLNK fields)
- Records vary significantly in complexity (see #More about records)
- It is rare for new records to be created, now that asyn device support exists).
Where do records come from?
Typically, records at the APS comes from either:
- EPICS base: main core of EPICS
- synApps: a collection of EPICS modules that are commonly used at the APS
A module is similar to a python package: it is an already written set of databases and associated behavior you can load into your IOC to do certain things, for example talk to specific hardware. An IOC can link to several modules.
Module | Records | Module | Records |
---|---|---|---|
alive | alive | motor | motor |
asyn | asyn | optics | table |
busy | busy | scaler | scaler |
calc | acalcout, scalcout, sseq, swait, transform | sscan | sscan |
camac | camac | std | epid, timestamp, throttle |
lua | luascript | vac | digitel, vs |
mca | mca | vme | vme |
allenBradley | ab1771IFE, ab1771N, ab1771IX, ... | allenBradley | ..., ab1791, abDcm |
If a record isn't listed here, it probably comes from EPICS base.
The advantage to using synApps over a collection of modules one assembles on their own is that some amount of BCDA testing has been done.
What is a record field?
Record fields are controllable or informative properties of a record. For a list of noteworthy fields, see the EPICS cheat sheet.
SCAN, PROC & FLNK fields
Records do nothing until they are processed. Records can be processed multiple ways:
- Manually:
- Write 1 (or any non-zero value) to a record’s PROC field
- Forward link (FLNK) from another record
- Periodically by setting the SCAN field to something other than
Passive
Index | Option | Index | Option |
---|---|---|---|
0 | Passive |
5 | 2 second
|
1 | Event |
6 | 1 second
|
2 | I/O Intr |
7 | 0.5 second
|
3 | 10 second |
8 | 0.2 second
|
4 | 5 second |
9 | 0.1 second
|
Note:
- If a record’s SCAN field is not specified in a database, it defaults to
Passive
. - The SCAN field is common to all record types and the options can be selected by index or by string.
I/O Intr
processes a record when the driver gets a new value, but is device/driver dependent and isn’t guaranteed to work
Record link types
Much of the power of EPICS comes from the ability to link EPICS records together. There are two link implementations: standard and dynamic.
- Dynamic links (pink in standard BCDA screens) are found on userCalc (swait records) and scan (sscan records) screens; this type of link accept only a PV name. The role of the process command (see below) is taken in a separate field.
- Standard links (purple in standard BCDA screens) are found everywhere else.
inlinkHelp and outlinkHelp are accessible from userTransform screens and scaler screens (for the later only).
Input Links
Input links read a value from another PV. It accepts a PV name followed by a process command (e.g. NPP
) and an alarm command (e.g. NMS
, ignore this).
Here are the possible process commands for an input link:
NPP
- Just read the value; don't process the target record (i.e. read a potentially stale value); this is a default command.PP
- Process the target record and then read a value from it.CA
- Read a value without causing processing to occur.CP
- Process linking record every time the target record processes.CPP
- Same as CP, but linking record process only if its SCAN field has the valuePassive
.
Note: inlinkHelp is accessible from userTransform screens.
Output Links
Output links write a value to another PV. It accepts a PV name followed by a process command (e.g. NPP
) and an alarm command (e.g. NMS
, ignore this).
Here are the possible process commands for an output link:
NPP
- Just write a value; don't process the target record; this is a default command.PP
- Write a value and then process the target record. To be used if you want EPICS to wait for completion. When the target record get processed, EPICS will trace it.CA
- Write a value; let the target record decide whether or not to process (as it would if you typed the value by hand); if the processing does occur, EPICS will not trace it.
Note:
- The default link process command,
NPP
, is almost never the desired behavior for output links. ChangeNPP
toPP
immediately and revert if problems are discovered. - If the target PV is itself a link field, you must specify the command
CA
; if you want to wait for completion in this case, you must use either the sseq or the sCalcout record, selectCA
and set the link's WAIT field toWait
- outlinkHelp is accessible from userTransform and scaler screens.
Forward Links
Forward links look like output links; they are purple on user displays, but they don't auto-populate with process & alarm commands. Forward links cause the linked record to process when the record containing the forward link is processed:
- Linked record is in the same IOC (PROC field for linked record is optional):
record_name.FLNK = linked_record_name
record_name.FLNK = linked_record_name.PROC
- Linked record is in a different IOC (PROC field for linked record is required):
record_name.FLNK = linked_record_name.PROC
Note:
- Forwarding-linking records in the same IOC by only specifying the record name is an exception to the "VAL is the default field" rule.
- When omitting the PROC field of a linked record in a different IOC, nothing will happen but you won't get any error message.
- Always specify the PROC field to avoid problems.
More about records
- Records vary significantly in complexity; one way to classify them would be (*):
- Simple records are associated with individual data types
- bi, bo, mbbi, mbbo, longin, longout, ai, ao, stringin, stringout, waveform
- Intermediate records often perform calculations or link multiple records
- calcout, scalcout, acalcout, swait, transform, fanout, dfanout
- Complex records are associated with devices or higher-level functionality
- motor, scaler, mca, sscan, table, digitel, vs
- Flexible records allow custom functionality to be implemented
- sub, aSub, luascript
(*) this is not an official classification, nor an exhaustive list of records.
Note:
- areaDetector databases are composed of mostly simple record.
How to find more info about record fields
To find documentation for a specific field you need to know/find answers to the following questions:
- Is the field common to all record or only input/output record types?
- If not, does the record come from EPICS base or a different EPICS module (synApps)?
- The EPICS base record reference documentation is the best place to find information about record types that come from EPICS base.
Field documentation appears in multiple locations:- Fields common to all record types
- Fields common to input record types
- Fields common to output record types
- Record-specific documentation
- synApps record reference documentation
- In each module's documentation directory
- https://github.com/epics-modules
/APSshare/epics/synApps_X_Y/support
- In each module's documentation directory
- The EPICS base record reference documentation is the best place to find information about record types that come from EPICS base.
What is a database?
A database is just a text file with a .db (or .template) extension containing a collection of records that are related.
Databases are generalized with macros to allow multiple instances to be loaded (e.g. $(P)):
- Macros are variables containing strings to be substituted when the database is loaded.
- Macros without default values are required to load the database; there is no easy way to figure out what those are for a given database other than looking at the file itself.
- Macros required by the database should match the macros required by associated screens & autosave (.req) files.
- The P (prefix) macro usually includes a colon (:), which is the standard separator used in PV names.
How are databases loaded?
There are 2 ways to load databases which are strictly equivalent.
dbLoadRecords
dbLoadRecords("$(IP)/db/ADAM_4018.db","P=kmp:,R=adam1,PORT=serial1,A=01")
dbLoadRecords("$(IP)/db/ADAM_4018.db","P=kmp:,R=adam2,PORT=serial1,A=02")
dbLoadTemplate
dbLoadTemplate("substitutions/ADAM_4018.substitutions","P=kmp:")
where ADAM_4018.substitutions:
file "$(IP)/db/ADAM_4018.db"
{
pattern
{R,PORT,A}
{adam1, serial1,01}
{adam2, serial1,02}
}
What's next?
To learn how to create your own IOC, go to IOC 101.