Adding a new device to EPICS

Adding a new device to EPICS could mean one of the following:

  1. Adding channels for a new unit of hardware of a type already supported by an IOC you have -- this just means changes to "db" files, see the standard EPICS tutorials on db files. [1]
  2. Compiling a new IOC with support enabled for a type of device for which someone has already written a device driver -- this just means following appropriate compile instructions. [2,3]
  3. Creating a new device driver for a new kind of device EPICS has never supported before, and compiling an IOC with that support. For this case, see the text below.

Adding support for a new kind of device

The following outline follows Furakawa's "Very Simple Example of EPICS Device Support" note [4]
(which I highly recommend) and the EPICS Application Developer's Guide [5].

0) Install EPICS base.

1) Initialize the new app. (In the following you should change "RunControl" to name of your IOC.)

mkdir (directory anywhere); 
cd (to the directory) -t ioc RunControl -i -t ioc RunControl
[this is a good point to commit to a repository for reference]

2) Add definition and code for the new device. For a simple single-value input channel, you want to make it an "ai" type channel. (In the following, change "devRunControlSHM.dbd" and "aiRunControlSHM.c" to whatever you want to name your files.)

Files to add:
RunControlApp/src/aiRunControlSHM.dbd -- define device in db
RunControlApp/src/devRunControlSHM.c -- the code for the device
(see $EPICS_BASE/src/dev/softDev/devAiSoft.c for a working ai device and modify to suit)
Files to modify: 
RunControlApp/src/Makefile -- tell it what to put in your IOC support library and database definition file

Here is an example of what needs to be modified in the App/src/Makefile directory:

+ # Build an IOC support library
+ LIBRARY_IOC += aiRunControlSHM
+ DBD += aiRunControlSHM.dbd
+ aiRunControlSHM_SRCS += devRunControlSHM.c

  # RunControl.dbd will be made up from these files:
  RunControl_DBD += base.dbd

  # Include dbd files from all support applications:
- #RunControl_DBD += xxx.dbd
+ RunControl_DBD += aiRunControlSHM.dbd

  # Add all the support libraries needed by this IOC
- #RunControl_LIBS += xxx
+ RunControl_LIBS += aiRunControlSHM

3) Compile (make)

cd (top)
cd iocBoot

4) Add definition for new channels to .db file and load them in st.cmd

5) Run

cd iocBoot/iocRunControl
../../bin/linux-x86_64/RunControl st.cmd

6) Test with caget or caput as appropriate

Working examples


[1] "What is an EPICS Database?" and "Record Types and Examples" at

[2] "Read Me (Installation Instructions)" at

[3] Chapter 2 (note especially section 2.5) in "EPICS Application Developer's Guide" at

[4] K. Furukawa, "Very Simple Example of EPICS Device Support",

[5] "EPICS Application Developer's Guide" at