# Count the index in the pedestal array continously and drive the # processing of the current pedestal array. Resets the index when # reaches grecord(calcout, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_cnt") { field(SCAN, "2 second") field(CALC, "A<=$(NELM)+5?A+1:0") field(INPA, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_cnt") field(FLNK, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_live") field(DOPT, "Use OCAL") field(OOPT, "Every Time") } # # Constantly put the recent voltage reading into the first (0th element) of OAV after # right-shifting the OAV. If the number of elements reaches NELM send the OAV into # the buffer waveform field. # # grecord(acalcout, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_live") { field(SCAN, "Passive") field(CALC, "B==$(NELM)+6?1:0" ) field(OCAL, "(ARR(A)){0,0}+(AA>>1)" ) field(INPA, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_nv") field(INPB, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_cnt") field(INAA, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_live.OAV" ) field(NELM, "$(NELM)") field(DOPT, "Use OCAL") field(OOPT, "When Non-zero") field(OUT , "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_buf PP") } # # reset the current array to zeros when the beam is on # grecord(acalcout, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_reset") { field(SCAN, ".2 second") field(CALC, "C<0.5&&E<0.5&&D<0.5?1:0") field(INPA, "IBCAD00CRCUR6") field(INPB, "$(PREF)AC:$(RING):min_current") field(INPC, "ISD0I011G") field(INPD, "$(PREF)AC:force_ped_calc") field(INPE, "IDA5C00I") field(INAA, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_buf_mt") field(OCAL, "AA") field(DOPT, "Use OCAL") field(OOPT, "When Non-zero") field(OUT , "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_live.OAV") field(FLNK, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_reset_cnt PP") } # # reset the pedestal reading counter to zero when there is beam # grecord(calcout, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_reset_cnt") { field(SCAN, "Passive") field(CALC, "C<0.5&&E<0.5&&D<0.5?1:0") field(INPA, "IBCAD00CRCUR6") field(INPB, "$(PREF)AC:$(RING):min_current") field(INPC, "ISD0I011G") field(INPD, "$(PREF)AC:force_ped_calc") field(INPE, "IDA5C00I") field(OCAL, "0") field(DOPT, "Use OCAL") field(OOPT, "When Non-zero") field(OUT , "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_cnt PP") } # Buffer waveform that gets filled when a full NELM array is accumulated withou # beam present. # grecord(waveform, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_buf_mt") { field(SCAN, "Passive") field(FTVL, "DOUBLE") field(NELM, "$(NELM)") } # Buffer waveform that gets filled when a full NELM array is accumulated withou # beam present. # grecord(waveform, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_buf") { field(SCAN, "Passive") field(FTVL, "DOUBLE") field(NELM, "$(NELM)") } # Grab the array in the buffer waveform each time processes and # caclulate the average value of the buffer waveform. The average # value of the waveform is put into the ai record for the pedestal # grecord(acalcout, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_avg") { field(SCAN, ".5 second") field(CALC, "AVG(AA)" ) field(INAA, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_buf") field(NELM, "$(NELM)") field(DOPT, "Use CALC") field(OOPT, "Every Time") field(OUT , "$(PREF)AC:$(RING):ped:$(C)_$(SGN) PP") } # # Most recent value of the pedestal caclulated when there # was not beam. Should be used in the position calculations. # grecord(ai, $(PREF)AC:$(RING):ped:$(C)_$(SGN) ) { field(DESC, "AC $(RING) $(C)-$(SGN) pedestal") field(SCAN, "Passive") field(PREC, "3" ) field(EGU , "V") } # # Normalized voltage a defined by R. Jones without pedestal subtraction. # Ideally this needs to be zero when there is no beam # grecord(calcout, "$(PREF)AC:$(RING):ped:$(C)_$(SGN)_nv") { field(DESC, "AC $(RING) $(C)-$(SGN) norm. voltage") field(SCAN, "Passive") field(CALC, "A*B*C") field(INPA, "$(V_RDBK) CPP NMS") field(INPB, "$(ADC2V)") field(INPC, "$(GAIN)") field(OOPT, "Every Time") field(DOPT, "Use CALC") }