From 4bfb5ea148b42f8b8df03a09e9c3f0870bad69e7 Mon Sep 17 00:00:00 2001 From: bernardo carvalho Date: Fri, 25 Sep 2020 19:17:29 +0100 Subject: [PATCH] added RPi2 IOC --- epics/README.md | 49 ++++++-- .../ISTTOKrpi2App/Db/ISTTOKpfeiffer.db | 115 ++++++++++++++++++ .../iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/Makefile | 19 +++ .../ISTTOKrpi2App/Db/pfeiffer.proto | 40 ++++++ .../ISTTOKrpi2/ISTTOKrpi2App/src/Makefile | 46 +++++++ .../ISTTOKrpi2/iocBoot/iocISTTOKrpi2/st.cmd | 34 ++++++ epics/iocs/RELEASE.local | 19 +++ 7 files changed, 309 insertions(+), 13 deletions(-) create mode 100644 epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/ISTTOKpfeiffer.db create mode 100644 epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/Makefile create mode 100644 epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/pfeiffer.proto create mode 100644 epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/src/Makefile create mode 100755 epics/iocs/ISTTOKrpi2/iocBoot/iocISTTOKrpi2/st.cmd create mode 100644 epics/iocs/RELEASE.local diff --git a/epics/README.md b/epics/README.md index 86d6b73..d17d03f 100644 --- a/epics/README.md +++ b/epics/README.md @@ -17,12 +17,12 @@ All software stored in IPFN GIT [server](https://git.ipfn.tecnico.ulisboa.pt/sum - **Humberto Figueiredo** (ISTTOK Session Leader) - **Hugo Alves** (ISTTOK Session Leader, State Machine development) - **Tiago Pereira** (dsPIC development, RS232 protocol/ Sensor Interface/ Wiring) -- **Paulo F. Carvalho** ( Epics Applications), CS-S Gui Panels) ## System description -Presently there are two instances of EPICS IOC Server implemented. +Presently there are two/three instances of EPICS IOC Server implemented. One responsible for the Temperature Node. And a second one, installed in a Raspberry Pi, implemented in the new control unit launched at ISTTOK for the remote control of the vacuum pumps, named Central Node. +A third one is dedicated for readind the Vacuum Sensore through the RS484 Interface ### Temperature/Vacuum Node: Temperature Sensors and ELCO Voltage Measurement Systems - Thermocouple Sensor @@ -227,22 +227,45 @@ Process Variables in this IOC Server: | ISTTOK:central:Shot-TorPSCurrentImage"| ai | ch3 | no | ---------- +* Connected to RS485 Bus (Not yet) + +|PV Name |PV Type |Archive| +|:----------|-------|---:| +|ISTTOK:central:RPump1-Pressure | ai | yes | +|ISTTOK:central:RPump2-Pressure | ai | yes | +|ISTTOK:central:TMPump1-PressureAdmission | ai | yes | +|ISTTOK:central:VVessel-Pressure | ai | yes | +---------- + + +### Central Control/Vacuum Node +- Vacuum Pfeiffer Sensors (RS485) + +#### Hardware Platform +1. A Raspberry Pi 3, running a linux distribution.. + * Has a USB/RS485 port for monitoring pressure + +#### Process Variables +Process Variables in this IOC Server: + * Connected to RS485 Bus |PV Name |PV Type |Archive| |:----------|-------|---:| -| ISTTOK:central:RPump1-Pressure | ai | yes | -|ISTTOK:central:RPump2-Pressure | ai | yes | -|ISTTOK:central:TMPump1-PressureAdmission | ai | yes | -ISTTOK:central:VVessel-Pressure | ai | yes +| ISTTOK:vacuum:RPump1-Pressure | ai | yes | +|ISTTOK:vacuum:RPump2-Pressure | ai | yes | +|ISTTOK:vacuum:TMPump1-PressureAdmission | ai | yes | +|ISTTOK:vacuum:VVessel-Pressure | ai | yes | +---------- +#### Software Platform +[//]: # (This may be the most platform independent comment) -##### Start the IOC on power up - 1. Make sure `screen` is installed in Linux - 2. Include following Line in /etc/rc.local - * `screen -dm bash -c "cd [..]/ISTTOKrpi/iocBoot/iocISTTOKrpi; ../../bin/linux-arm/ISTTOKrpi st.cmd"` - 3. To access EPICS console run - * `sudo screen -r` +1. Linux Raspian "buster" (user :pi): + * IP addr: 192.168.1.120 ( ISTTOK private network) + * NTP/timedatectl time conected to IPFN Gps NTP/PPS server IP:10.136.227.237 193.136.136.129 + (this is mandatory, Rpi does not have a Real Time clock see https://www.raspberrypi.org/forums/viewtopic.php?t=178763) + * EPICS 7. To install follow [EPICS Docs](https://docs.epics-controls.org/projects/how-tos/en/latest/getting-started/installation.html) ## Download and configure CS-Studio @@ -266,7 +289,7 @@ ISTTOK:central:VVessel-Pressure | ai | yes ### EPICS Channel Access Configuration ``` -export EPICS_CA_ADDR_LIST="192.168.1.110 192.168.1.152" +export EPICS_CA_ADDR_LIST=""192.168.1.110 192.168.1.120 192.168.1.152" export EPICS_CA_AUTO_ADDR_LIST="NO" ``` diff --git a/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/ISTTOKpfeiffer.db b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/ISTTOKpfeiffer.db new file mode 100644 index 0000000..577e88b --- /dev/null +++ b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/ISTTOKpfeiffer.db @@ -0,0 +1,115 @@ +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)VVessel-Pressure") +} +record (longin, "$(P)$(R)P001:E") +{ + field (DESC, "Pressure001 exponent $(bus)") +} +record (calc, "$(P)$(R)VVessel-Pressure") +{ + field (DESC, "ISTTOK:central:VVessel-Pressure") + 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)RPump1-Pressure") +} +record (longin, "$(P)$(R)P002:E") +{ + field (DESC, "Pressure002 exponent $(bus)") +} +record (calc, "$(P)$(R)RPump1-Pressure") +{ + field (DESC, "ISTTOK:central:RPump1-Pressure") + 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") +# field(HIHI,"1.0e-1") +# field(HIGH,"5.0e-3") +# field(LOW, "20.0") +# field(LOLO,"0.0") + field(HHSV,"MAJOR") + field(HSV, "MINOR") +# field(LSV, "MINOR") +# field(LLSV,"MAJOR") +} + +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)TMPump1-PressureAdmission") +} + +record (longin, "$(P)$(R)P003:E") +{ + field (DESC, "Pressure003 Exponent $(bus)") +} +record (calc, "$(P)$(R)TMPump1-PressureAdmission") +{ + field(DESC, "ISTTOK:central:TMPump1-PressureAdmission") + 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)RPump2-Pressure") +} +record (longin, "$(P)$(R)P004:E") +{ + field (DESC, "Pressure004 Exponent $(bus)") +} + +record (calc, "$(P)$(R)RPump2-Pressure") +{ + field(DESC, "ISTTOK:central:RPump2-Pressure") + 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") +# field(HIHI,"1.0e-1") +# field(HIGH,"5.0e-3") +# field(LOW, "20.0") +# field(LOLO,"0.0") + field(HHSV,"MAJOR") + field(HSV, "MINOR") +# field(LSV, "MINOR") +# field(LLSV,"MAJOR") +} + +record(stringout,"$(P)$(R)RS485Debug") { + field(DESC, "") + field(DTYP, "stream") + field(OUT, "@pfeiffer.proto debug $(bus)") + field(VAL,"") +} + diff --git a/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/Makefile b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/Makefile new file mode 100644 index 0000000..af95e8b --- /dev/null +++ b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/Makefile @@ -0,0 +1,19 @@ +TOP=../.. +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE + +#---------------------------------------------------- +# Create and install (or just install) into /db +# databases, templates, substitutions like this +DB += ISTTOKpfeiffer.db +DB += pfeiffer.proto + +#---------------------------------------------------- +# If .db template is not named *.template add +# _template = + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/pfeiffer.proto b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/pfeiffer.proto new file mode 100644 index 0000000..527ef03 --- /dev/null +++ b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/Db/pfeiffer.proto @@ -0,0 +1,40 @@ +Terminator=CR; +MaxInput = 20; + +# in millisecond +#ReadTimeout = 2000; +ReplyTimeout = 250; + +# Using redirection to read 2 records, mantissa and exponent +getPressure001 { + out "0010074002=?106"; + in "0011074006%4u%(\$1)2u%+"; +} +getPressure002 { + 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"; +#} + +# Connect a stringout record to this to get +# a generic command interface. +# After processing finishes, the record contains the reply. + +debug { + ExtraInput = Ignore; + out "%s"; in "%39c" +} + diff --git a/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/src/Makefile b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/src/Makefile new file mode 100644 index 0000000..13b302e --- /dev/null +++ b/epics/iocs/ISTTOKrpi2/ISTTOKrpi2App/src/Makefile @@ -0,0 +1,46 @@ +TOP=../.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +#============================= +# Build the IOC application + +PROD_IOC = ISTTOKrpi2 +# ISTTOKrpi2.dbd will be created and installed +DBD += ISTTOKrpi2.dbd + +# ISTTOKrpi2.dbd will be made up from these files: +ISTTOKrpi2_DBD += base.dbd + +# Include dbd files from all support applications: +#ISTTOKrpi2_DBD += xxx.dbd +ISTTOKrpi2_DBD += asyn.dbd +ISTTOKrpi2_DBD += stream.dbd +ISTTOKrpi2_DBD += drvAsynSerialPort.dbd + +# Add all the support libraries needed by this IOC +ISTTOKrpi2_LIBS += asyn +ISTTOKrpi2_LIBS += stream + +# ISTTOKrpi2_registerRecordDeviceDriver.cpp derives from ISTTOKrpi2.dbd +ISTTOKrpi2_SRCS += ISTTOKrpi2_registerRecordDeviceDriver.cpp + +# Build the main IOC entry point on workstation OSs. +ISTTOKrpi2_SRCS_DEFAULT += ISTTOKrpi2Main.cpp +ISTTOKrpi2_SRCS_vxWorks += -nil- + +# Add support from base/src/vxWorks if needed +#ISTTOKrpi2_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary + +# Finally link to the EPICS Base libraries +ISTTOKrpi2_LIBS += $(EPICS_BASE_IOC_LIBS) + +#=========================== + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/epics/iocs/ISTTOKrpi2/iocBoot/iocISTTOKrpi2/st.cmd b/epics/iocs/ISTTOKrpi2/iocBoot/iocISTTOKrpi2/st.cmd new file mode 100755 index 0000000..c553ca0 --- /dev/null +++ b/epics/iocs/ISTTOKrpi2/iocBoot/iocISTTOKrpi2/st.cmd @@ -0,0 +1,34 @@ +#!../../bin/linux-arm/ISTTOKrpi2 + +#- You may have to change ISTTOKrpi2 to something else +#- everywhere it appears in this file + +< envPaths +epicsEnvSet( "STREAM_PROTOCOL_PATH", "$(TOP)/db" ) + +cd "${TOP}" + +## Register all support components +dbLoadDatabase "dbd/ISTTOKrpi2.dbd" +ISTTOKrpi2_registerRecordDeviceDriver pdbbase + +## Load record instances +#dbLoadRecords("db/xxx.db","user=pi") +## Load Serial drivers +drvAsynSerialPortConfigure("RS0","/dev/ttyUSB0") +#drvAsynSerialPortConfigure("RS0","/dev/ttyAMA0") + +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=vacuum:,bus=RS0") + +cd "${TOP}/iocBoot/${IOC}" +iocInit + +## Start any sequence programs +#seq sncxxx,"user=pi" diff --git a/epics/iocs/RELEASE.local b/epics/iocs/RELEASE.local new file mode 100644 index 0000000..b8d208f --- /dev/null +++ b/epics/iocs/RELEASE.local @@ -0,0 +1,19 @@ +#RELEASE Location of external products +HOME=/home/pi +SUPPORT=$(HOME)/Apps/epics7/support +# +# +ASYN=$(SUPPORT)/asyn +STREAM=$(SUPPORT)/StreamDevice +# IPAC release V2-7 or later is required. +IPAC= +#$(SUPPORT)/ipac-2-15 +# +# # SEQ is required for testIPServer +SNCSEQ= +#$(SUPPORT)/seq-2-2-5 +# +CALC= +PCRE= +# +EPICS_BASE=$(HOME)/Apps/epics7/epics-base