return data
This commit is contained in:
parent
ad63eb12c4
commit
e781905912
3 changed files with 13 additions and 5 deletions
|
@ -72,6 +72,7 @@ def set_output(value: float):
|
||||||
|
|
||||||
#control RPM
|
#control RPM
|
||||||
def rpm_control():
|
def rpm_control():
|
||||||
|
print("control_RPM")
|
||||||
actual_rpm = float(get_variable(variable_actual_rpm))
|
actual_rpm = float(get_variable(variable_actual_rpm))
|
||||||
requested_rpm = float(get_variable(variable_requested_rpm))
|
requested_rpm = float(get_variable(variable_requested_rpm))
|
||||||
actual_set_U = read_0_10_out(stack=int(get_variable(variable_control_stack)), channel=int(get_variable(variable_control_channel)))
|
actual_set_U = read_0_10_out(stack=int(get_variable(variable_control_stack)), channel=int(get_variable(variable_control_channel)))
|
||||||
|
@ -79,10 +80,12 @@ def rpm_control():
|
||||||
#slow down rotating if over maximum
|
#slow down rotating if over maximum
|
||||||
if actual_rpm > float(get_variable(variable_max_rpm)):
|
if actual_rpm > float(get_variable(variable_max_rpm)):
|
||||||
set_output(actual_set_U - 1)
|
set_output(actual_set_U - 1)
|
||||||
|
print("max_rpm_reached")
|
||||||
return
|
return
|
||||||
|
|
||||||
if requested_rpm == 0:
|
if requested_rpm == 0:
|
||||||
set_output(0)
|
set_output(0)
|
||||||
|
print("control_set: 0")
|
||||||
return
|
return
|
||||||
|
|
||||||
#algorithm for RPM control
|
#algorithm for RPM control
|
||||||
|
@ -91,6 +94,7 @@ def rpm_control():
|
||||||
set_output(actual_set_U - float(get_variable(variable_control_step_U)))
|
set_output(actual_set_U - float(get_variable(variable_control_step_U)))
|
||||||
elif requested_rpm > actual_rpm:
|
elif requested_rpm > actual_rpm:
|
||||||
set_output(actual_set_U + float(get_variable(variable_control_step_U)))
|
set_output(actual_set_U + float(get_variable(variable_control_step_U)))
|
||||||
|
print("control_1")
|
||||||
return
|
return
|
||||||
|
|
||||||
if (requested_rpm - float(get_variable(variable_control_step_rpm_1))) < actual_rpm or actual_rpm < (requested_rpm + float(get_variable(variable_control_step_rpm_1))):
|
if (requested_rpm - float(get_variable(variable_control_step_rpm_1))) < actual_rpm or actual_rpm < (requested_rpm + float(get_variable(variable_control_step_rpm_1))):
|
||||||
|
@ -98,6 +102,7 @@ def rpm_control():
|
||||||
set_output(actual_set_U - float(get_variable(variable_control_step_U_1)))
|
set_output(actual_set_U - float(get_variable(variable_control_step_U_1)))
|
||||||
elif requested_rpm > actual_rpm:
|
elif requested_rpm > actual_rpm:
|
||||||
set_output(actual_set_U + float(get_variable(variable_control_step_U_1)))
|
set_output(actual_set_U + float(get_variable(variable_control_step_U_1)))
|
||||||
|
print("control_2")
|
||||||
return
|
return
|
||||||
|
|
||||||
if (requested_rpm - float(get_variable(variable_control_step_rpm_2))) < actual_rpm or actual_rpm < (requested_rpm + float(get_variable(variable_control_step_rpm_2))):
|
if (requested_rpm - float(get_variable(variable_control_step_rpm_2))) < actual_rpm or actual_rpm < (requested_rpm + float(get_variable(variable_control_step_rpm_2))):
|
||||||
|
@ -105,6 +110,7 @@ def rpm_control():
|
||||||
set_output(actual_set_U - float(get_variable(variable_control_step_U_2)))
|
set_output(actual_set_U - float(get_variable(variable_control_step_U_2)))
|
||||||
elif requested_rpm > actual_rpm:
|
elif requested_rpm > actual_rpm:
|
||||||
set_output(actual_set_U + float(get_variable(variable_control_step_U_2)))
|
set_output(actual_set_U + float(get_variable(variable_control_step_U_2)))
|
||||||
|
print("control_3")
|
||||||
return
|
return
|
||||||
|
|
||||||
if (requested_rpm - float(get_variable(variable_control_step_rpm_3))) < actual_rpm or actual_rpm < (requested_rpm + float(get_variable(variable_control_step_rpm_3))):
|
if (requested_rpm - float(get_variable(variable_control_step_rpm_3))) < actual_rpm or actual_rpm < (requested_rpm + float(get_variable(variable_control_step_rpm_3))):
|
||||||
|
@ -112,6 +118,7 @@ def rpm_control():
|
||||||
set_output(actual_set_U - float(get_variable(variable_control_step_U_3)))
|
set_output(actual_set_U - float(get_variable(variable_control_step_U_3)))
|
||||||
elif requested_rpm > actual_rpm:
|
elif requested_rpm > actual_rpm:
|
||||||
set_output(actual_set_U + float(get_variable(variable_control_step_U_3)))
|
set_output(actual_set_U + float(get_variable(variable_control_step_U_3)))
|
||||||
|
print("control_4")
|
||||||
return
|
return
|
||||||
|
|
||||||
print("empty_run")
|
print("empty_run")
|
||||||
|
|
|
@ -2,7 +2,7 @@ from src.variables.service import get_variable, set_variable
|
||||||
from gpiozero import Button
|
from gpiozero import Button
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from scripts.speed_controller import rpm_control
|
#from scripts.speed_controller import rpm_control
|
||||||
|
|
||||||
pulses_per_rotation = 4
|
pulses_per_rotation = 4
|
||||||
reader = Button(4, pull_up=False, bounce_time=0.0005)
|
reader = Button(4, pull_up=False, bounce_time=0.0005)
|
||||||
|
@ -22,10 +22,11 @@ def event():
|
||||||
set_variable("actual_rpm_unfiltered", rpm, False)
|
set_variable("actual_rpm_unfiltered", rpm, False)
|
||||||
|
|
||||||
set_variable("actual_rpm", round(actual_rpm, 1), False)
|
set_variable("actual_rpm", round(actual_rpm, 1), False)
|
||||||
rpm_control()
|
print(round(actual_rpm, 1))
|
||||||
|
# rpm_control()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reader.when_pressed = event
|
reader.when_pressed = event
|
||||||
|
|
|
@ -11,8 +11,8 @@ if bool(os.getenv("BACKGROUND_SCRIPTS_RUN", 0)):
|
||||||
|
|
||||||
|
|
||||||
#control speed
|
#control speed
|
||||||
#from scripts.speed_controller import rpm_control
|
from scripts.speed_controller import rpm_control
|
||||||
#scheduler.add_job(rpm_control, trigger=IntervalTrigger(seconds=0.5))
|
scheduler.add_job(rpm_control, trigger=IntervalTrigger(seconds=0.5))
|
||||||
|
|
||||||
#control fans
|
#control fans
|
||||||
from scripts.fan_controller import fan_control
|
from scripts.fan_controller import fan_control
|
||||||
|
|
Loading…
Add table
Reference in a new issue