From 10b2504e23a28839329674b7c17a2aa057b3e3e1 Mon Sep 17 00:00:00 2001 From: Bernardo Carvalho Date: Wed, 6 Nov 2019 10:29:33 +0000 Subject: [PATCH] Added RS485 PVS --- .../ISTTOKrpiApp/Db/ISTTOKpfeiffer.db | 97 +++++++++++++++++++ .../ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKrs485.db | 49 ---------- epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/Makefile | 2 +- .../ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd | 18 +++- epics/iocs/ISTTOKrpi/protocols/pfeiffer.proto | 31 ++++-- 5 files changed, 138 insertions(+), 59 deletions(-) create mode 100644 epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKpfeiffer.db delete mode 100644 epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKrs485.db diff --git a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKpfeiffer.db b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKpfeiffer.db new file mode 100644 index 0000000..025c5a2 --- /dev/null +++ b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKpfeiffer.db @@ -0,0 +1,97 @@ +record (longin, "$(P)$(R)P001:M") +{ + field (DESC, "getPressure001 $(bus)") + field (DTYP, "stream") + field (INP, "@pfeiffer.proto getPressure001($(P)$(R)P001:E) $(bus)") + field (SCAN, "1 second") + field (FLNK, "$(P)$(R)P001") +} +record (longin, "$(P)$(R)P001:E") +{ + field (DESC, "Pressure001 exponent $(bus)") +} +record (calc, "$(P)$(R)P001") +{ + field (DESC, "ex ISTTOK:vacuum:Pressure_Chamber1") + field(INPA, "$(P)$(R)P001:M") + field(INPB, "$(P)$(R)P001:E") + field(CALC, "(A*0.001)*10.0**(B-20)") + field(PREC, "3") + field(EGU, "mBar") +} + +record (longin, "$(P)$(R)P002:M") +{ + field (DESC, "getPressure002 $(bus)") + field (DTYP, "stream") + field (INP, "@pfeiffer.proto getPressure002($(P)$(R)P002:E) $(bus)") + field (SCAN, "2 second") + field (FLNK, "$(P)$(R)P002") +} +record (longin, "$(P)$(R)P002:E") +{ + field (DESC, "Pressure002 exponent $(bus)") +} +record (calc, "$(P)$(R)P002") +{ + field (DESC, "Pressure_Primary1") + field(INPA, "$(P)$(R)P002:M") + field(INPB, "$(P)$(R)P002:E") + field(CALC, "(A*0.001)*10.0**(B-20)") + field(PREC, "3") + field(EGU, "mBar") +} + +record (longin, "$(P)$(R)P003:M") +{ + field (DESC, "getPressure003 Mantissa $(bus)") + field (DTYP, "stream") + field (INP, "@pfeiffer.proto getPressure003($(P)$(R)P003:E) $(bus)") + field (SCAN, "1 second") +# field (SCAN, "I/O Intr") + field (FLNK, "$(P)$(R)P003") +} + +record (longin, "$(P)$(R)P003:E") +{ + field (DESC, "Pressure003 Exponent $(bus)") +} +record (calc, "$(P)$(R)P003") +{ + field(DESC, "Pressure_Primary2") + field(INPA, "$(P)$(R)P003:M") + field(INPB, "$(P)$(R)P003:E") + field(CALC, "(A*0.001)* 10.0**(B-20)") + field(PREC, "3") + field(EGU, "mBar") +} + +record (longin, "$(P)$(R)P004:M") +{ + field (DESC, "getPressure004 Mantissa $(bus)") + field (DTYP, "stream") + field (INP, "@pfeiffer.proto getPressure004($(P)$(R)P004:E) $(bus)") + field (SCAN, "1 second") + field (FLNK, "$(P)$(R)P004") +} +record (longin, "$(P)$(R)P004:E") +{ + field (DESC, "Pressure004 Exponent $(bus)") +} +record (calc, "$(P)$(R)P004") +{ + field(DESC, "Pressure_TMP_Admission") + field(INPA, "$(P)$(R)P004:M") + field(INPB, "$(P)$(R)P004:E") + field(CALC, "(A*0.001)* 10.0**(B-20)") + field(PREC, "3") + field(EGU, "mBar") +} + +record(stringout,"$(P)$(R)RS485Debug") { + field(DESC, "") + field(DTYP, "stream") + field(OUT, "@pfeiffer.proto debug $(bus)") + field(VAL,"") +} + diff --git a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKrs485.db b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKrs485.db deleted file mode 100644 index 24c82f6..0000000 --- a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKrs485.db +++ /dev/null @@ -1,49 +0,0 @@ -record (longin, "$(P)$(R)P003:M") -{ - field (DESC, "getPressure003 Mantissa $(bus)") - field (DTYP, "stream") - field (INP, "@pfeiffer.proto getPressure003($(P)$(R)P003:E) $(bus)") - field (SCAN, "I/O Intr") - field (FLNK, "$(P)$(R)P003") -} - -record (longin, "$(P)$(R)P003:E") -{ - field (DESC, "Pressure003 Exponent $(bus)") -} -record (calc, "$(P)$(R)P003") -{ - field(INPA, "$(P)$(R)P003:M") - field(INPB, "$(P)$(R)P003:E") - field(CALC, "(A*0.001)* 10.0**(B-20)") - field(PREC, "3") - field(EGU, "mBar") -} -record (longin, "$(P)$(R)P002:M") -{ - field (DESC, "getPressure002 $(bus)") - field (DTYP, "stream") - field (INP, "@pfeiffer.proto getPressure002($(P)$(R)P002:E) $(bus)") - field (SCAN, "I/O Intr") - field (FLNK, "$(P)$(R)P002") -} - -record (longin, "$(P)$(R)P002:E") -{ - field (DESC, "Pressure002 exponent $(bus)") -} -record (calc, "$(P)$(R)P002") -{ - field(INPA, "$(P)$(R)P002:M") - field(INPB, "$(P)$(R)P002:E") - field(CALC, "(A*0.001)*10.0**(B-20)") - field(PREC, "3") - field(EGU, "mBar") -} -record(stringout,"$(P)$(R)Debug") { - field(DESC, "") - field(DTYP, "stream") - field(OUT, "@pfeiffer.proto debug $(bus)") - field(VAL,"") -} - diff --git a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/Makefile b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/Makefile index 1ad52ee..8e1bc4a 100644 --- a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/Makefile +++ b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/Makefile @@ -8,7 +8,7 @@ DB += ISTTOKstates.db DB += ISTTOKvacummPumps.db DB += ISTTOKpcf8574.db DB += ISTTOKpcf8591.db -DB += ISTTOKrs485.db +DB += ISTTOKpfeiffer.db # If .db template is not named *.template add # _TEMPLATE = diff --git a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd index 7b81188..ee2cfb3 100755 --- a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd +++ b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd @@ -31,10 +31,26 @@ drvAsynI2CConfigure( "I2C", "/dev/i2c-1", 1 ) ## Load record instances dbLoadRecords("db/ISTTOKstates.db","P=ISTTOK:,R=central:") dbLoadRecords("db/ISTTOKpcf8574.db","P=ISTTOK:,R=central:") +dbLoadRecords("db/ISTTOKpcf8591.db","P=ISTTOK:,R=central:") #dbLoadRecords("db/ISTTOKpcf8574.db","P=ISTTOK:,R=central:,ID=57") dbLoadRecords("db/ISTTOKvacummPumps.db","P=ISTTOK:,R=central:") -dbLoadRecords("db/ISTTOKpcf8591.db","P=ISTTOK:,R=central:") +## Load Serial drivers +drvAsynSerialPortConfigure("RS0","/dev/ttyUSB0") + +asynSetOption("RS0", 0, "baud", "9600") +asynSetOption("RS0", 0, "bits", "8") +asynSetOption("RS0", 0, "parity", "none") +asynSetOption("RS0", 0, "stop", "1") +asynSetOption("RS0", 0, "clocal", "Y") +asynSetOption("RS0", 0, "crtscts", "N") + +dbLoadRecords("db/ISTTOKpfeiffer.db","P=ISTTOK:,R=central:,bus=RS0") + +# Uncomment to Debug STREAM serial activity +#var streamError 1 +#var streamDebug 1 +#streamSetLogfile("logfile.txt") ## Run this to trace the stages of iocInit #traceIocInit diff --git a/epics/iocs/ISTTOKrpi/protocols/pfeiffer.proto b/epics/iocs/ISTTOKrpi/protocols/pfeiffer.proto index 9a08d9e..5552412 100644 --- a/epics/iocs/ISTTOKrpi/protocols/pfeiffer.proto +++ b/epics/iocs/ISTTOKrpi/protocols/pfeiffer.proto @@ -1,17 +1,33 @@ Terminator=CR; MaxInput = 20; -ReadTimeout = 2000; -getPressure003 { - in "0031074006%4u%(\$1)2u%+"; + +#in millisecond +#ReadTimeout = 2000; +ReplyTimeout = 200; + +# Using redirection to read 2 records, mantissa and exponent +getPressure001 { + out "0010074002=?106"; + in "0011074006%4u%(\$1)2u%+"; } getPressure002 { - in "0021074006%4u%(\$1)2u%+"; + out "0020074002=?107"; + in "0021074006%4u%(\$1)2u%+"; } +getPressure003 { + out "0030074002=?108"; + in "0031074006%4u%(\$1)2u%+"; +} +getPressure004 { + out "0040074002=?109"; + in "0041074006%4u%(\$1)2u%+"; +} +# # in "0031074006%4u%(\$1)2u%*3u"; # -getPressureE003 { - in "0031074006%*4u%2u%*3u"; -} +#getPressureE003 { +# in "0031074006%*4u%2u%*3u"; +#} # Connect a stringout record to this to get # a generic command interface. @@ -20,6 +36,5 @@ getPressureE003 { debug { ExtraInput = Ignore; out "%s"; in "%39c" - }