From Hchkswiki
Jump to: navigation, search

The Controls for several of the HES/HKS magnets and field probes are implemented on two PC104 computers. PC104s are small form factor PCs using compact flash for disk. We run linux on the PC104s and use the EPICS portable channel access server (PCAS) to interface the devices to EPICS.

See the PC104 Hardware page for information on the CPU and peripheral hardware used.

Software Location

The running on the PC104s can be developed and examined from the cvxwrks account on the Hall C counting house linux cluster (cdaql1-6). The working copy of the code is in


This is an image of a complete PC104 linux system. The main files of interest are in home/cvxwrks/R3.14.6/base/hksApp in the Db and src directories and in home/cvxwrks/R3.14.6/base/iocBoot/iochks which contains the EPICS startup scripts.

Working with the software

To modify or configure the controls software, one generally will only need to work in the following directories:

Software that communicates with the hardware being controlled or monitored
Definitions of the EPICS signal names (variable names) that control screens and other applications use to communicate with the PC104
Startup scripts that load the appropriate software and signal names. Each PC104 will use a different startup script.

The software and signal name definitions are macro/variable configured so that software can be reused for devices that have the same interface and so that devices can be easily moved to different serial ports or PC104 boards.

State Machines

The connection between the C routines that talk to the various RS2323 devices and EPICS variables is made with state machine sequencers written in State Notation Language (SNL). The reference for SNL and the sequncer is the State Notation Language and Sequencer Users Guide.

Four state machines were used in E01-011. Each of these state machine files (ending in .stt is matched with a file containing C routines with the low level comminication code. Also each state machine has a .dbd file that registers the state machine with the PCAS software. The four state machines and assocated files are:

hall.stt hallLib.c hall.dbd
Hall Probes
nmr.stt nmrLib.c nmr.dbd
NMR Probes
mps.stt psLib.c ps.dbd
Power supply controls
sst.stt ssLib.c sst.dbd
Sieve slit and target motion control

If new state machines are added, or filenames are changed, the hks_DBD and hks_SRCS lines in Makefile must be edited.

EPICS Database

EPICS Startup Scripts


To compile the state machines do the following (from the cvxwrks account) to activate the compilers and libraries that are compatible with the system running on the PC104s:

     /usr/sbin/chroot /net/cdaqfs/home/EPICS/PC104/hcpc10401_nfs bash
     source setupEpics
     cd R3.14.6/base/hksApp

(The chroot command will currently work on cdaql4 and cdaql6). To compile type make.

Running software on the PC104

Compiling creates the executable hks in R3.14.6/base/hksApp/src/O.linux-x86 and copies the database definition files into R3.14.6/base/db.


The development directories are mounted on the PC104 with NFS. To run the development copy of the application, do

     ssh cvxwrks@hcpc10401
     cd R3.14.6/base/iocBoot/iochks


For production, the compiled code should be copied to the PC104 local disk so that the controls don't rely on NFS. The PC104 should also be setup to automatically start the EPICS application on boot. This can be done by uncommenting the last line of /etc/rc.d/rc.local

     sleep 99999d | ./st.cmd > /dev/null &