A learning project for developing a simulated refrigerator control system using EPICS.
The project was originally started during EPICS training and is now being extended into an interactive control-system simulation.
Status: Work in progress.
The temperature-control/thermostat logic is currently implemented. Automatic temperature dynamics, door control, lighting, alarms, and the final Phoebus GUI are still to be added.
The refrigerator is currently implemented using a ready-made EPICS softIocPVA and an EPICS database.
fridge.db
|
v
st.cmd
|
v
softIocPVA
|
v
EPICS PVs
No external hardware or StreamDevice support is required because the refrigerator is currently simulated entirely within the EPICS environment.
fridge-control/
├── .gitignore
├── README.md
├── fridge.db
└── st.cmd
The database uses the macro:
$(P)
rather than hard-coding FRIDGE: into every record.
The startup file loads the database with:
P=FRIDGE:
For example:
$(P)TEMP:ACTUAL
becomes:
FRIDGE:TEMP:ACTUAL
This allows the same database structure to be reused later with different equipment prefixes.
The current implementation contains:
FRIDGE:TEMP:ACTUAL
FRIDGE:TEMP:SET
FRIDGE:TEMP:HYST
FRIDGE:TEMP:WARM
FRIDGE:TEMP:COLD
FRIDGE:THERMOSTAT
FRIDGE:PUMP
Represents the current fridge temperature.
It is implemented as an analog input (ai) because it represents temperature information coming into the control system.
At the current development stage, the value is manually changed using pvput to simulate different fridge temperatures.
Automatic temperature dynamics will be added later.
Represents the desired fridge temperature selected by the operator.
It is implemented as an analog output (ao).
The current configuration uses:
Minimum setpoint: 1 degC
Maximum setpoint: 8 degC
Default setpoint: 4 degC
Defines the thermostat hysteresis/deadband.
The default value is:
1 degC
The operator can adjust this value.
For example:
TEMP:SET = 4 degC
TEMP:HYST = 1 degC
produces:
Upper threshold = 5 degC
Lower threshold = 3 degC
A calc record that determines whether the actual temperature is above the upper thermostat threshold.
The calculation is:
ACTUAL > SET + HYST
The result is:
1 = temperature above upper threshold
0 = otherwise
The record uses CP (Process on Change) links so that changes to the actual temperature, setpoint, or hysteresis automatically cause the calculation to be processed.
A calc record that determines whether the actual temperature is below the lower thermostat threshold.
The calculation is:
ACTUAL < SET - HYST
The result is:
1 = temperature below lower threshold
0 = otherwise
This record also uses CP links for automatic processing.
A calcout record implementing the thermostat state logic.
It reads:
TEMP:WARM
TEMP:COLD
current PUMP state
and evaluates:
A ? 1 : (B ? 0 : C)
where:
A = TEMP:WARM
B = TEMP:COLD
C = current PUMP state
This means:
WARM = 1
-> Pump ON
COLD = 1
-> Pump OFF
WARM = 0 and COLD = 0
-> Keep previous pump state
The calculated result is sent to:
FRIDGE:PUMP
using the OUT link of the calcout record.
Represents the simulated cooling pump.
It is implemented as a binary output (bo):
0 = OFF
1 = ON
The pump is now controlled automatically by FRIDGE:THERMOSTAT.
The thermostat deliberately uses two different switching thresholds.
For example:
SET = 4 degC
HYST = 1 degC
gives:
ACTUAL > 5 degC
-> Pump turns ON
3 degC <= ACTUAL <= 5 degC
-> Pump keeps its previous state
ACTUAL < 3 degC
-> Pump turns OFF
This prevents rapid ON/OFF switching around the temperature setpoint.
Example cooling cycle:
Actual temperature = 6.0
|
v
WARM = 1
|
v
PUMP ON
|
v
temperature falls
Actual temperature = 4.0
|
v
WARM = 0
COLD = 0
|
v
PUMP remains ON
Actual temperature = 2.8
|
v
COLD = 1
|
v
PUMP OFF
TEMP:ACTUAL
|
+---------+---------+
| |
v v
TEMP:WARM TEMP:COLD
ACTUAL > SET+HYST ACTUAL < SET-HYST
| |
+---------+---------+
|
v
THERMOSTAT
A ? 1 : (B ? 0 : C)
|
| OUT
v
PUMP
CP links cause the temperature calculations to process automatically when their input values change.
The thermostat uses the current pump state inside the hysteresis band so that the pump retains its previous state.
Activate the Mamba EPICS environment:
mamba activate epicsGo to the project directory:
cd ~/fridge-controlStart the IOC:
softIocPVA st.cmdThe IOC shell should appear:
epics>
List the loaded records with:
dbl
Open another terminal and activate the EPICS environment:
mamba activate epicsCheck the main settings:
pvget FRIDGE:TEMP:ACTUAL
pvget FRIDGE:TEMP:SET
pvget FRIDGE:TEMP:HYST
pvget FRIDGE:PUMPFor the current development stage, the actual temperature can be changed manually to simulate the fridge becoming warmer or colder:
pvput FRIDGE:TEMP:ACTUAL 6With a setpoint of 4 degC and hysteresis of 1 degC, the pump should turn ON.
Move the temperature into the hysteresis band:
pvput FRIDGE:TEMP:ACTUAL 4The pump should remain ON.
Then simulate a sufficiently cold fridge:
pvput FRIDGE:TEMP:ACTUAL 2The pump should turn OFF.
The control state can be inspected using:
pvget FRIDGE:TEMP:WARM
pvget FRIDGE:TEMP:COLD
pvget FRIDGE:THERMOSTAT
pvget FRIDGE:PUMPThe project currently demonstrates:
- EPICS database records
- Reusable PV prefixes using macros
- Analog input (
ai) - Analog output (
ao) - Binary output (
bo) calcrecordscalcoutrecords- Record links
CP(Process on Change)- Automatic record processing
- Configurable hysteresis
- Stateful thermostat control
- Soft IOC operation
- PV Access clients (
pvget,pvput,pvmonitor)
The project is not complete.
Next steps include:
- Simulate automatic temperature evolution
- Make the pump gradually cool the fridge
- Simulate temperature rise when cooling is off
- Add a door sensor
- Add automatic interior-light control
- Add door-open timing/alarm logic
- Add high-temperature alarms
- Test the complete closed-loop simulation
- Build a Phoebus Display Builder GUI
- Add live temperature/status visualization
- Add temperature plotting/trending
Basic communication between Phoebus on Windows and the EPICS IOC running in WSL has already been tested successfully.
A Phoebus Text Update widget was able to read an EPICS PV from the WSL IOC and update automatically when the PV changed.
The complete fridge operator interface will be developed after the IOC/control logic is finished.
Work in progress — automatic thermostat checkpoint.
The project currently contains a working configurable thermostat with hysteresis. The next major step is to simulate the physical temperature response of the fridge so that the system becomes a complete closed-loop simulation.