EPICS interface for the PLC system

Overview

PLC system holds signal values in its internal registers. By reading the register values or writing values into the registers, we can communicate with the PLC system.

EPICS translator is a software translating the PLC register values to EPICS process variables (PVs). It can also transfer EPICS PV values into PLC registers.

The EPICS translator is implemented as an EPICS IOC. It is running on a computer called k1kiki0 (the name should be changed to k1plc0). Physical location of this computer is the PLC rack in the center area. You can login to this computer from the KAGRA control network with the controls account.

A note on EPICS terminology

The following words are used to mean basically the same thing.

PV (Process Variable)
EPICS record
EPICS channel

"PV" and "record" are correct EPICS terms. "Channel" is widely used to mean PV or record, but it is a misuse.

As a policy, the PLC system provide two classes of EPICS PVs.

These PVs read or write into hardware channels, for example: channel 1 of Y-End ADC, channel 6 of X-End DI and so on. These PVs have names such as K1:PLC-YEND_ADC_Ch1 or K1:PLC-XEND_DI_Ch6. The names do not contain the information of what is connected. So users of the PLC system should create User PVs to have more meaningful names. The PLC administrator (currently Aso) will make all the hardware channels available as hardware PVs.

These PVs read one or more hardware PVs and (optionally) do some calculations to produce physically meaningful values and PV names. For example, assuming that a vacuum gauge is connected to Y-End ADC Ch1 and the corresponding hardware PV is K1:PLC-YEND_ADC_Ch1, you can create an user PV, K1:PLC-VAC_EY_PRESSURE, with the following database definition.

record (calc, "$(SYSTEM)-VAC_EY_PRESSURE")
{
    field (DESC, "EY Vacuum pressure" )
    field (INPA, "$(SYSTEM)-YEND_ADC_Ch1")
    field (CALC, "10^(1.667*A*10/4096 - 9.33)" )
    field (EGU, "Pa")
    field (SCAN,"$(SCAN) second")
}

This PV holds the vaccum pressure in Pa.

You do not have to do a calculation unless necessary. Just copying the value of a hardware PV is fine in most cases.

Adding a hardware PVs (usually not necessary for users)

record (ai, "$(SYSTEM)-XEND_ADC_Ch1")
{
    field (DESC, "D3792:X-End ADC Ch1 value" )
    field (DTYP, "devFromArray")
    field (INP, "$(SYSTEM):D3640-D4599 @ 152" )
    field (SCAN,"$(SCAN) second")
}

How to add a User PV

record (calc, "$(SYSTEM)-VAC_EY_GV1_OPEN")
{
    field (DESC, "EY GV Open" )
    field (INPA, "$(SYSTEM)-YEND_DI_Ch10")
    field (CALC, "A" )
    field (SCAN,"$(SCAN) second")
}

Adding a new database file

dbLoadRecords("db/newDatabaseFile.db","SYSTEM=$(SYSTEM),SCAN=.1")

Starting/Restarting the EPICS translator

The EPICS translator is started at the system start by systemd. You can control it by executing the following commands on k1kiki0.

sudo systemctl start epics-trans.service

sudo systemctl stop epics-trans.service

sudo systemctl restart epics-trans.service

sudo systemctl status epics-trans.service

sudo journalctl -u epics-trans

Details of the systemd configuration

The systemd unit file for EPICS translator is "/lib/systemd/system/epics-trans.service".

[Unit]
Description=EPICS Translator for the KAGRA PLC system
After=network.target

[Service]
Environment=EPICS_BASE=/home/controls/PLC/EPICS_Trans/base-3.14.12.2
Environment=EPICS_HOST_ARCH=linux-x86
Environment=TOP=/home/controls/PLC/EPICS_Trans/base-3.14.12.2
Environment=ASYN=/home/controls/PLC/EPICS_Trans/base-3.14.12.2/asyn
ExecStart=/home/controls/PLC/EPICS_Trans/base-3.14.12.2/bin/linux-x86/kagraMps /home/controls/PLC/EPICS_Trans/base-3.14.12.2/iocBoot/iockagraMps/st_end.cmd
StandardInput=tty
TTYPath=/dev/tty50
StandardOutput=journal
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target

Assigning tty50 to the standard input is necessary to run the IOC properly because it expects to be run in a terminal.

sudo systemctl enable epics-trans.service

Registering new EPICS PVs to KAGRA DAQ

In order to record the values of newly added EPICS PVs in the KAGRA DAQ system, you need to do the following configuration work.

[default]
gain=1.00
datatype=4
ifoid=0
acquire=3
offset=0
units=V
dcuid=4
datarate=16

[K1:PLC-VAC_EY_PRESSURE]
units=Pa
[K1:PLC-YEND_ADC_Ch5]

KAGRA/Subgroups/MIF/PLC/EPICS (last edited 2018-02-01 16:06:24 by YoichiAso)