From 8e534c636bc4bd358a6482ca38259f609e175153 Mon Sep 17 00:00:00 2001 From: Bernardo Carvalho Date: Mon, 14 Feb 2022 16:45:44 +0000 Subject: [PATCH] Inserted 3rd Relay Board and PVs --- epics/README.md | 9 +++- .../ISTTOKrpiApp/Db/ISTTOKmachineControl.db | 30 ++++++------ .../ISTTOKrpiApp/src/IsttokSeqExec.stt | 49 ++++++++++++++++--- .../iocISTTOKrpi/save/iocISTTOKrpi.sav | 2 +- .../ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd | 2 +- 5 files changed, 66 insertions(+), 26 deletions(-) diff --git a/epics/README.md b/epics/README.md index 39c6393..6fd7836 100644 --- a/epics/README.md +++ b/epics/README.md @@ -217,7 +217,6 @@ Process Variables in this IOC Server: | ISTTOK:central:TDA8444:32:DAC_CH3| longout | no | | ISTTOK:central:TDA8444:32:DAC_CH5| longout | no | | ISTTOK:central:TDA8444:32:DAC_CH6| longout | no | -| ISTTOK:central:Shot-TorPSCurrent| longout | no | ---------- * Connected to PCF8591 ADC / DAC register @ address 0x48=d72 @@ -259,6 +258,14 @@ SPDT Relay Address = 17 |ISTTOK:central:Buzzer| bo | 3 | Relay NO/NC| +* Connected to Seeeduino- 4-Channel SPDT Relay Address = 19 + +|PV Name | PV Type | Bit | Relay NO/NC| +|:----------|-------|---:| +| ISTTOK:central:Shot-TorPSDisable| 0 | NO | +| ISTTOK:central:Lab-WarningLight| 1 | NO | + + ### Vacuum Node (**Not used, backup server only**) - Vacuum Pfeiffer Sensors (RS485) diff --git a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKmachineControl.db b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKmachineControl.db index 2133001..9518345 100644 --- a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKmachineControl.db +++ b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/ISTTOKmachineControl.db @@ -443,13 +443,27 @@ record(bo, "$(P)$(R)Buzzer" ) { field(OSV,"MINOR") } +###################################### +# Tor Power Supply Disable # +# É desligado na emergência e em qualquer estado que +# não seja Process ou Wait Shot. +###################################### +record(bo, "$(P)$(R)Shot-TorPSDisable" ) { + field(DESC,"Tor Power Supply Disable") + ####field( OUT, "$(P)$(R)PCF8574:61:REGISTER.B1 PP" ) + field(OUT,"$(P)$(R)SEEED4RELAY:19:REGISTER.B0 PP") + field( ZNAM, "Enabled" ) + field( ONAM, "Disabled" ) + field(VAL,"0") + field(OSV,"MINOR") +} ############################## # LIGHTS ON/OFF # ############################## record(bo, "$(P)$(R)Lab-WarningLight" ) { field(DESC,"Luzes de sinalização, 220V ") # ####field(OUT, "$(P)$(R)PCF8574:60:REGISTER.B5 PP" ) - field(OUT,"$(P)$(R)SEEED4RELAY:19:REGISTER.B0 PP") + field(OUT,"$(P)$(R)SEEED4RELAY:19:REGISTER.B1 PP") field(ZNAM,"OFF") field(ONAM, "ON") field(VAL, "0") @@ -460,20 +474,6 @@ record(bo, "$(P)$(R)Lab-WarningLight" ) { # field(VAL,"1") #} -###################################### -# Tor Power Supply Disable # -# É desligado na emergência e em qualquer estado que -# não seja Process ou Wait Shot. -###################################### -record(bo, "$(P)$(R)Shot-TorPSDisable" ) { - field(DESC,"Tor Power Supply Disable") - ####field( OUT, "$(P)$(R)PCF8574:61:REGISTER.B1 PP" ) - field(OUT,"$(P)$(R)SEEED4RELAY:19:REGISTER.B1 PP") - field( ZNAM, "Enabled" ) - field( ONAM, "Disabled" ) - field(VAL,"0") - field(OSV,"MINOR") -} # field( ZNAM, "Off" ) # field( ONAM, "On" ) # field(VAL,"1") diff --git a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/src/IsttokSeqExec.stt b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/src/IsttokSeqExec.stt index 1a35789..e306914 100644 --- a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/src/IsttokSeqExec.stt +++ b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/src/IsttokSeqExec.stt @@ -18,10 +18,18 @@ **/ //%% #include "errlog.h" -program IsttokSeqExec +program IsttokSeqExec ("output=logFile.txt") %{#include "errlog.h"}% +%%#include /* for exit() */ +%%#include /* for exit() */ +%%#include /* for exit() */ /* CONSTANT DECLARATION*/ -/*Relays and INPUT (Valleman Board) have negative Logic!*/ +/*Relays and INPUT PVs on Valleman Board have negative Logic!*/ +/*=================== declarations =========================*/ + +int fd; /* file descriptor for logging */ +char *pmac; /* used to access program macros */ + short PCF_RELAY_ON = 0; short PCF_RELAY_OFF= 1; short PCF_INPUT_ON = 0; @@ -142,12 +150,13 @@ assign IsttokRPump2_Motor to "ISTTOK:central:RPump2-Motor"; short IsttokRPump2_Valve; assign IsttokRPump2_Valve to "ISTTOK:central:RPump2-Valve"; - +/* No use for these, Controller does not respond short IsttokTMPump1_ControllerOff; assign IsttokTMPump1_ControllerOff to "ISTTOK:central:TMPump1-ControllerOff"; short IsttokTMPump1_ControllerOn; assign IsttokTMPump1_ControllerOn to "ISTTOK:central:TMPump1-ControllerOn"; +*/ short IsttokTMPump1_MotorOff; assign IsttokTMPump1_MotorOff to "ISTTOK:central:TMPump1-MotorOff"; @@ -277,6 +286,23 @@ ss PulseSequence { /*********** State: init ****************** */ state init { entry { + fd = -1; + /* Use parameter to define logging file */ + + pmac = macValueGet("output"); + if (pmac == 0 || pmac[0] == 0) { + printf("No macro defined for \"output\"\n"); + fd = 1; + } + else { + fd = open(pmac, (O_CREAT | O_WRONLY), 0664); +/* if (fd == ERROR) { */ + if (fd == -1) { + printf("Can't open %s\n", pmac); + exit (-1); + } + } + dprintf(fd, "Starting program\n"); strcpy(msg, "INIT: Sequence Entry"); pvPut(msg); errlogSevPrintf(NO_ALARM, "%s\n",msg); @@ -326,13 +352,13 @@ ss PulseSequence { Isttok_TorPSTrigger= OFF; pvPut(Isttok_TorPSTrigger); - +/* IsttokTMPump1_ControllerOff = OFF; pvPut(IsttokTMPump1_ControllerOff); IsttokTMPump1_ControllerOn = OFF; pvPut(IsttokTMPump1_ControllerOn); - +*/ IsttokTMPump1_MotorOff = OFF; pvPut(IsttokTMPump1_MotorOff); @@ -457,7 +483,6 @@ ss PulseSequence { } state Emergency when ( (pvStatus(IsttokRPump1_Pressure) != pvStatOK) || (pvStatus(IsttokTMPump1_Emergency) != pvStatOK) ) { - //when ( pvStatus(IsttokRPump1_Pressure) != pvStatOK || pvStatus(IsttokRPump2_Pressure) != pvStatOK || // pvStatus(IsttokTMPump1_Emergency) != pvStatOK || pvStatus(IsttokTMPump2_Emergency) != pvStatOK) { /* Vacuum emergency: Pulse state change to Stopping */ /*IsttokOPREQ = STOP; State should recover from */ @@ -466,8 +491,8 @@ ss PulseSequence { strcpy(msg, "State Idle to Stopping"); pvPut(msg); errlogSevPrintf(MINOR, "%s\n", msg); - sprintf(sendMail, "Rpump1 Pressure:%1.1e TMP1 Emergency:%d TMP1 Adm. Pressure:%4.2e", - IsttokRPump1_Pressure, IsttokTMPump1_Emergency, IsttokTMPump1_Pressure); + sprintf(sendMail, "Vacuum Emergency while Idle, Rpump1 Pressure:%1.1e, TMP1 Adm. Pressure:%4.2e, TMP1 Emergency:%d", + IsttokRPump1_Pressure, IsttokTMPump1_Pressure, IsttokTMPump1_Emergency); pvPut(sendMail); } state Stopping @@ -1394,6 +1419,14 @@ ss StoppingSequence { when (IsttokOPSTATE != POS_Stopping ) { } state NonStopping } } +/* Exit procedure - close the log file +exit { + printf("close fd=%d\n", fd); + if ((fd > 0) && (fd != ioGlobalStdGet(1)) ) + close(fd); + fd = -1; +} +*/ /**** END PROGRAM ***/ diff --git a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav index a8b23c7..da711ab 100644 --- a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav +++ b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav @@ -1,4 +1,4 @@ -# autosave R5.3 Automatically generated - DO NOT MODIFY - 220204-153705 +# autosave R5.3 Automatically generated - DO NOT MODIFY - 220214-164146 ISTTOK:central:PULSE-NUMBER.VAL 49468 ISTTOK:central:LogMessage.VAL ISTTOK:central:LASTOPSTATE.VAL 2 diff --git a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd index e12e627..096618f 100755 --- a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd +++ b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/st.cmd @@ -83,4 +83,4 @@ asInit create_monitor_set("$(IOC).req", 30, "P=ISTTOK:,R=central:") ## Start any sequence programs , use safe mode -seq IsttokSeqExec "unit=ISTTOK" +seq IsttokSeqExec "unit=ISTTOK,node=central,output=logFile2"