debug speed control algorithm #3
This commit is contained in:
parent
ebda5844ef
commit
4a439fabdc
1 changed files with 3 additions and 4 deletions
|
@ -4,11 +4,10 @@ import datetime
|
||||||
|
|
||||||
from scripts.speed_controller import rpm_control
|
from scripts.speed_controller import rpm_control
|
||||||
|
|
||||||
pulses_per_rotation = 1
|
pulses_per_rotation = 4
|
||||||
reader = Button(4, pull_up=False, bounce_time=0.0005)
|
reader = Button(4, pull_up=False, bounce_time=0.0005)
|
||||||
set_variable("speed_reader_last_impulse_time", datetime.datetime.now(), False)
|
set_variable("speed_reader_last_impulse_time", datetime.datetime.now(), False)
|
||||||
|
|
||||||
rpm_last = 0
|
|
||||||
|
|
||||||
def event():
|
def event():
|
||||||
actual = datetime.datetime.now()
|
actual = datetime.datetime.now()
|
||||||
|
@ -18,8 +17,8 @@ def event():
|
||||||
|
|
||||||
rpm = (60 / difference) / pulses_per_rotation
|
rpm = (60 / difference) / pulses_per_rotation
|
||||||
|
|
||||||
actual_rpm = (rpm_last + rpm) / 2
|
actual_rpm = (float(get_variable("actual_rpm_unfiltered")) + rpm) / 2
|
||||||
rpm_last = rpm
|
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()
|
rpm_control()
|
||||||
|
|
Loading…
Add table
Reference in a new issue