####################################################### # ### ### # # ### EPICS Database for ### # # ### I2C PCF8591 board ### # # ### ### # # ### author: B. Carvalho IPFN ### # # ### ### # # ### Ref 2.0; 2019-10-14 ### # # ### ### # # ### macros: ID I2C address of ADC ### # # ### Description: ### # # ### This is an example DB file using ### # # ### stream(asynI2C) to read/write ### # # ### an PCF8591 ADDA chip ### # ####################################################### ##################################################### # Read/Write pcf8591 register @ address 0x48=d72 ### # ##################################################### record( mbboDirect, "$(P)$(R)PCF8591:72:CTRLREGISTER") { field( DTYP, "stream") field( OUT, "@pcf8591.proto wReg(72) I2C") field( SHFT, "0") field( NOBT, "8") field(VAL, 255) field(PINI,"YES") } # Receiving two bytes. last one counts record( longin, "$(P)$(R)PCF8591:72:ADC_CH1" ) { field(DTYP, "stream") field(INP, "@pcf8591.proto rConvAdc0(72) I2C") # field( FLNK, "$(P)$(R)PCF8591:72:CHANNEL1" ) } record( calc, "$(P)$(R)PCF8591:72:BYTE2_CH1" ) { field( INPA, "$(P)$(R)PCF8591:72:ADC_CH1 PP NMS") # extract LSB =last byte received field( CALC, " A & 255 " ) } record( ai, "$(P)$(R)PCF8591:72:CHANNEL1" ) { field( INP, "$(P)$(R)PCF8591:72:ADC_CH1 PP NMS") field( SCAN, "1 second") field( ASLO, "0.02" ) field( AOFF, "0" ) field( EGU, "V" ) field( PREC, "3" ) field( HOPR, "5.0" ) field( LOPR, "0.0" ) } record( longin, "$(P)$(R)PCF8591:72:ADC_CH2" ) { field(DTYP, "stream") field(INP, "@pcf8591.proto rConvAdc1(72) I2C") #field( FLNK, " } record( calc, "$(P)$(R)PCF8591:72:BYTE2_CH2" ) { field( INPA, "$(P)$(R)PCF8591:72:ADC_CH2 PP NMS") field(SCAN, "1 second") # LSB i=last byte received field( CALC, " A & 255 " ) }