IOC Application for BPM Data-acquisition System
Yong HU huyong1979@gmail.com

1 OVERVIEWThe BPM data-acquisition (DAQ) system of KEK Linac uses Tektronix DPO7104 oscilloscopes as digitizers andsignal processors to measure BPMs’ signals and calculate beam positions and beam charges. The BPM DAQ
software, which was a non-EPICS and windows-program, has been upgraded to be based on EPICS that makes theDPO oscilloscope act as Channel Access Server. This new DAQ system is expected to satisfy the requirement offast measuring beam-position and beam-charge when 50Hz beam-mode switching of Linac is operated in nearfuture.
The EPICS-based BPM DAQ software (the IOC name is “montekIOC”) implements the device support of two kindsof EPICS records. One is waveform record which contains the values of all BPMs’ parameters (beam position, beamcharge, etc.) in one DPO oscilloscope. The other is stringout record which is used to adjust the oscilloscope’s
settings (vertical range, horizontal delay, etc.)

2 IMPLEMENTATIONThe new DAQ software (montekIOC) is based on and evolved from the old one (montekdpo). The basic principles
for implementing montekIOC are:1)

Keep using shared memory programming technique. All data related to BPM are available in shared memory
which is read and written by the IOC. This makes montekIOC compatible with other BPM-related application
programs (shmsend.exe, uspwmd.exe, etc.) which are also base-on shared memory.

2)

To get data from shared memory efficiently, waveform record, instead of ai record, is adopted. And subArrayrecord is used to extract each element from waveform record.

3)

Ten beam modes are available in operation of KEK Linac. Independent waveform record and subArrayrecords are prepared for each beam mode. And the EPICS database files (.db) are automatically generated bya program.

4)

DPO7104 oscilloscope can perform single-sequence acquisition (ACQ: STOPAFTER SEQ) or continualacquisition (ACQ: STOPAFTER RUNSTOP). To improve the IOC’s updating rate (50Hz), continual acquisition
is preferable.

5)

Since the DPO oscilloscope runs in continual acquisition mode, it’s difficult to make montekIOC synchronizedwith extern trigger signal. So, the IOC is triggered by an EPICS record which is generated by the event
timing system (EVG module) via Channel Access.

2.1 Source files

Except the file ‘montekdpo.cpp’, all other files of the old DAQ software are kept in montekIOC. The postfix ‘.cpp’ ischanged to ‘.c’ and some modifications are made on the file ‘tek.c’. Source files of montekIOC are shown in table 1.
Table 1 Source files of montekIOC
File namemain functions

Note

cmprepare.c1) cmprepare( ); 2) datasize( );prepare shared memory; get oscilloscope’s setting
parameters from ‘teksp.dat’ filetek.c1) tek_open( ); 2)tek_init( );operate DPO oscilloscope: open tekVisa, set vertical3) tek_verset( ); 4) tek_acq( ); ……

range, acquire waveform data, etc.

1)spread( ); 2)spmeas( );measure BPM electrode signals and calculate beam3)spcalc( );positions and beam charge

spwmerr.c1)errend( ); 2) errmsg( );handle errors

drvMontek.c

1)setup_osc( ): setup oscilloscope

driver support routines for DPO7104; initialize

2)get_pos_cur( ): position and charge

DPO oscilloscope.

1)init_wf_record( );device support of waveform record; get BPMs'

2) read_wf_montek( )positions, beam charges, peak-peak voltages, etc.

1) init_stringout_record( );device support of stringout record; set oscilloscope's2) write_stringout_montek( )vertical range, horizontal delay, etc.

spmeas3.c

devWfMontek.c

devStringoutMontek.c

