Skip to content

Commit

Permalink
BF: Controlled system PT1 #1084
Browse files Browse the repository at this point in the history
  • Loading branch information
amesin13 committed Jan 6, 2025
1 parent 03d89ed commit a52b7bd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/mlpro/bf/systems/pool/first_order_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
## - changed dt = p_step to dt = p_step.total_seconds()
## -- 2024-12-03 0.5.0 ASP class PT1: update methods _reset()
## - add start state of the system
## -- 2024-12-30 0.6.0 ASP class PT1: Refactoring
## -- 2024-12-30 0.6.0 ASP class PT1: Refactoring
## - add C_SAMPLE_FREQ : Specifies how often the system is sampled in a control cycle
## - add self._dt: Sampling time
## - update _simulate_reaction(), _reset()
## -- 2025-01-05 0.7.0 ASP class PT1: Refactoring
## - changed self.K to self._K
## - changed self.T to self._T
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.6.0 (2024-12-30)
Ver. 0.7.0 (2025-01-05)
This module provides a simple demo system that represent a first-order-system
Further information: https://www.circuitbread.com/tutorials/first-order-systems-2-2
"""
Expand Down Expand Up @@ -78,8 +81,8 @@ def __init__( self,
Start value of the control variable
"""

self.K = p_K
self.T = p_T
self._K = p_K
self._T = p_T
self._sys_num = p_sys_num
self._y_start = p_y_start
self._y_prev = None
Expand Down Expand Up @@ -140,7 +143,7 @@ def _simulate_reaction(self, p_state: State, p_action: Action, p_step = None):
for step in range(self.C_SAMPLE_FREQ):

# rekursions function of first oder system
y = (self._dt* self.K * u + self.T * self._y_prev) / (self.T + self._dt)
y = (self._dt* self._K * u + self._T * self._y_prev) / (self._T + self._dt)
self._y_prev = y

# Limit output
Expand Down

0 comments on commit a52b7bd

Please sign in to comment.