Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 23 additions & 49 deletions tools/pidmayuresh3.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,26 @@
import numpy as np
import math
import concore
dT = 0.1

sp = concore.tryparam('sp', 67.5)
Kp = concore.tryparam('Kp', 0.075)
Ki = concore.tryparam('Ki', 0.02)
Kd = concore.tryparam('Kd', 0.005)
freq = concore.tryparam('freq',30)
sigout = concore.tryparam('sigout',True)
cin = concore.tryparam('cin', 'hr')

def pid_controller(state, ym, sp, Kp, Ki, Kd, sigout, cin, low, up):
Prev_Error = state[0]
I = state[1]
if cin == 'hr':
Error = sp - ym[1]
elif cin == 'map':
Error = sp - ym[0]
else:
print('invalid control input '+cin)
quit()
P = Error
I = I + Error*dT
D = (Error - Prev_Error )/dT
amp = Kp*P + Ki*I + Kd*D
Prev_Error = Error
if sigout:
amp = (up-low)/(1.0 + math.exp(amp)) + low
state = [Prev_Error, I]
return (state, amp)


concore.default_maxtime(150)
concore.delay = 0.02
init_simtime_ym = "[0.0, 70.0,91]"
ym = np.array(concore.initval(init_simtime_ym))
state = [0.0, 0.0]
print("Mayuresh's PID controller: sp is "+str(sp))
print(concore.params)
while(concore.simtime<concore.maxtime):
while concore.unchanged():
ym = concore.read(1,"ym",init_simtime_ym)
ym = np.array(ym)
(state,amp) = pid_controller(state,ym,sp,Kp,Ki,Kd,sigout,cin,0,3)
u = np.array([amp,freq])
print(str(concore.simtime) + " u="+str(u) + "ym="+str(ym))
concore.write(1,"u",list(u),delta=0)
"""
Backward-compatibility wrapper for pidmayuresh.py.

This file previously contained a duplicate PID controller implementation
that used print() instead of logging. The canonical implementation now
lives in pidmayuresh.py (which uses the logging module).

This wrapper re-exports everything so that any existing import of
pidmayuresh3 continues to work without modification.

See: https://github.com/ControlCore-Project/concore/issues/378
"""

import warnings
warnings.warn(
"pidmayuresh3 is deprecated — use pidmayuresh instead.",
DeprecationWarning,
stacklevel=2,
)

# Re-execute the canonical module so run-time behaviour is identical
# when this file is invoked directly (e.g., via a study graph).
from pidmayuresh import * # noqa: F401,F403
Comment thread
GaneshPatil7517 marked this conversation as resolved.
Outdated



Loading