The Virtual Instrument Control System
Xu Jing-wei, Cheng hui-jun, Liu de-kang
Institute of High Energy Physics, Academia Sinica
P.O.Box 918-10, Beijing 100039

Abstract

2 System structure

LabVIEW is a graphical programming language for dataacquisition, data analysis and data presentation. It offers aneasy and fast way to develop control systems and program
instrumentation systems. We have developed a virtual instrumentation system that will be used in the control system of BEPC or SSRF on the basis of LabVIEW. The main
purpose of this virtual instrumentation system is to meetspecial needs for the control system of BEPC and SSRF.
The virtual instrumentation system integrates many instruments and devices such as CAMAC, PLC, DAQ and otherdevices with GPIB interface. Many applications have been
designed and developed by using LabVIEW as interface.
The PC is used as a server that acquires data fromCAMAC, PLC, DAQ, GPIB devices and other data sources
via the network. In addition, a command library to be usedwith PLCs has been implemented and stored in the userlibof LabVIEW. Users can build PLC monitor and controlsystems easily by using the programs in this library. In thispaper, we will discuss the virtual instrumentation system indetail.

The virtual instrumentation system is divided into twolevels.(see Fig. 1):

1 Introduction
There are many instruments and control devices in thecontrol system and beam diagnostic system of BEPC. Most
instruments can only provide special functions, at the sametime some instruments can not be accessed directly fromcontrol and beam diagnostic systems. In order to solvethese problems, we chose LabVIEW as the solution. The
reason is following:First, most instruments and devices used in the control
and beam diagnostic system provide standard interfaces
such as GPIB R S232, etc.
Second, LabVIEW includes many drivers for communication to other instruments, such as PLC, VXI, serial ports,etc.
Third, LabVIEW is a graphical programming software
which provides a friendly man-machine interface, it is very
easy to learn and efficient when used by developers. Up tonow, we have developed a virtual instrumentation systemin our laboratory by combining LabVIEW with standard
data acquisition and instrument control devices. This virtual instrumentation system includes applications which
communicate from LabVIEW to the instruments and devices. We also developed a command library for the usewith PLCs including almost all the commands of PLC
devices by using LabVIEW as interface. This PLC command library contains many ICONS that have been put inthe user library of LabVIEW. By using these ICONs users
can build the PLC monitor and control system easily.

2.1 First level: the interface level
In this level, the server PC plays the key role. The server
PC is the man-machine interface to the operator. All application programs run in the server PC. Three adapter cards
are installed in the server PC. They are: GPIB adapter,DAQ adapter and CAMAC adapter. All data acquired
through these adapters are transferred to the server PC.
Different application programs run in the server PC for
CAMAC, PLC, DAQ and instruments with standard GPIB
interface. Each application program fulfills one task. For
instance, the program in the PLC only communicates witha special PLC device. All these LabVIEW application programs are called VI (virtual instruments) because theirappearance and operation can imitate actual instruments.
Each VI includes two parts: a front panel and a block diagram. The front panel is the user interface of the VI. It is acombination of many controls and indicators. Controls
simulate instrument input devices and supply data to theblock diagram. Indicators simulate instrument output devices and display data acquired or generated by the block
diagram. The block diagram is the graphical source code ofthe VI. It integrates many objects which send or receive
data, perform specific functions and control the flow ofexecution.
The server PC also can receive and send data from andto other sources, such as EXCEL files and data via network. So far, we have developed the network communication VIs based on the TCP/IP protocol and VIs to read andwrite data from and to EXCEL files.
The software items installed on the server PC are thefollowing: Windows 95, LabVIEW 4.01, Visual C/C++
2.0. All application programs are developed by using thesesoftware tools.
2.2 Second level: the hardware level
This level includes CAMAC, PLC, DAQ and instruments with GPIB interface. The data are acquired and sent
to the server PC through adapters installed on the server
PC. For CAMAC, we install a CCU-2-80B CAMAC crate
controller in the CAMAC crate and an adapter in the server
PC. All data are sent to CAMAC modules or received fromCAMAC modules through this CCU-2-80B controller. For
PLCs we use the RS232 protocol to communicate with
PLC devices. The data from PLC devices are transferredthrough a serial port to the server PC. We also send andreceive data from 390ADs (a programming digitizer withstandard GPIB interface) and other DAQ devices.
SERVERLABVIEWDATABASE

RS232,Ethernet

UseDefaultCINAbort
UseDefaultCINLoadUseDefaultCINUnload
UseDefaultCINSave
CIN MgErr CINRun(void var1);
CIN MgErr CINRun(void var1){/* Enter your code here */DAQ and otherdevices

CAMAC

return noErr;}

GPIB Instuments PLC

