Data Acquisition and Management in BEPC
X. Geng, J. Zhao, Y. Yan, Y. Yu, H. Luo, W. Liu
Institute of High Energy Physics, Chinese Academy of Sciences
P.O.Box 918-10, Beijing 100039, China
Internet: Suny@bepc5.ihep.ac.cn
This paper describes the method of upgrading the BEPC control system, in which the dedicated adapter VAX-CAMACChannel (VCC) was replaced by a commercial adapter KSC2922/3922, Qbus CAMAC interface. All low level I/O driver
routines have been changed without changing the whole CAMAC hardware system. The upgraded control system has adistributed architecture and several hierarchical databases are installed in the FEC computers, so the data flow should becontrolled. Once raw data in any node have been refreshed, any changes will be transferred to the other nodes to maintain
uniformity of data in those databases.

1. INTRODUCTION
The original BEPC control system has a centralized structure mainly composed of a console, a VAX750 computer, theintelligent channel VCC, the CAMAC system and hardware devices. The structure of the system is shown in figure 1. VCC
is a dedicated product from SLAC, which is no longer produced and of which there is a shortage of spare parts. Now the VCC
has been replaced by the commercial product KSC2922/3922, a Qbus-CAMAC adapter produced by Kinetic Systems
Corporation, which serves as the data communication interface to the CAMAC hardware.

Figure 1 Original control system structure

Figure 2Upgraded BEPC control system

The upgraded control system has a distributed architecture based on Ethernet and has been operational since Oct. 1994
(Figure 2 ). Because of the short time available for upgrading, the low level CAMAC system was retained.

2. HARDWARE STRUCTURE
The VAX-11/750 used the VCC as a Unibus - CAMAC interface, but the VAX4500 and MicroVAXII computers in theimproved system use the Q-bus. The KSC 2922 Computer Bus Adapter provides an interface between the DEC Q-Bus and up
to eight 3922 dedicated crate controllers through a byte-wide parallel bus. The 2922/3922 combination provides four DMA
modes and a programmed transfer mode. All modes of operation are capable of transferring 16- or 24-bit CAMAC data words.
DMA data rates up to 0.77 MB/s can be achieved.

3. SYSTEM SOFTWARE
Data acquisition software consists of a packet creation program PBZ, a data I/O program XCAMAC, a device on/off
program DCOUT, the digital voltage acquisition program of the main B and Q magnet power supplies SPRDVM and thebeam position monitor program BPM.
In the control system, there are nearly 7,000 signals which can be classed into 7 types. (see Table 1)
Table 1. The signals table
Input signals

Output signals

DM ( digital monitor )AM ( analog monitor )D I ( digital input )DV ( digital voltage )DC ( digital control )AC ( analog control )DO ( digital output )1 bit digital input
analog input
16 bits digital input
R*4 analog input
1 bit digital output
analog output
16 bits digital output

For acquisition of the signals mentioned above, the following programs were rewritten:
The VCC packets are made by subroutine PBZ. PBZ takes the CAMAC I/O address of each signal from the database andassembles it to the control word and VCC packet. Then the control words and VCC packets are sent to the database to be usedby XCAMAC and other processes. The sequence of the VCC packets in the database is: DMAMDI packets, AC_OUT
pockets, AC_IN packets, DCDO packets, IPSC packets and SAM packets. The BEPC system has about 1350 VCC packets.
The data acquisition process XCAMAC refreshes the database at a rate of twice a second and acquires about 4000 signals
each time. The process also carries out the ramp operation of the magnet power supplies during particle acceleration in BEPC.
The subroutine SPRDVM acquires the digital voltage signals (DV) so that operators can monitor the present current
status of the magnet power supplies. DVM3456A is connected to the VAX computer via a 3388 GPIB interface.

4. IMPROVEMENT
There was a hierarchical database in the original control system which had a static area and a dynamic area. In the staticarea, there was information about the CAMAC interface and machine parameters. The original data from the accelerator
equipment was stored in the dynamic area which was refreshed at 2 HZ. For the distributed architecture of the new system, theoriginal database had to be modified. First of all, we installed a database in each FEC computer with same data structure andcreated a 3922 packet area in the dynamic area of the databases. To keep the uniformity of the data records in these databases, anetwork communication program was developed to exchange the data between those databases and several new sections wereinserted the dynamic area of each database to hold the raw data from other nodes which are refreshed once per second throughthe network. As shown in figure 3, when the database on node 1 receives the raw data from its input/output port, the network
communication manager is notified by a event flag to fetch the data and send them to the database in node 2. In order toprevent alteration of the high level application program, the 3922 data area in the dynamic area is mapped onto the original
VCC data area and the local index of the database is replaced by a new global index in each database at control system startup,
so that the raw data from all of the accelerator devices can be read in each node.
The format of the data and command packets differs from that for the VCC; therefore the main work was in changing thepacket chains from VCC format to 3922 format. Another difference is the data bit format. The VCC requires the 16 high bits
to be valid, but the 2922 needs the 16 low bits.
A new packeting organization program QPBZ acquires the CAMAC I/O address of every signal from the database,assembles them to CAMAC control words by calling the 3922 driver subroutines such as Cainit, Caopen, Caclos, Canaf,Cainaf, Cablk, Cahalt, Caexew and Camsg, etc. Since block transfer operation is need for acquiring the analog signals by theSAM modules, we wrote a new program for the organization of SAM packets.

Figure 3

The upgraded database

In tests, we found that the I/O speed of the KSC2922/3922 is lower than that of the VCC. To transfer the same numberof data when 30 main power supplies are ramping, the minimum interval between two QIOs is 30 ms for the VCC and 44
ms for the 3922. The reason is that the VCC is an intelligent module which can assemble F17 command transfers toCAMAC modules, while the 3922 is a dumb module. The F17 command has to be sent by the VAX computer, so the lengthof the 3922 packet chain is 1.5 times as long as that of the VCC. As it takes more time to transfer the data, we don’t acquire
the device status information during the ramping of the main PS to enhance speed. In accordance with the 3922 packet rules,
the output data are placed in the packet chains and the readback is mapped onto the old VCC area.

5. CONCLUSION
The upgraded BEPC control system was completed in October 1994. The dedicated adapter VCC has been replaced by acommercial product successfully and the real-time response speed and the reliability of the system are improved. In the nearfuture, we will upgrade the DVM acquisition with an analog scanning module.

ACKNOWLEDGMENT
The author would like to thank Prof. Huiying Luo and Chunhong Wang who gave us a much support.

REFERENCES[1] J. Zhao, X. Geng et al., Proc. of Conf. on High Energy Acc. (1995)[2] J.Zhao, Nation Conf.
[3] X. Geng, Y. Yan, Nation Conf.