diff --git a/pyconsys/DControl.py b/pyconsys/DControl.py index 9454a06..2b03397 100644 --- a/pyconsys/DControl.py +++ b/pyconsys/DControl.py @@ -15,6 +15,11 @@ def __init__(self, kd=1): self._kd = kd self._xe_old = 0 + def reset(self, kd): + """ resets the unit """ + self._kd = kd + self._xe_old = 0 + def get_xa(self, xe): """ give input, get output Parameters: diff --git a/pyconsys/DelayControl.py b/pyconsys/DelayControl.py index 5b53c4f..a752961 100644 --- a/pyconsys/DelayControl.py +++ b/pyconsys/DelayControl.py @@ -16,6 +16,12 @@ def __init__(self, delay=0): self._queue = queue.Queue() self._counter = 0 + def reset(self, delay): + """ resets the unit """ + self._delay = delay + self._counter = 0 + self._queue.queue.clear() + def get_xa(self, xe): """ give input, get output Parameters: diff --git a/pyconsys/IControl.py b/pyconsys/IControl.py index f7cd8fe..b0005be 100644 --- a/pyconsys/IControl.py +++ b/pyconsys/IControl.py @@ -15,6 +15,11 @@ def __init__(self, ki=1): self._ki = ki self._sum = 0 + def reset(self, ki): + """ resets the unit """ + self._ki = ki + self._sum = 0 + def get_xa(self, xe): """ give input, get output Parameters: diff --git a/pyconsys/PControl.py b/pyconsys/PControl.py index f758a69..257b5e5 100644 --- a/pyconsys/PControl.py +++ b/pyconsys/PControl.py @@ -14,6 +14,10 @@ def __init__(self, kp=1): kp(float): Kp""" self._kp = kp + def reset(self, kp): + """ resets the unit """ + self._kp = kp + def get_xa(self, xe): """ give input, get output Parameters: diff --git a/pyconsys/PIDControl.py b/pyconsys/PIDControl.py index 7b67815..e3da338 100644 --- a/pyconsys/PIDControl.py +++ b/pyconsys/PIDControl.py @@ -26,11 +26,9 @@ def update_params(self, kp, ki, kd): kp(float): Kp ki(float): Ki kd(float): Kd """ - self._pControl._kp = kp - self._iControl._ki = ki - self._iControl._sum = 0 - self._dControl._kd = kd - self._dControl._xe_old = 0 + self._pControl.reset(kp) + self._iControl.reset(ki) + self._dControl.reset(kd) def get_xa(self, xe): """ give input, get output