Fig. 1 Structure of virtual instrumentation system.
3 Applications
3.1 LabVIEW-CAMAC application
CAMAC devices are widely used in the control andbeam diagnostic systems. It has been the standard bus in
the field of high energy physics. Although LabVIEW
provides some drivers for CAMAC controllers, there aremany CAMAC controllers which are not yet supported byLabVIEW, among them the CCU-2-80B controller which
is now widely used in the control and beam diagnostic
system of BEPC.
The CCU-2-80B is a CAMAC crate controller which wasdesigned and developed in IHEP. It supports standard
CAMAC modules. Because LabVIEW has not supplied adriver for the CCU-2-80B, we have developed our own
driver which provides an interface to support the communication between LabVIEW and the CCU-2-80B controller. The driver is programmed using C/C++. It supports thebasic CAMAC operations including reading, writing andtesting status bits.
LabVIEW provides two modes to link C/C++ programs.
One mode is CIN (Code Interface Node). Through CIN,
users can directly call the C/C++ program within LabVIEW by using the special format offered by CIN. The
other mode is DLL (Dynamic Link Libraries). Users cancall any DLL or shared library from LabVIEW.
We have developed an application program that communicates with CAMAC devices by using the above twomodes.
For the DLL mode, we use Visual C/C++ to develop theC/C++ programs to support the basic CAMAC operations.
Thereafter the program is changed into a DLL program
which can be called by LabVIEW directly.
For the CIN mode, we develop the C/C++ program using
the specific format drafted by LabVIEW. The following is
the basic CIN format of LabVIEW:/*/* CIN source file/*# include “xtcode.h”/* stubs for advanced CIN functions */UseDefaultCINInit
UseDefaultCINDispose

All graphic interface programs are developed in LabVIEW, however, all I/O programs are developed in Visual
C/C++. All application programs will be used in the beamdiagnostic system of BEPC.
3.2 LabVIEW-PLC applicationA PLC (programmable logic controller) is another important device in our control system. We developed acommand library for the PLC using LabVIEW. It includes
34 VI. Each VI in the library has its own ICON and users
can call this VI through its ICON which can be found inthe FUNCTIONS palette of LabVIEW.

Fig. 2 LabVIEW-PLC application
Because PLC devices which we use are linked to theserver PC through a serial port, every VI of the commandlibrary is developed on the basis of the serial protocol. Weuse the basic serial subVI of LabVIEW for this commandlibrary. The basic serial subVI are Serial Port Read VI,
Serial Port Write VI, Serial Port Init VI, and Serial Port
Break VI.
Although the PLC device which we use is the OMRONC200H, the command library can be used for any PLC
device, which uses the serial port protocol, without anychange. Nearly all PLC commands are included in ourlibrary. Therefore users can easily and efficiently constructspecial PLC monitor or control systems by calling VIs ofthis PLC command library.
The following is a sample of a VI in this library (see Fig.
2.). This VI is to execute a test command by responding tothe test strings which are sent from the server to PLC devices.

in a similar way.

3.3 LabVIEW-DAQ application
Data acquisition from DAQ adapters is another importanttask for which application programs had to be developed.
The DAQ device which we use is the PC-DIO-96. It is a
96-bit parallel digital I/O board. It has been installed in theserver PC. It contains four 24-bit programmable peripheral
interfaces (PPIs). Each can be further divided into three 8bit ports. The boards can be operated in either unidirectional or bi-directional mode. Digital signals acquired fromdata sources are transferred to the server PC through a 100pin male ribbon connector. The following application is asample of the VI which sends data through the PC-DIO-96
board.

Fig. 4 Front panel of LabVIEW-390AD
4 Conclusions

Fig. 3 LabVIEW-DAQ application
3.4 LabVIEW-GPIB application
Most instruments used in the control and beam diagnosticsystems provide a standard GPIB interface. In order tomeet special needs of the beam diagnostic system ofBEPC, we have implemented this application by using the390AD which is a programming digitizer with standard
GPIB interface. A GPIB adapter which is produced by NIcorporation is installed in the server PC. On the server
PC, users can operate the digitizer just the same as the real
digitizer. Our application does the following: data of channel 1 of the 390AD are acquired by the server PC throughthe GPIB adapter, then these data are processed using aseries of mathematical algorithms in order to get the correct
result needed by engineers. The calculated data are sent
back to channel 2 of the 390AD and displayed on theserver PC at the same time. Figure 4 is the front panel ofthe LabVIEW-390AD VI.
We have developed applications for other GPIB devices

A virtual instrumentation system has been developed in
our laboratory and LabVIEW-CAMAC application will be
used in the beam diagnostic system . Because of the limited
budget and resources, we have only developed CAMAC,PLC, GPIB and DAQ applications by using LabVIEW asinterface. In the near future, we will install DATABASE
in the server PC and all data acquired through instruments
will be stored in a database. All applications send and receive data through this database. Also, VME is our nextchoice to link with LabVIEW.
Acknowledgments
The authors would like to thank Lu-ping, Huang-hong,Ye kai-rong, and the staff of Beijing Zhong Ke Fan HuaElectronic Technology corporation for their enormous help.
References[1] J. Chen, et al., “Virtual Instrumentation Interface for
SRRC Control system”, in ICALEPCS,1995.
[2] Ch. Bertuzzi, et al, “USE OF LABVIEW AS LOCAL
SUPERVISION FOR THE LEP COOLING AND
VENTILATIONCONTROL SYSTEM”, inICALEPCS, 1995.