Skip to content

Commit

Permalink
PID tuning, continued
Browse files Browse the repository at this point in the history
  • Loading branch information
schwabix-1311 committed Jan 27, 2025
1 parent 8a39b01 commit 2b8c250
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
3 changes: 3 additions & 0 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ aquaPi ToDo list
# startup behaviour of bus isn't good - let everybody post its data as response to HELLO?
# on Raspi driver TC420 finds a device although there's none

- Logging to systemd journal? see https://trstringer.com/systemd-logging-in-python/
This article also covers systemctl services

- Navigation:
/ Home, a configurable dashboard
/settings Controllers, with foldable groups containing Controllers & their in/out
Expand Down
29 changes: 19 additions & 10 deletions aquaPi/machineroom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def create_default_nodes(self) -> None:
COMPLEX_TEMP = SIM_TEMP and False

if REAL_CONFIG:
# __Lighting__ #
# single PWM dimmed LED bar, perceptive correction
light_schedule = ScheduleInput('Zeitplan Licht', '* 14-21 * * *')

Expand All @@ -121,7 +122,7 @@ def create_default_nodes(self) -> None:
light_c = SunCtrl('Leuchtbalken', light_schedule.id, xscend=1.0)

light_pwm = AnalogDevice('Dimmer', light_c.id,
'PWM 0', percept=True, maximum=85)
'PWM 0', percept=True, maximum=75)
light_schedule.plugin(self.bus)
light_c.plugin(self.bus)
light_pwm.plugin(self.bus)
Expand All @@ -131,22 +132,29 @@ def create_default_nodes(self) -> None:
[light_schedule.id, light_c.id]) # , light_pwm.id])
history.plugin(self.bus)

# single water temp sensor, switched relay
wasser_i = AnalogInput('Wasser', 'DS1820 xA2E9C', 25.0, '°C',
avg=1, interval=180)
# __Temperatures__ #
# single water temp sensor
# 2-point switched relay or triac ...
#wasser_i = AnalogInput('Wasser', 'DS1820 xA2E9C', 25.0, '°C',
# avg=1, interval=60)
#wasser = MinimumCtrl('Temperatur', wasser_i.id, 25.0)
#wasser_o = SwitchDevice('Heizstab', wasser.id,
# 'GPIO 12 out', inverted=True)
# 'GPIO 12 out', inverted=False)

# ... or PID driven triac (relay has increased wear, not recomm.)
# PID for my 60cm/100W: sensor cycle 300s, PID 1.0/0.05/5, PWM 10s
wasser_i = AnalogInput('Wasser', 'DS1820 xA2E9C', 25.0, '°C',
avg=1, interval=300)
wasser = PidCtrl('PID Temperatur', wasser_i.id, 25.0,
p_fact=1.5, i_fact=0.1, d_fact=0.)
p_fact=1.0, i_fact=0.05, d_fact=5.0)
wasser_o = SlowPwmDevice('Heizstab', wasser.id,
'GPIO 12 out', inverted=True, cycle=90)
'GPIO 12 out', inverted=False, cycle=10)
wasser_i.plugin(self.bus)
wasser.plugin(self.bus)
wasser_o.plugin(self.bus)

# air temperature, just for the diagram
wasser_i2 = AnalogInput('Wasser 2', 'DS1820 x7A71E', 25.0, '°C',
wasser_i2 = AnalogInput('Raumluft', 'DS1820 x7A71E', 25.0, '°C',
avg=2, interval=60)
wasser_i2.plugin(self.bus)

Expand All @@ -165,14 +173,15 @@ def create_default_nodes(self) -> None:
coolspeed.id]) # , cool.id])
t_history.plugin(self.bus)

# __CO2__ #
adc_ph = AnalogInput('pH Sonde', 'ADC #1 in 3', 2.49, 'V',
avg=3, interval=30)
calib_ph = ScaleAux('pH Wert', adc_ph.id, 'pH',
limit=(4.0, 10.0),
points=[(2.99, 4.0), (2.51, 6.9)])
ph = MaximumCtrl('pH Steuerung', calib_ph.id, 6.7)

ph_broken = True
ph_broken = False # True
if ph_broken:
# WAR broken CO2 vent:
# pulse it, as CO2 only flows when partially opened
Expand Down Expand Up @@ -257,7 +266,7 @@ def create_default_nodes(self) -> None:
wasser = PidCtrl('Temperaturregler', wasser_i.id, 25.0,
p_fact=1.5, i_fact=0.1, d_fact=0.)
wasser_o = SlowPwmDevice('Heizstab', wasser.id,
'GPIO 12 out', inverted=True, cycle=20)
'GPIO 12 out', inverted=False, cycle=20)
wasser.plugin(self.bus)
wasser_o.plugin(self.bus)
wasser_i.plugin(self.bus)
Expand Down
1 change: 1 addition & 0 deletions aquaPi/machineroom/ctrl_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def listen(self, msg) -> bool:
log.brief('PID -> %f (%+.1f)', self.data, -val * 100)
self.post(MsgData(self.id, round(self.data, 4)))

#FIXME: test a permanent err_sum leak of 1% or 10% , avoid windup
if self.data <= 0. or self.data >= 100.:
self._err_sum /= 2
self._err_old = err
Expand Down
6 changes: 3 additions & 3 deletions aquaPi/machineroom/out_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ def set(self, perc: float) -> None:
def get_settings(self) -> list[tuple]:
settings = super().get_settings()
settings.append(('cycle', 'PWM cycle time', self.cycle,
'type="number" min="10" max="300" step="1"',
'inverted', 'Inverted', self.inverted,
'type="number" min="0" max="1"'))
'type="number" min="10" max="300" step="1"'))
settings.append(('inverted', 'Inverted', self.inverted,
'type="number" min="0" max="1"')) # FIXME 'class="uk-checkbox" type="checkbox" checked' fixes appearance, but result is always False )
return settings


Expand Down

0 comments on commit 2b8c250

Please sign in to comment.