BNMR: frontend

From DaqWiki
Revision as of 13:00, 15 June 2016 by en>Suz
Jump to navigation Jump to search

Links

Introduction

The frontend task (MIDAS clients febnqr_vmic or febnmr_vmic) runs on the VMIC frontend computer (lxbnmr or lxbnqr), located in the VME crate. The VMIC is a 32-bit computer running linux. It has access to the same disk(s) as the Midas Host.

The frontend task is a MIDAS frontend task, and the frontend user code is linked with the MIDAS system frontend code and MIDAS libraries. The frontend user code discussed here was written specifically for the bnmr and bnqr experiments. Its underlying structure is that of the MIDAS example whose features are described in Frontend_user_code. The frontend code is identical for the two experiments bnmr and bnqr. Differences are handled with "ifdef" statements. Its purpose is to initialize, set up and read out the DAQ hardware modules.

When the frontend task is started, it performs initial initialization of the DAQ hardware. At begin-of-run, it loads the run parameters into the hardware modules (scaler(s),PSM), and loads the PPG control code (a loadfile previously written by client rf_config), into the PPG. It sets the DAQ hardware into acquisition mode, sets the first value of the sweep (if required), and sets the helicity. It then starts the first PPG cycle by starting the PPG. While the PPG cycle is running, it checks for Scaler half-full, reads out the data from the scaler(s) when needed. At the end of the cycle, it processes the data, storing it as histograms (Type 2 (TD)), calculates scaler sums and adds data to the cumulative scalers. It sends out data banks (Type 1 only), scaler and information banks at the end of each cycle. It flips the helicity, increments the sweep device (if needed) and restarts the PPG for the next cycle. For Type 2 runs, it sends out the histogram data banks periodically.

At end-of-run, the frontend program sends out the final data and disables the DAQ hardware.

Polling in the frontend

When running the PPG cycle, the frontend program polls the SIS3801 Scaler to see if its internal data buffer needs reading out (looks for scaler half-full), in which case it reads the scaler data into a buffer. The bnmr and bnqr experiments do not usually produce enough scaler data during the cycle to require reading out before the end of the PPG cycle.

The PPG produces a pulse train of "MCS next" output signals during each cycle. The number of pulses corresponds to the number of dwell times (number of bins). The MCS Next signals advance the Scaler to the next bin (connected to Scaler input "External Next"). This signal is called "Load Next Event" (LNE). The continuous operation of the frontend depends on the Scaler receiving the correct number of LNE i.e. MCS Next pulses. If too few are received, the PPG cycle will not be restarted. If too many, the PPG will continue to cycle, but the data will be no good. The scaler counts the number of LNE pulses it receives, and the number is available to be read via the acquisition count register.

The frontend program polls the acquisition count register. When this number reaches the expected number of bins, the PPG cycle is complete, and the frontend goes into its end-of-cycle routine, reads out the final data from the scaler(s) and processes the data. It then restarts the PPG for the next cycle (single channel mode) or waits for an external start (dual channel mode).


Source Code The source code is stored in the DAQ CVS repository under the directory "bnmr". Local copies are checked out into the main DAQ directories for BNMR and BNQR, i.e. /home/<beamline>/online/<beamline> where <beamline> is either bnmr or bnqr. The main program is febnmr.c, which includes bnmr.init.c and various header files. Other code needed includes bnmr_epics.c .



To Build the frontend code

The frontend code is located in directory /home/<beamline>/online/<beamline> where <beamline> is bnmr or bnqr (see BNMR#Nomenclature). The main frontend user code is called febnqr_vmic.c. For bnmr, a softlink febnmr_vmic.c points to this code. The Makefile in the main DAQ directory is identical for bnmr and bnqr experiments. The environment variable BEAMLINE is used to set up the definitions automatically to build the frontend for either bnmr or bnqr experiments.

The code runs on and must be built on the 32-bit VMIC computer. To build the code, log onto lxbnmr or lxbnqr as user bnmr or user bnqr respectively. Then type

cd  /home/<beamline>/online/<beamline>
make

The task will be called febn[mq]r_vmic.exe (see BNMR#Nomenclature).

To completely rebuild the frontend task, execute "make clean" before rebuilding.