The GNU Control System at CAMD
B. Craft and P. Jines
Center for Advanced Microstructures and Devices
Louisiana State University
3990 W. Lakeshore Drive, Baton Rouge, LA 70803, USAAbstract
The Center for Advanced Microstructures and Devices(CAMD) at Louisiana State University operates a 1.5 GeV,
synchrotron radiation dedicated, electron storage ring. The
injector is a 180 MeV linear accelerator. The procurement ofthe entire accelerator system, including the control systems,
utilized a single, fixed-price contract. The control system
for the storage ring was based upon a commercial controlsystem software package running on a DEC MicroVax and aDEC VaxStation. The interface hardware included CAMAC,GPIB, RS-232 and Allen-Bradley PLC. The control system
for the injector used third-party software running on top ofOS9 in a VME crate controller. The interface hardware washome-brew TTL on a VME bus-adapter card. The system
has been in operation since the fall of 1992.
Efforts to interface the two control systems to each otherwere unsuccessful. Though OS9 provided basic TCP/IP capabilities, the third-party control software consumed essentially 100% of the available CPU. Pinging the linac controlsystem resulted in the time-out of watch-dogs which in turnlead to a shutdown of the linac.
An upgrade of the control system is underway. The DECand VME computers will be replaced by Pentium based
PC’s. The software of the upgraded control system will bebased on totally free software including the Linux kernel andthe GNU compiler and libraries.
1 BackgroundThe contract, between Louisiana State University andMaxwell Laboratories, for the design, fabrication, installation, and commissioning of the “turn-key” synchrotron lightsource was signed in December, 1989. The decision to basethe control system for the storage ring on MicroVax hardware running Vista software was made in late 1990. This
was a natural choice at the time. CAMD already had one MicroVax which had been purchased to support design calculations at LSU. It and its components could serve as on-handspares for the control-system MicroVax being supplied byMaxwell. The Vista software had grown out of Los Alamos
National Laboratory. The package provided a significant infrastructure and its developers contributed their expertise to
the development of the CAMD control system.
Early in the design of the accelerator systems, Maxwell
Laboratories decided to subcontract the injector linac toCGR-MeV. This was also a natural decision at the time.
An essentially identical linac had already been accepted byOxford Instruments for the Helios project with IBM. The
IBM/Oxford linac from CGR-MeV was in routine operationin Fishkill, NY at the time that Maxwell and CAMD agreed
to the subcontract. The most significant difference between
the IBM/Oxford and CAMD/Maxwell linacs was the specification of the external interface into the control system of thelinac. IBM and Oxford tapped in to the control system at theanalog signal level. Maxwell and CAMD specified TCP/IP
access to the control system computer.
During subsystem acceptance tests in the third quarterof 1992, the inability of the linac control system to accept
TCP/IP access was identified. This deficiency was considered negligible within the scope of the overall project. The
accelerator systems were formally accepted by CAMD inAugust, 1992 and have been in routine operation since.
In the mean time, CGR-MeV delivered injector linacs toESRF in Grenoble, France and Elettra in Treiste, Italy. Since
then, they have gotten out of the injector linac business. Thishas left CAMD with a totally unsupported control system
for the linac. Efforts to reverse-engineer the hardware of thelinac control system have been frustrated by our inability toidentify several rather large silicon components.
2 Design objectives
The design objectives for the control system upgrade arestraightforward: Replace linac control system with something supportable and maintainable Integrate storage ring and linac control systems
 Minimize required capital investment
 Minimize ongoing hardware and software maintenanceexpenses Develop GUI based operator interface.
 Provide documented, simplified, and unified API
 Automate as much of “Operations” as possible.
3 The GNU design
The computer hardware platform selected for the upgrade is
the generic “personal computer” based on the Intel Pentium
processor. We presently have one 200MHz computer andone 166MHz computer dedicated to this project. These twocomputers cost less than we have been spending annuallyfor maintenance of the MicroVax. Obviously, no spares arenecessary for the basic computers because of their instantavailability.
The operating system being used is Linux. The complete
source to the kernel and all of the utility programs, including

compilers, editors, and libraries, is freely and readily available. The Linux kernel and the GNU compiler (gcc) arecovered by the “GNU General Public License” (GPL). The
necessary libraries, including libc and libm, are covered by
the “GNU General Library Public License.” Additionally,working within the Linux community, application specificsoftware is freely available in source form.
The GUI will be based on Tcl/Tk which is copyrighted by
the Regents of the University of California, Sun Microsystems, Inc., and other parties. The terms of its use are similar
to those of the GPL. Tcl/Tk runs on Microsoft’s Windows,Apple’s Macintosh, and most derivatives of Unix. Whenrunning on Linux, Tk utilizes the X-windows system provided by the XFree86 package.
The API will be developed in two parallel forms: a Clibrary and a Tcl loadable shared object library. The numberof API entry points will be kept to a minimum. The first API
modules developed will be string based. All conversions andformatting will be handled by the libraries.
All of the software we develop during the course of thisproject will be made freely available under the GPL.
3.1 Storage ring
Most of the control functions of the control system that relate to the storage ring are implemented using CAMAC. The
HYTEC ethernet crate controllers and all of the CAMAC
modules of the original control system will be utilized in
the upgraded system. The timing system of the storage ringkickers and septum has been and will continue to be implemented in Stanford Research Systems (SRS) Timing/Delay
Generators which interface to the computer through GPIB.
The system of Allen-Bradley PLC’s which has been usedfor functions such as vacuum interlock and kicker amplitudecontrol will be maintained in the upgraded system.
3.2 Linac
Most of the control functions of the linac control system interface to the VME computer via a VME bus adapter. The
external interface to this bus adapter is a 50 conductor ribbon cable. The signal levels are simple TTL. At the otherend of this cable is a cage of simple cards which implement
digital and analog input and output. In the upgraded controlsystem, a PC equipped with an ISA “kludge card” will replace the VME bus adapter and associated VME computer.
Use of the cage of simple interface cards will be continued.
The other control signals connected to the VME crate aretiming signals. These functions will be implemented using
additional SRS Timing/Delay Generators.
4 Implementation
The signing of a contract for the acquisition of a superconducting wiggler in June, 1996 significantly impacted plans
for the control system upgrade. The wiggler is scheduled
to be installed in December of this year. Its operation will
require additional control channels. Due to the large tune

