BNMR: frontend

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

Links

Introduction

The frontend task (febnqr_vmic or febnmr_vmic runs on the VMIC frontend computer located in the VME crate (lxbnqr or lxbnmr). 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 the MIDAS library. 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 modules (PPG,PSM,Scaler(s),VMEIO32). At begin-of-run, it loads the run parameters into the hardware modules, and loads the PPG control code (a loadfile compiled using the input parameters, and written by client rf_config), into the PPG. It sets the DAQ hardware into acquisition mode, sets the first value of the sweep (Type 1 I-MUSR only), and sets the helicity using EPICS Channel Access. It then starts the first PPG cycle by starting the PPG. While the PPG cycle is running, it checks for Scaler half-full, reading out the data from the scaler internal buffer 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.

Note
the above describes the situation in single channel mode. In dual channel mode each cycle is started by an external signal to the PPG which occurs when the beam is switched between channels).


Polling in the frontend for end-of-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, and the DAQ will appear to grind to a halt. If too many, the PPG will continue to cycle, but the data will be no good (overlapping cycles). The scaler counts the number of LNE pulses it receives, and this number can 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).



To Build the frontend code

The frontend code is located in directory /home/<beamline>/online/<beamline>. 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.