Calibration of ADC readings `HIT` to energy `E` works like this ``` E = MULI HIT * gain E = ADDI HIT + pedl ``` The `pedl` was calculated as ``` pedl = -$floor(p*gain) ``` where `p` is the ADC reading corresponding to E = 0 keV. Since `p` is a large magnitude negative number, the limited precision of the `MULI` instruction parameter causes significant errors in `pedl`. This patch aims to fis those errors. The new formula for `pedl` is ``` pedl = $floor(-p*$MRND(gain)) ``` i.e., we use the same value for `gain` as the `MULI` instruction. This is now in place for any automatic calibration calculations in `step_temp_calib.l3`. For the FS in space we use a fixed precomputed calibration. This is based on the TVAC FS calibration for T=-36°C, with some adjustments for the changed `acq_time=6`. The TVAC calib has been saved earlier to `step_fs_calib-36.calib` with full precision, i.e., without taking `$MRND()` into account. The awk script `step_fs_calib-36.awk` reverts those calculations, applies the adjustments, and outputs the adjustes numbers. Since awk does not have access to `$MRND()`, the script has been changed to output formulas for `pedl`, including `$MRND()`,
86 lines
2.7 KiB
Makefile
86 lines
2.7 KiB
Makefile
# Makefile for GNU make, building all Solo L3 triggers.
|
|
|
|
STEP_SOURCES = step
|
|
STEP_MODELS = em pf pqm fm fs
|
|
STEP_VARIANTS = small
|
|
|
|
STEP_T_CALIB = step_T-calib
|
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
L3C = ../../l3.py
|
|
L3DIS = ../../l3dis.py
|
|
|
|
MODEL =
|
|
VARIANT =
|
|
|
|
ifneq ($(MODEL),)
|
|
DMODEL = -DM_$(shell echo $(MODEL) | tr '[:lower:]' '[:upper:]')
|
|
endif
|
|
|
|
ifeq ($(VARIANT),)
|
|
MODVAR = $(MODEL)
|
|
else
|
|
MODVAR = $(shell echo $(MODEL) $(VARIANT) | tr ' ' _)
|
|
DVARIANT= -DV_$(shell echo $(VARIANT) | tr '[:lower:]' '[:upper:]')
|
|
endif
|
|
|
|
L3FLAGS =
|
|
L3FLAGSS = $(DMODEL) $(DVARIANT) $(L3FLAGS)
|
|
|
|
all: step_all basics
|
|
basics: $(STEP_SOURCES:%=%_l3.py) $(STEP_SOURCES)_$(STEP_VARIANTS)_l3.py
|
|
l3c_all: step_l3c $(STEP_SOURCES:%=%.l3c) $(STEP_SOURCES)_$(STEP_VARIANTS).l3c
|
|
l3v_all: step_l3v $(STEP_SOURCES:%=%.l3v) $(STEP_SOURCES)_$(STEP_VARIANTS).l3v
|
|
|
|
-include *.d
|
|
|
|
%.l3c: %.l3 $(L3C)
|
|
$(L3C) $(L3FLAGS) $($*_FLAGS) -g hex -o $@ -2 $<
|
|
%.l3v: %.l3 $(L3C)
|
|
$(L3C) $(L3FLAGS) $($*_FLAGS) -g verilog -vv -o $@ -2 -l $*.l3d $<
|
|
%_l3.py: %.l3 $(L3C)
|
|
$(L3C) $(L3FLAGS) $($*_FLAGS) -g python -vv -o $@ -2 -l $*.l3d $<
|
|
|
|
findmodel = $(firstword $(filter $(HETEPT_MODELS) $(STEP_MODELS),$(shell echo $* | tr _ ' ')))
|
|
findvariant = $(firstword $(filter-out $(HETEPT_MODELS) $(STEP_MODELS),$(shell echo $* | tr _ ' ')))
|
|
|
|
ifeq ($(MODEL)$(VARIANT),)
|
|
step_%_l3.py step_%.l3c step_%.l3v: step.l3 $(L3C)
|
|
$(MAKE) MODEL=$(findmodel) VARIANT=$(findvariant) $@
|
|
else
|
|
%_$(MODVAR).l3c: %.l3 $(L3C)
|
|
$(L3C) $(L3FLAGSS) $($*_FLAGS) $($*_$(MODEL)_FLAGS) -g hex -o $@ -2 $<
|
|
%_$(MODVAR).l3v: %.l3 $(L3C)
|
|
$(L3C) $(L3FLAGSS) $($*_FLAGS) $($*_$(MODEL)_FLAGS) -g verilog -vv -o $@ -2 -l $*_$(MODVAR).l3d $<
|
|
%_$(MODVAR)_l3.py: %.l3 $(L3C)
|
|
$(L3C) $(L3FLAGSS) $($*_FLAGS) $($*_$(MODEL)_FLAGS) -g python -vv -o $@ -2 -l $*_$(MODVAR).l3d $<
|
|
endif
|
|
|
|
STEP_FILES1 = $(foreach M,$(STEP_MODELS),$(STEP_SOURCES:%=%_$M))
|
|
STEP_FILES = $(STEP_FILES1) $(foreach V,$(STEP_VARIANTS),$(STEP_FILES1:%=%_$V))
|
|
STEP_ALL = $(patsubst %,%_l3.py, $(STEP_FILES))
|
|
step_all: $(STEP_ALL)
|
|
STEP_L3C = $(patsubst %,%.l3c, $(STEP_FILES))
|
|
step_l3c: $(STEP_L3C)
|
|
STEP_L3V = $(patsubst %,%.l3v, $(STEP_FILES))
|
|
step_l3v: $(STEP_L3V)
|
|
$(STEP_ALL) $(STEP_L3C) $(STEP_L3V) step.gold: $(patsubst %, %.l3, $(STEP_SOURCES)) step_config.l3 step_pha.l3 step_calib.l3 step_calib_small.l3 step_temp_calib.l3
|
|
|
|
%.l3dis: %.l3c $(L3DIS)
|
|
$(L3DIS) -F 'R%(addr)-3d= %(cond)-3s %(mnem)-5s %(args)-25s # 0x%(instr)08x' $< > $@
|
|
|
|
%.l3cc: %.l3dis
|
|
$(L3C) -g hex -o $@ $<
|
|
-diff -u $*.l3c $*.l3cc
|
|
|
|
clean:
|
|
rm -f *.l3[cdv] *.l3dis *.l3cc *_l3.py *_l3.pyc .*.forward .*.forward.new *.d
|
|
|
|
%.gold: $(L3C) %.l3
|
|
$(L3C) -2vv -g dis -DM_FS $(word 2, $^) >$@ 2>&1
|
|
|
|
gold: step.gold
|
|
|
|
step_fs_calib-36_v7.3.calib: step_fs_calib-36.awk step_fs_calib-36.calib
|
|
$^ > $@
|