shift and orbit dilation caused by operation of the wiggler,
its turn-on procedure will be as difficult as ramping the storage ring energy and will therefore require the use of list processors. Rather that waste effort implementing this with theold control system, the decision was made to implement it in
the upgraded system. This made the CAMAC system of thestorage ring the highest priority. For reasons both politicaland technical, the project was not begun until February thisyear.
The ethernet crate controllers of the CAMAC system initially presented somewhat of a problem. Though the vendorsupplied manuals state that the details of the protocol areavailable upon request, this is not the case. TCPDUMP,
from the Network Research Group of Lawrence Berkeley
National Laboratory, was used to reverse engineer the interaction between the MicroVax and the crate controllers.
TCPDUMP, which is freely available, allows one to eavesdrop on an ethernet. The protocol, which is alleged to be
associated with LLC2, was implement in user-space using
the BSD Sockets provided by the Linux kernel. Because
the protocol involves a packet sequence number that is associated, in the crate controller, with the hardware ethernet
address of the host computer, a daemon was written to allow
multiple applications using CAMAC to run on a single hostcpu.
A minimal set of the ESONE routines was implemented.
Two libraries are provided at this point: one for stand-alone
testing and the other that utilizes the daemon. The entry
points of these two libraries are identical. The API can beplaced on top of either of these libraries. The API presently
has the following entry points:
 init read write get units set units
 get range
 finiThis set of entry points is not complete. Versions of read andwrite that manipulate arrays rather that just single words will
be necessary.
The CAMAC list processors, which are used to condition
magnets, ramp the storage ring, and run the BPM (beam position monitoring) system were initially feared to present aserious programming challenge. This fear was based on thefact that list processors are essentially embedded processors.
Surprisingly, this fear turned out to be unfounded. The Ccode developed by Maxwell Laboratories for controlling thelist processors ported easily to Linux.
Two National Instruments GPIB PCI cards are used to interface to SRS Timing/Delay Generators. One is in the PC
in the linac tunnel. The other, in the PC in the control room,
provides for kicker timing and also interfaces to the network
analyzer, spectrum analyzer, and digital scopes. The kernelbased device driver for these GPIB cards was obtained fromthe Linux Lab Project. A complete remote GUI has been developed that renders the “Face” of the SRS boxes on an X

display. One can configure an SRS box in the linac tunnel
from the control room. The only difference is that one uses
a mouse instead of a finger to push the buttons.
The Allen-Bradley PLC’s in our system are 5 or 6 years
old. The controllers speak only a proprietary protocol.
Rather than bare the expense of upgrading three controllers
to the new versions that operate with an open protocol, wepurchased an over-priced interface card and its associateddriver development software from Allen-Bradley. The coding for this driver has not yet begun.
There are several hundred “channels” in the control system at CAMD. This makes the control system “medium” insize. PostgreSQL, copyrighted by the Regents of the University of California and freely available, is being used for
database management. Besides the information to associatemnemonics with, for example, CAMAC crate number, CAMAC slot number, and module subaddress, the database contains the information to convert numbers from binary to engineering or scientific units such as amps or beam energy.
The database also contains information about ranges andlimits. Eventually, most of the Tcl/Tk application code will
also be stored in the database.
Work has not yet begun on the control system of the linac.
As mentioned previously, the planned arrival of a superconducting wiggler has focussed control system development
efforts on the CAMAC system of the storage ring. The task
to displace the VME computer of the linac control system isexpected to be somewhat tricky. Because the interface is basically a single ribbon cable carrying TTL signals, migration
is abrupt. The old and new computers cannot simultaneously
contribute to the control of the linac. This is the exact opposite of the situation with the ethernet crate controllers of theCAMAC system for the storage ring. The effort to replace
the VME computer will be further hampered by the lack ofcomprehensive documentation.

5 Summary
The CAMAC portion of the storage ring control system, including the list processors, is fully functional in the new,
Linux based control system. The magnets have been conditioned, the ring energy ramped, and the BPM’s read allunder the control of a PC. This system is prepared for thearrival of the superconducting wiggler.
The GPIB interfaces are fully functional and the GUI for
the Timing/Delay Generators is complete. The RS-232 interface to the water systems has not been addressed but isexpected to be trivial. The driver for the Allen-Bradley interface card has not yet been written and is expected to takea fair amount of work.
Due to present priorities, work has not yet begun to displace the VME computer of the linac control system. Thistask will be addressed in January of next year.
Acknowledgements
The authors would like to express their appreciation ofLinus Torvalds and the entire Linux community for the kernel we are using. We would like to thank the Free Software
Foundation for the GNU compiler and libraries. We would
like thank The Regents of the University of California, Sun
Microsystems, and John Ousterhout for Tcl/Tk. We would
like to thank C. Schroeter for the Linux GPIB Package. Thisauthor (BC) would like to thank Alan Cox for numerous emails elucidating the organization of the ethernet software
within the Linux kernel. We would also like to thank thedevelopers of PostgreSQL and XFree86.