DC Motor Speed Regulation
?
for a given model, just modify the Controller part of the simulation purposes can be achieved, the previous code only proportional link, no integral and differential links, so need to increase these two links, here set kp=8 , Ki=1 , kd=60 , the resulting simulation waveform is
It can be seen that the acceleration and deceleration time is very short, rapid reaction, the overshoot is not small, the speed curve has a very low deviation.
The specific code is as follows:
Block Controller
?
InPort command (n=1);
?
InPort feedback (n=1);
?
OutPort OutPort (n=1);
?
Real error;
?
Real Errori;
?
Real Errord;
?
Real pout;
?
Parameter Real kp=8;
?
Parameter Real ki=1;
?
Parameter Real kd=60;
?
Parameter Real Max_output_pos = 10;
?
Parameter Real Max_output_neg =-10;
?
Algorithm
?
Error: = command.signal[1]-feedback.signal[1];
?
Errori:=errori+error;
?
Errord:=error-pre (Error);
?
Pout: = Kp * Error+ki*errori+kd*errord;
?
If pout > Max_output_pos Then
?
OUTPORT.SIGNAL[1]: = Max_output_pos;
?
ElseIf Pout < Max_output_neg Then
?
OUTPORT.SIGNAL[1]: = Max_output_neg;
?
Else
?
OUTPORT.SIGNAL[1]: = pout;
?
End If;
?
End Controller;
?
?
?
?
DC Motor Speed Regulation operation