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
|
||||
def rpm_control():
|
||||
print("control_RPM")
|
||||
actual_rpm = float(get_variable(variable_actual_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)))
|
||||
|
@ -79,10 +80,12 @@ def rpm_control():
|
|||
#slow down rotating if over maximum
|
||||
if actual_rpm > float(get_variable(variable_max_rpm)):
|
||||
set_output(actual_set_U - 1)
|
||||
print("max_rpm_reached")
|
||||
return
|
||||
|
||||
if requested_rpm == 0:
|
||||
set_output(0)
|
||||
print("control_set: 0")
|
||||
return
|
||||
|
||||
#algorithm for RPM control
|
||||
|
@ -91,6 +94,7 @@ def rpm_control():
|
|||
set_output(actual_set_U - float(get_variable(variable_control_step_U)))
|
||||
elif requested_rpm > actual_rpm:
|
||||
set_output(actual_set_U + float(get_variable(variable_control_step_U)))
|
||||
print("control_1")
|
||||
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))):
|
||||
|
@ -98,6 +102,7 @@ def rpm_control():
|
|||
set_output(actual_set_U - float(get_variable(variable_control_step_U_1)))
|
||||
elif requested_rpm > actual_rpm:
|
||||
set_output(actual_set_U + float(get_variable(variable_control_step_U_1)))
|
||||
print("control_2")
|
||||
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))):
|
||||
|
@ -105,6 +110,7 @@ def rpm_control():
|
|||
set_output(actual_set_U - float(get_variable(variable_control_step_U_2)))
|
||||
elif requested_rpm > actual_rpm:
|
||||
set_output(actual_set_U + float(get_variable(variable_control_step_U_2)))
|
||||
print("control_3")
|
||||
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))):
|
||||
|
@ -112,6 +118,7 @@ def rpm_control():
|
|||
set_output(actual_set_U - float(get_variable(variable_control_step_U_3)))
|
||||
elif requested_rpm > actual_rpm:
|
||||
set_output(actual_set_U + float(get_variable(variable_control_step_U_3)))
|
||||
print("control_4")
|
||||
return
|
||||
|
||||
print("empty_run")
|
||||
|
|
|
@ -2,7 +2,7 @@ from src.variables.service import get_variable, set_variable
|
|||
from gpiozero import Button
|
||||
import datetime
|
||||
|
||||
from scripts.speed_controller import rpm_control
|
||||
#from scripts.speed_controller import rpm_control
|
||||
|
||||
pulses_per_rotation = 4
|
||||
reader = Button(4, pull_up=False, bounce_time=0.0005)
|
||||
|
@ -22,7 +22,8 @@ def event():
|
|||
set_variable("actual_rpm_unfiltered", rpm, False)
|
||||
|
||||
set_variable("actual_rpm", round(actual_rpm, 1), False)
|
||||
rpm_control()
|
||||
print(round(actual_rpm, 1))
|
||||
# rpm_control()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ if bool(os.getenv("BACKGROUND_SCRIPTS_RUN", 0)):
|
|||
|
||||
|
||||
#control speed
|
||||
#from scripts.speed_controller import rpm_control
|
||||
#scheduler.add_job(rpm_control, trigger=IntervalTrigger(seconds=0.5))
|
||||
from scripts.speed_controller import rpm_control
|
||||
scheduler.add_job(rpm_control, trigger=IntervalTrigger(seconds=0.5))
|
||||
|
||||
#control fans
|
||||
from scripts.fan_controller import fan_control
|
||||
|
|
Loading…
Add table
Reference in a new issue