# bpmAfe.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 bpmPadAfe.template or bpmVmeDigiAfe.db AND EXPANDED FOR # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # MODE: a -- Use VME IOC PVs # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # 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,undefined):ATT.DOL <---- $(chrg,undefined) CPP // DEFINED IN: [depends on 'chrg' macro substitution]. # $(dev,undefined):ACTL.DOL <---- $(dev,undefined):ACCESS.RVAL CP // DEFINED IN: associated main IOC database 'IOC--BPbpm.db' # $(dev,undefined):ATTOL.DOL<---- $(dev,undefined):ATTO CP // DEFINED IN: associated main IOC database 'IOC--BPbpm.db' # $(dev,undefined):CLAOL.DOL<---- $(dev,undefined):CLAO CP // DEFINED IN: associated main IOC database 'IOC--BPbpm.db' # # # # Additional macros added to support other architectures. These macros do NOT need to be populated for PAD AFEs # because the default value is set for them: # # instance - AFE identifier (0,1,... or identifying string) # devsup - device support name (qspiAfe for 'generic' suppport used by SLAC RTM and XTA AFE) # type - AFE flavor, 0 for PAD, 1 for XTA, 2 for RTM # record(longout, "$(dev,undefined):CALA") { field(DESC, "AFE Cal. Att.") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+1,qspiAfe") field(LOPR, "0") field(HOPR, "31") field(DRVL, "6") field(DRVH, "31") field(EGU, "dB") } record(longout, "$(dev,undefined):ATT1") { field(DESC, "AFE Att. 1") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+2,qspiAfe") field(LOPR, "0") field(HOPR, "15") field(DRVL, "0") field(DRVH, "15") field(EGU, "dB") } record(longout, "$(dev,undefined):ATT2") { field(DESC, "AFE Att. 2") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+3,qspiAfe") field(EGU, "dB") field(LOPR, "0") field(HOPR, "31") field(DRVL, "0") field(DRVH, "31") field(EGU, "dB") } # AFE FW versions (decimal): # 4 original LCLS-I FW version # >=32 ATT2 has 32 dB range; before 16 dB # 33 200 MHz board # 34 140 MHz board w/ 6dB PAD removed # 35 200 MHz board w/ 6dB PAD removed # > 64 140 MHz board not used with PAD/coldfire (XTA) # 8 MicroTCA RTM record(longin, "$(dev,undefined):VERS") { field(DESC, "AFE Firmware Vers.") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(INP, "#C0S0@AFE$(instance,undefined)+5,qspiAfe") field(LOLO, "3") field(LLSV, "MAJOR") field(PINI, "YES") field(FLNK, "$(dev,undefined):ATTINIT") } record(longin, "$(dev,undefined):CSR") { field(DESC, "AFE Control and Status register") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(INP, "#C0S0@AFE$(instance,undefined)+0,qspiAfe") } record(longout, "$(dev,undefined):AODL") { field(DESC, "Delay Trig -> AMP On") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+0x10,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev,undefined):R1DL") { field(DESC, "Delay AMP On -> RF1") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+0x11,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev,undefined):RFWD") { field(DESC, "RF Pulse Width") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+0x13,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev,undefined):OFFT") { field(DESC, "Delay RF Off -> Ctrl Sw.") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+0x14,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVL, "255") } record(longout, "$(dev,undefined):R2DL") { field(DESC, "Ctrl Sw. -> RF2") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+0x12,qspiAfe") 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,undefined):CALT") { field(DESC, "AFE CAL Soft Trigger") field(DTYP, "BusAddress") # address is chip-select << 8 + register field(OUT, "#C0S0@AFE$(instance,undefined)+6,qspiAfe") } record(mbbo, "$(dev,undefined):CALM") { field(DESC, "AFE Cal. Mode") field(DTYP, "BusAddress") field(OUT, "#C0S0@AFE$(instance,undefined)+0,softTogAfe") field(NOBT, "2") field(SHFT, "0") field(ZRST, "CAL RED") field(ZRVL, "0") field(ONST, "CAL GRN") field(ONVL, "1") 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") } # Subroutine to set up attenuator limits at ioc startup. # Attenuator ranges vary among AFE types and FW versions # This record also in bpmVmeDigiAfePart.db record(aSub, "$(dev,undefined):ATTINIT") { field(DESC, "Set up AFE att limits") field(SNAM, "subAttSetup") field(FTA, "LONG") field(INPA, "$(dev,undefined):VERS") field(FTVA, "LONG") field(OUTA, "$(dev,undefined):ATT1.HOPR") field(FTVB, "LONG") field(OUTB, "$(dev,undefined):ATT1.DRVH") field(FTVC, "LONG") field(OUTC, "$(dev,undefined):ATT2.HOPR") field(FTVD, "LONG") field(OUTD, "$(dev,undefined):ATT2.DRVH") field(FTVE, "LONG") field(OUTE, "$(dev,undefined):ATT.HOPR") field(FTVF, "LONG") field(OUTF, "$(dev,undefined):ATT.DRVH") field(FTVG, "LONG") field(OUTG, "$(dev,undefined):ATT.VAL") field(FTVH, "LONG") field(OUTH, "$(dev,undefined):ATTC.D") field(FTVI, "LONG") field(OUTI, "$(dev,undefined):ATTC.E") field(FTVJ, "LONG") field(OUTJ, "$(dev,undefined):ATTC.F") field(FTVK, "LONG") field(OUTK, "$(dev,undefined):ATTO.DRVL") field(FTVL, "LONG") field(OUTL, "$(dev,undefined):ATTO.LOPR") field(FTVM, "LONG") field(OUTM, "$(dev,undefined):ATTO.DRVH") field(FTVN, "LONG") field(OUTN, "$(dev,undefined):ATTO.HOPR") field(FTVO, "LONG") field(OUTO, "$(dev,undefined):CLAO.DRVL") field(FTVP, "LONG") field(OUTP, "$(dev,undefined):CLAO.LOPR") field(FTVQ, "LONG") field(OUTQ, "$(dev,undefined):CLAO.DRVH") field(FTVR, "LONG") field(OUTR, "$(dev,undefined):CLAO.HOPR") field(FLNK, "$(dev,undefined):ATT") } # Total attenuation (but ATTO is still added to this) record(longout, "$(dev,undefined):ATT") { field(DESC, "AFE Total Attenuation") field(OUT, "$(dev,undefined):ATTC.A PP") field(DRVL, "0") field(DRVH, "30") field(LOPR, "0") field(HOPR, "30") field(EGU, "dB") field(DOL, "$(chrg,undefined) CPP") field(OMSL, "supervisory") field(VAL, "30") } # 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 # #----------------------------------------------------------------------------- # New RTM AFE characteristics are different (assume 140 ft LMR: 2.2db/100ft): # L1 : 3.1 dB cable, 4.5 dB 1st BPF, 1.1 dB att1, 3.3dB NF = 12.0dB # L2 : 1.1 dB att2, 2.7 dB NF, 1 dB BPF = 4.8dB # G1 : = 16.0dB # # -> breakpoint ~ 23dB # #----------------------------------------------------------------------------- # # Semantics of the different fields # A: Total attenuation (ATT records deposits value there) # B: ATTO # C: CLAO # D: BPT Breakpoint (see above) # E: (ATT1MAX) max. ATT1 attenuation (depends on version, set by ATTINIT) # F: (ATT2MAX) max. ATT2 attenuation (depends on version, set by ATTINIT) # # if ( (T=ATT+ATTO) > ATT1MAX + ATT2MAX ) # T = ATT1MAX + ATT2MAX # endif # # if ( (A1 = floor((T - BPT)/2)) < 0 ) # A1 = 0; # A2 = T; # else # if (A1 > ATT1MAX) # A1 = ATT1MAX; # endif # A2 = T - A1 # endif # # if ( A2 > ATT2MAX ) # A1 = A2-ATT2MAX # A2 = ATT2MAX # endif # # CA = CLAO + ATT1MAX + ATT2MAX - ATT # if ( CA < 0 ) # CA = 0 # else if ( CA > ACMAX ) # CA = ACMAX # endif # # Then, it writes three links: # $(dev,undefined):ATT1 = A1 # $(dev,undefined):ATT2 = A2 # $(dev,undefined):CALA = CA # record(sub, "$(dev,undefined):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,undefined):ACTL") { field(DESC, "ATT OMSL Ctrl") field(DTYP, "Soft Channel") field(DOL, "$(dev,undefined):ACCESS.RVAL CP") field(OMSL, "closed_loop") field(OUT, "$(dev,undefined):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... ### ### This db now used for AFEs controlled by either ### a VME IOC or a PAD IOC. Use the same db for ### both for simplicity. ### ### 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,undefined):ATTOL") { field(DESC, "ATTO Propagator") field(DTYP, "Soft Channel") field(DOL, "$(dev,undefined):ATTO CP") field(OMSL, "closed_loop") field(OUT, "$(dev,undefined):ATTC.B PP") field(EGU, "dB") } record(longout, "$(dev,undefined):CLAOL") { field(DESC, "CLAO Propagator") field(DTYP, "Soft Channel") field(DOL, "$(dev,undefined):CLAO CP") field(OMSL, "closed_loop") field(OUT, "$(dev,undefined):ATTC.C PP") field(EGU, "dB") } # Records only needed for RTM AFE record(longout, "$(dev,undefined):TRIG2BEAM") { field(DESC, "Trigger -> ADC trig") field(DTYP, "BusAddress") field(OUT, "#C0S0@AFE$(instance,undefined)+0x15,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVH, "255") field(PINI, "YES") } record(longout, "$(dev,undefined):RF2RED") { field(DESC, "Red RF -> ADC trig") field(DTYP, "BusAddress") field(OUT, "#C0S0@AFE$(instance,undefined)+0x16,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVH, "255") field(PINI, "YES") } record(longout, "$(dev,undefined):RF2GRN") { field(DESC, "Grn RF -> ADC trig") field(DTYP, "BusAddress") field(OUT, "#C0S0@AFE$(instance,undefined)+0x17,qspiAfe") field(EGU, "33ns") field(LOPR, "1") field(DRVL, "1") field(HOPR, "255") field(DRVH, "255") field(PINI, "YES") }