Skip to content

Commit

Permalink
fix inability to use Daily Bezier method in PID (#323), fix display o…
Browse files Browse the repository at this point in the history
…f first point of Daily Bezier method
  • Loading branch information
kizniche committed Nov 18, 2017
1 parent 7a13c90 commit 9031298
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 5.4.2 (Unreleased)

### Bugfixes

- Fix display of first point of Daily Bezier method
- Fix inability to use Daily Bezier method in PID ([#323](https://github.com/kizniche/mycodo/issues/323))


## 5.4.1 (2017-11-12)

### Features
Expand Down
24 changes: 16 additions & 8 deletions mycodo/controller_pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def run(self):

while self.running:

if self.method_start_act == 'Ended':
if (self.method_start_act == 'Ended' and
self.method_type == 'Duration'):
self.stop_controller(ended_normally=False,
deactivate_pid=True)
self.logger.warning(
Expand Down Expand Up @@ -460,9 +461,12 @@ def manipulate_output(self):
abs(self.control_variable))
if self.control_variable < 0:
pid_entry_value = -pid_entry_value
self.write_pid_output_influxdb('duty_cycle', pid_entry_value)
self.write_pid_output_influxdb(
'duty_cycle', pid_entry_value)

elif self.raise_output_type in ['command', 'wired', 'wireless_433MHz_pi_switch']:
elif self.raise_output_type in ['command',
'wired',
'wireless_433MHz_pi_switch']:
# Ensure the output on duration doesn't exceed the set maximum
if (self.raise_max_duration and
self.control_variable > self.raise_max_duration):
Expand All @@ -484,7 +488,8 @@ def manipulate_output(self):
duration=self.raise_seconds_on,
min_off=self.raise_min_off_duration)

self.write_pid_output_influxdb('pid_output', self.control_variable)
self.write_pid_output_influxdb(
'pid_output', self.control_variable)

else:
if self.raise_output_type == 'pwm':
Expand Down Expand Up @@ -520,8 +525,8 @@ def manipulate_output(self):
self.lower_duty_cycle = self.lower_min_duration

self.logger.debug(
"Setpoint: {sp}, Control Variable: {cv}, Output: PWM output "
"{id} to {dc:.1f}%".format(
"Setpoint: {sp}, Control Variable: {cv}, "
"Output: PWM output {id} to {dc:.1f}%".format(
sp=self.set_point,
cv=self.control_variable,
id=self.lower_output_id,
Expand All @@ -540,7 +545,9 @@ def manipulate_output(self):
pid_entry_value = -pid_entry_value
self.write_pid_output_influxdb('duty_cycle', pid_entry_value)

elif self.lower_output_type in ['command', 'wired', 'wireless_433MHz_pi_switch']:
elif self.lower_output_type in ['command',
'wired',
'wireless_433MHz_pi_switch']:
# Ensure the output on duration doesn't exceed the set maximum
if (self.lower_max_duration and
abs(self.control_variable) > self.lower_max_duration):
Expand All @@ -561,7 +568,8 @@ def manipulate_output(self):
duration=self.lower_seconds_on,
min_off=self.lower_min_off_duration)

self.write_pid_output_influxdb('pid_output', self.control_variable)
self.write_pid_output_influxdb(
'pid_output', self.control_variable)

else:
if self.lower_output_type == 'pwm':
Expand Down
2 changes: 2 additions & 0 deletions mycodo/mycodo_flask/method_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def method_data(method_id):
for n in range(points_x):
percent = n / float(points_x)
second_of_day = percent * seconds_in_day
if second_of_day == 0:
continue
y = bezier_curve_y_out(last_method_data.shift_angle,
P0, P1, P2, P3,
second_of_day)
Expand Down

0 comments on commit 9031298

Please sign in to comment.