Accused
Consider such a controlled object
J θ ¨ ( t ) = u ( t ) + d ( t ) J \ddot\theta(t) = u(t) + d(t)Ji¨(t)=u(t)+d ( t )
among them,JJJ is the moment of inertia,θ \thetaθ is angle,uuu is the control quantity,ddd is the disturbance, andd ( t ) < D d(t) < Dd(t)<D disturbance bounded
design sliding surface
The design sliding surface is
s = ce ( t ) + e ˙ ( t ) s = ce(t) + \dot e(t)s=what ( t )+e˙ (t)
where the tracking error and its derivative are,θ d \theta_didFor the ideal angle signal
e ( t ) = θ ( t ) − θ d ( t ) e(t) = \theta (t) - \theta_d(t)e(t)=θ ( t )−id(t)
e ˙ ( t ) = θ ˙ ( t ) − θ ˙ d ( t ) \dot e(t) = \dot\theta (t) - \dot\theta_d(t) e˙(t)=i˙(t)−i˙d(t)
gain control
s ˙ = c e ˙ ( t ) + e ¨ ( t ) = c e ˙ ( t ) + 1 J ( u ( t ) + d ( t ) ) − θ ¨ d ( t ) = − ε s g n ( s ) \begin{align} \dot s &= c \dot e(t) + \ddot e(t) = c \dot e(t) + \frac{1}{J} (u(t) + d(t)) - \ddot \theta_d(t) = -\varepsilon sgn(s) \end{align} s˙=ce˙(t)+e¨(t)=ce˙(t)+J1(u(t)+d(t))−i¨d(t)=−εsgn(s)
Inversely solve the control quantity u ( t ) u(t)u(t)
u ( t ) = J ( − c e ˙ ( t ) + θ ¨ d ( t ) − ε s g n ( s ) ) − d ( t ) u(t) = J(-c\dot e(t) + \ddot \theta_d(t) - \varepsilon sgn(s)) - d(t) u(t)=J ( − ce˙(t)+i¨d(t)−εsgn(s))−d ( t )
Here we ignore the interference
u ( t ) = J ( − ce ˙ ( t ) + θ ¨ d ( t ) − ε sgn ( s ) ) u(t) = J(-c\dot e(t) + \ddot \theta_d(t) - \varepsilon sgn(s))u(t)=J ( − ce˙(t)+i¨d(t)−εsgn(s))
proof of stability
Let LYapunov function V = 1 2 S 2 V=\frac{1}{2}S^2V=21S2 ,let
V ̇ = ss ̇ = s ( ce ̇ ( t ) + e ̈ ( t ) ) = s ( ce ̇ ( t ) + 1 J ( u ( t ) + d ( t ) ) − θ ̈ d ( t ) ) = s ( ce ̇ ( t ) + 1 J ( J ( − ce ̇ ( t ) + θ ̈ d ( t ) − ε sgn ( s ) ) + d ( t ) ) − θ ̈ d ( t ) ) = s ( − ε sgn ( s ) + 1 J d ( t ) ) = − ε ∣ s ∣ + 1 J sd ( t ) \begin{align} \dot V &= s \dot s \\ &= s(c \dot(t) + \ddot(t)) \\ &= s(c\dot(t) + \frac{1}{J}(u(t) + d(t)) - \ddot \theta_d(t)) \\ &= s(c \dot e(t) + \frac{1}{J} (J(-c\dot e(t) + \ddot \theta_d(t) - \valuepsilon sgn(s)) + d(t)) - \ddot \theta_d(t)) \\ &= s(-\valuepsilon sgn(s) + \frac{1}{J}d(t)); \\ &= -\varepsilon |s| + \frac{1}{J}sd(t)\end{align}V˙=ss˙=s(ce˙(t)+e¨(t))=s(ce˙(t)+J1(u(t)+d(t))−i¨d(t))=s(ce˙(t)+J1( J ( − ce˙(t)+i¨d(t)−εsgn(s))+d(t))−i¨d(t))=s(−εsgn(s)+J1d(t))=−ε∣s∣+J1sd(t)
It can be seen that when the disturbance $d(t) $ has an upper bound, that is, d ( t ) < D d(t) < Dd(t)<D disturbance is bounded, ifε \varepsilonIf the value of ε is reasonable, the system is stable.
python simulation program
Suppose the simulation signal we track is θ d ( t ) = sin ( t ) \theta_d(t) = sin(t)id(t)=s in ( t ) , moment of inertiaJ = 10 J=10J=10 , initial valueθ ( 0 ) = 0 \theta(0) = 0i ( 0 )=0 ,θ ̇ ( 0 ) = 0 \dot \theta(0) =i˙(0)=0。
import numpy as np
import matplotlib.pyplot as plt
# 被控对象
class ControlModel():
def __init__(self):
self.T = 10
self.times = 10 * 1000
self.time_T = self.T / self.times
self.pos = 0
self.theta = np.zeros(self.times, dtype='float64')
self.dot_theta = np.zeros(self.times, dtype='float64')
self.u = np.zeros(self.times, dtype='float64')
self.d = np.zeros(self.times, dtype='float64')
self.J = 10
self.Max_u = 30
def reset(self):
self.pos = 0
self.dot_theta[0] = np.deg2rad(0)
self.theta[0] = np.deg2rad(0)
self.d[0] = 0
def step(self, u):
if self.pos >= self.times:
return True
if np.abs(u) > self.Max_u:
u = np.sign(u) * self.Max_u
self.u[self.pos] = u
self.d[self.pos] = 10
self.stepOnce()
self.pos += 1
return False
def stepOnce(self):
data = np.array([self.u[self.pos],
self.d[self.pos],
self.dot_theta[self.pos],
self.theta[self.pos],
self.J])
k1 = self.time_T * self.iterateOnce(data)
k2 = self.time_T * self.iterateOnce(data + 0.5 * k1)
k3 = self.time_T * self.iterateOnce(data + 0.5 * k2)
k4 = self.time_T * self.iterateOnce(data + k3)
data = data + (k1 + 2 * k2 + 2 * k3 + k4) / 6
self.dot_theta[self.pos + 1] = data[2]
self.theta[self.pos + 1] = data[3]
def iterateOnce(self, data):
u = data[0]
d = data[1]
dot_theta = data[2]
theta = data[3]
J = data[4]
_dot_theta = (u + d) / J
_theta = dot_theta
return np.array([0, 0, _dot_theta, _theta, 0])
def get_theta(self):
return self.theta[self.pos - 1]
def get_dot_theta(self):
return self.dot_theta[self.pos - 1]
# 误差,误差的一阶导,误差的二阶导的结构
class Control:
def __init__(self):
self.e = 0
self.dot_e = 0
self.ddot_e = 0
def insert(self, e):
self.ddot_e = e - self.e - self.dot_e
self.dot_e = e - self.e
self.e = e
def get_e(self):
return self.e
def get_dot_e(self):
return self.dot_e
def get_ddot_e(self):
return self.ddot_e
# 生成控制对象
M = ControlModel()
M.reset()
C = Control()
T = Control()
theta_list = []
for i in range(M.times - 1):
theta_d = np.sin(i / 1000)
theta_list.append(theta_d)
e = (theta_d - M.get_theta()) / M.time_T
C.insert(e)
T.insert(theta_d)
c = 5
varesplion = 3
s = c * C.get_e() + C.get_dot_e()
u = M.J * (c * C.get_dot_e() + T.get_ddot_e() + varesplion * np.sign(s))
M.step(u)
Simulation results
The position tracking curve is as follows
The control curve is as follows
It can be seen that the effect of position tracking is still good. Here we have carried out a certain limit, which affects its control effect, but the control amount has chattering. In a real control environment, components may not be able to withstand start this chattering.