2.2 Driver and device support of montekIOC
The file ‘drvMontek.c’ is for driver support, whose main task is to initialize the IOC (create shared memory, opentekVisa session, set oscilloscope, etc.) by init_montek( ). Additionally, two important functions are implemented.
One is setup_osc( ) which is used to adjust oscilloscope’s settings. The other is get_pos_cur() which is used to getbeam positions and beam charges and called by ‘devWfMontek.c’. setup_osc() calls many tekVisa-related functions
including tek_verset( ), tek_horset( ), tek_dlyset( ), etc. get_pos_cur( ) calls three functions including tek_acq( ),spmeas( )and spcalc( ).
The file ‘devWfMontek.c’ is for device support of waveform record which is the core of montekIOC. Two device
support routines are implemented. One is init_wf_record( ) whose main task is to allocate memory space(‘paraData’) for BPM-related data. The other is very important for montekIOC and it’s read_wf_montek( ) whosetask is to make beam positions and beam charges available in waveform record. Once montekIOC gets beam-mode
value from event timing system, read_wf_montek() will start to be processed and to perform following operations:
1)set oscilloscope by setup_osc( ) only when Linac operators change oscilloscope’s vertical range, delay time, .etc;2)select oscilloscope’s data source (CH3 and CH4 are dedicated for KEKB e+); 3) get the data of beam positions andbeam charges by get_pos_cur( ); 4)calculate the average and standard deviation values of beam positions andcharges; 5) copy all BPM-related data to ‘paraData’ memory space; 6) The last step: copy ‘paraData’ to the memory
space of waveform record.

The file ‘devStringoutMontek.c’ is for device support of stringout record whose main task is to adjust oscilloscope's
vertical range of CH1,2 and CH3,4, horizontal delay, etc.

2.3 EPICS naming convention
montekIOC uses five kinds of EPICS records which include event, calcout, waveform, subArray and stringout. TheEPICS naming convention for these records are shown in table 2.
Table 2 EPICS naming convention
record typenaming convention(example)

note

event

LIiBM:montekName:MODE

One event record is used to get beam-mode value from

(LIiBM:montek3A1:MODE)

event timing record “LIiEV:sa”.

LIiBM:montekName:MODE:beam-mode

Ten calcout records are used to choose which waveform

LIiBM:montek3A1:MODE:KBE

record to be processed according to beam-mode.

LIiBM:montekName:WAVE:beam-mode

Ten waveform records are used for ten different beam-

LIiBM:montek3A1:WAVE:KBE

mode operations.

LIiBM:BPMname_bunch:parameter:beam-mode

It’s used to extract each element of waveform record.

LIiBM:SP_31_4_1:ISNGL(or IAVE, ISGM):KBE

260 (2*13*10) subArray records for one BPM.

LIiBM:montekName:settings

Four stringout records are used to change oscilloscope's

LIiBM:montek3A1: VER(or DLY, SP, VER_34)

vertical range of CH1,2 and CH3.4, horizontal delay, etc

calcout

waveform

subArraystringout

2.4 auto-generating database
A lot of EPICS records need to be prepared. The numbers of subArray records for one BPM can be calculated asfollowing: 13 (beam-parameters: x, y, i, average, sigma, peak-peak voltages) * 10 (beam modes) * 2 (bunches) = 260.
Each oscilloscope (montekIOC) measures 2~6 BPMs. So, if the oscilloscope controls 6 BPMs, 1560 subArrayrecords are needed.
Preparing so many records manually is very difficult. A simple windows-program (autoConfigure.exe, the source
file is autoConfigure.cpp) is developed to auto-generate database files (.db) and startup file (st.cmd).
When the oscilloscope is rebooted, it can automatically update files, start ‘shmsend.exe’ and ‘uspwmd.exe’,configure montekIOC, generate .db and st.cmd files and finally start the IOC by using some .bat files(Startup_montek.bat, start_monsoft.bat, config_startIOC.bat, etc.).

3 USAGE
Using montekIOC software is easy. The software package is available on Linac servers: \\orange\montek or\\eggplant\public\BPM . Find the ‘epics’ folder and copy the whole folder (it contains ‘base-3.14.8.2’ and‘montekIOC’) to Local Disk (C) of PDO7104 oscilloscope. Then reboot the DPO. The montekIOC will automaticallyrun.

In the future, if ‘shmsend.exe’ and ‘uspwmd.exe’ are not used, comment out the corresponding commands in‘start_monsoft.bat’.
‘cygwin.bat’ can be used to recompile (use 3.80 version of make.exe) the source codes of montekIOC. It’s better toinstall Microsoft Visual Studio and Cygwin in DPO oscilloscope.

4 CONCLUSION
Many methods and techniques for implementing montekIOC were tested, such as waveform record VS ai record,
continual acquisition VS single-sequence acquisition, single-thread programming VS multi-thread programming.
The best combination is waveform record + continual acquisition + single-thread programming.
Performance tests on montekIOC were carried out. The test results show that montekIOC can work.