# bpmPadAfe-stdalone.db; database for controlling stripline-BPM AFE # This database should not be loaded on PADs w/o AFE hardware. # # THIS FILE WAS GENERATED WITH msi FROM padBpmAfe.template AND EXPANDED FOR # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # MODE: b -- standalone PAD # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # NOTE: The template can be configured by means of proper macro # substitutions to # a) operate in 'normal' LCLS stripline BPM mode. In this # mode a few CA links to the VME/main IOC are active fetching # '$(dev):ACCESS', '$(dev):ATTO' and '$(dev):CLAO' from the # main IOC. # # b) standalone mode. In this mode, ACCESS is ignored and 'ATTO' and # 'CLAO' are instantiated / hosted on the PAD IOC. # # Mode 'a' is chosen by substituting # 'suffix' ='L', # 'propomsl' = 'closed_loop' # 'attomsl' = 'supervisory' # 'chrgL' = ' CPP' # 'actlL' = '$(dev):ACCESS.RVAL CP' # 'attoL' = '$(dev):ATTO CP' # 'claoL' = '$(dev):CLAO CP' # # Mode 'b' is chosen by substituting # 'suffix' = '' (empty) # 'propomsl' = 'supervisory' # 'attomsl' = 'supervisory' # 'chrgL' = '0' # 'actlL' = '0' # 'attoL' = '0' # 'claoL' = '0' # # SUBSTITUTIONS: # Substitutions available in main .db file # 'dev' : device name prefix # 'chrg' : name of global attenuator PV (for scaling all AFE attenuators with beam charge)(mode a) or '0' (mode b) # 'chrg' is only available in mode 'a'. # # Substitutions available in the template -- intended to be expanded when generating '.db' with MSI. # # 'chrgL' : name of global attenuator PV (for scaling all AFE attenuators with beam charge) + CPP attribute (mode a) or '0' (mode b) # 'actlL' : name of ACCESS.RVAL PV + CP attribute (mode a) or '0' (mode b) # 'attoL' : name of ATTO PV + CP attribute (mode a) or '0' (mode b) # 'claoL' : name of CLAO PV + CP attribute (mode a) or '0' (mode b) #'attomsl' : default/initial OMSL; if 'supervisory' then the 'ATT' PV controls attenuators # if 'closed_loop' then ATT is fetched from it's DOL (=='chrg' PV). # 'suffix' : see above. #'propomsl': see above. # # LINKS (pointing outside of this file): These links are only used in mode a and set to '0' in mode b. # $(dev):ATT.DOL <---- $(chrg) CPP // DEFINED IN: [depends on 'chrg' macro substitution]. # $(dev):ACTL.DOL <---- $(dev):ACCESS.RVAL CP // DEFINED IN: associated main IOC database 'IOC--BPbpm.db' # $(dev):ATTOL.DOL<---- $(dev):ATTO CP // DEFINED IN: associated main IOC database 'IOC--BPbpm.db' # $(dev):CLAOL.DOL<---- $(dev):CLAO CP // DEFINED IN: associated main IOC database 'IOC--BPbpm.db' # # record(bo, "$(dev):CLKS") { field(DESC, "AFE Clock Source") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0,qspiPadAfe") field(MASK, "8") field(ZNAM, "External AFE Clk") field(ONAM, "Internal AFE Clk") field(VAL, "1") field(PINI, "YES") } record(mbbo, "$(dev):CALM") { field(DESC, "AFE Cal. Mode") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0,softTogAfe") field(NOBT, "2") field(SHFT, "0") field(ZRST, "CAL RED") field(ZRVL, "0") field(ONST, "CAL GRN") field(ONVL, "1") field(TWST, "CAL BOTH") field(TWVL, "2") field(THST, "CAL NONE") field(THVL, "3") # 'soft toggle' mode. NOTE: LSB must match RED or GRN # which choses the mode to start with field(FRST, "CAL TOGGLE") field(FRVL, "4") field(VAL, "4") field(PINI, "YES") } record(longout, "$(dev):CALA") { field(DESC, "AFE Cal. Att.") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+1,qspiPadAfe") field(LOPR, "0") field(HOPR, "31") field(DRVL, "0") field(DRVH, "31") field(EGU, "dB") } record(longout, "$(dev):ATT1") { field(DESC, "AFE Att. 1") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+2,qspiPadAfe") field(LOPR, "0") field(HOPR, "15") field(DRVL, "0") field(DRVH, "15") field(EGU, "dB") } record(longout, "$(dev):ATT2") { field(DESC, "AFE Att. 2") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+3,qspiPadAfe") field(EGU, "dB") field(LOPR, "0") field(HOPR, "15") field(DRVL, "0") field(DRVH, "15") field(EGU, "dB") } record(longin, "$(dev):VERS") { field(DESC, "AFE Firmware Vers.") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(INP, "#C0S0@AFE+5,qspiPadAfe") field(LOLO, "3") field(LLSV, "MAJOR") field(PINI, "YES") } record(longout, "$(dev):AODL") { field(DESC, "Delay Trig -> AMP On") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0x10,qspiPadAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev):R1DL") { field(DESC, "Delay AMP On -> RF1") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0x11,qspiPadAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev):RFWD") { field(DESC, "RF Pulse Width") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0x13,qspiPadAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev):OFFT") { field(DESC, "Delay RF Off -> Ctrl Sw.") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0x14,qspiPadAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev):R2DL") { field(DESC, "Ctrl Sw. -> RF2") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+0x12,qspiPadAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } # This record just issues a CAL trigger record(longout, "$(dev):CALT") { field(DESC, "AFE CAL Soft Trigger") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+6,qspiPadAfe") } # This record issues a CAL trigger, # waits for 'VAL' cycles (CPU dependent) # and then issues a ADC trigger, i.e., # it runs a full, soft calibration # cycle. record(longout, "$(dev):SFTC") { field(DESC, "AFE Soft CAL Acq") field(DTYP, "BusAddress") # address is only used for chip-select field(OUT, "#C0S0@AFE,softCalAfe") field(DRVL, "0") field(LOPR, "0") field(HOPR, "1000") field(DRVH, "1000") } # NOTE: Reseting the limiter does NOT work (seems HW doesn't implement it) record(bo, "$(dev):LMTR") { field(DESC, "Reset AFE Limiter") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE+4,qspiPadAfe") field(MASK, "1") field(ZNAM, "ON") field(ONAM, "OFF") field(VAL, "0") field(PINI, "YES") } # Placeholders (just to give PVs a name...) # Total attenuation (but ATTO is still added to this) record(longout, "$(dev):ATT") { field(DESC, "AFE Total Attenuation") field(OUT, "$(dev):ATTC.A PP") field(DRVL, "0") field(DRVH, "30") field(LOPR, "0") field(HOPR, "30") field(EGU, "dB") field(DOL, "0") field(OMSL, "supervisory") field(VAL, "30") field(PINI, "YES") } # This subroutine record performs the # following operation (ATTC.D defines # the breakpoint where ATT1 kicks in # -- it depends on losses and gains: # BPT = G1 + L1 - L2 # with # G1: gain of 1st stage, # L1: loss + NF upstream of 1st stage, # L2: loss between 1st and 2nd stage + NF of 2nd stage # # if L1 : 2dB cable, 3dB 1st Filter, 1dB Att1 residual, 2.8dB NF = 8.8dB # L2 : 1dB Att2 residual, 4.5dB BPF, 3dB NF = 8.5dB # G1 : = 20.0dB # # -> breakpoint ~ 20dB # # if ( (T=ATT+ATTO) > 30 ) # T = 30 # endif # # if ( (A1 = floor((T - ATTC.D)/2)) < 0 ) # A1 = 0; # A2 = T; # else # A2 = T - A1 # endif # if ( A2 > 15 ) # A1 = A2-15 # A2 = 15 # endif # # CA = CLAO - ATT # if ( CA < 0 ) # CA = 0 # endif # # Then, it writes three links: # $(dev):ATT1 = A1 # $(dev):ATT2 = A2 # $(dev):CALA = CA # record(sub, "$(dev):ATTC") { # Note: this record uses it's name to calculate # db link addresses to ATT1, ATT2, CALA field(DESC, "AFE Total Att. Calc.") # initialize fields to max. attenuation: # During init: # 1. hw initializes to max # 2. this record holds max # 3. PINI of the placeholder PVs (ATT, ATTO & friends) # trickle in and cause the total attenuation to # go down... field(A, "30") field(B, "0") field(C, "60") field(D, "20") field(EGU, "dB") field(INAM, "subAttIni") field(SNAM, "subAtt") } #propagate 'ACCESS.RVAL' state to #attenuator control #This record is unused in stdalone mode 'b' record(bo, "$(dev):ACTL") { field(DESC, "ATT OMSL Ctrl") field(DTYP, "Soft Channel") field(DOL, "0") field(OMSL, "supervisory") field(OUT, "$(dev):ATT.OMSL PP") } ### ### Keep 'ATTO' and 'CLAO' on the main/VME IOC. ### It is more confusing but then we don't have ### to restore anything across reboots on the PAD ### IOC... ### ### NOTE: We could use the INPB / INPC ### links of ATTC directly but we DONT. ### Potentially, ATTC can be processed ### on every shot -- we don't want the ### links to be fetched every time for ### efficiency reasons. Hence the 'propagator' ### records which monitor ATTO/CLAO and ### write to ATTC.B ATTC.C only when ### necessary... record(longout, "$(dev):ATTO") { field(DESC, "ATTO Propagator") field(DTYP, "Soft Channel") field(DOL, "0") field(OMSL, "supervisory") field(OUT, "$(dev):ATTC.B PP") field(EGU, "dB") } record(longout, "$(dev):CLAO") { field(DESC, "CLAO Propagator") field(DTYP, "Soft Channel") field(DOL, "0") field(OMSL, "supervisory") field(OUT, "$(dev):ATTC.C PP") field(EGU, "dB") }