DC Motor Speed Control simulation operation

Source: Internet
Author: User

DC Motor Speed Control simulation operation

Block Controller

InPort command (n=1);

InPort feedback (n=1);

OutPort OutPort (n=1);

Real error;

Real pout;

Parameter Real kp=10;

Parameter Real Max_output_pos = 10;

Parameter Real Max_output_neg =-10;

Parameter Real ki=1;

Algorithm

Error: = command.signal[1]-feedback.signal[1];

Pout: = Kp * ERROR;

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;

On the basis of the problem model proportional controller, the combination of integral adjustment and differential regulation is added to the PID controller, and the code is modified 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=7;

Parameter Real ki=0.1;

Parameter Real kd=50;

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;

The effect of PID three adjustment parameters on dynamic response is as follows:

Kp Increase will reduce the current value to achieve a stable time, but will increase the overshoot, reduce system stability;

Ki eliminates steady-state errors, but reduces system stability and slows dynamic response.

KD can reduce overshoot and adjust time;

According to the KP,KI,KD three parameters of the adjustment characteristics, in order to ensure a small adjustment time to minimize overshoot, and then select the adjustment kp,ki,kd three parameters, adjust the KP value to ensure that the adjustment time is short but the overshoot is not too large, Adjust ki to eliminate the steady state error of motor current and motor speed, and minimize the slow effect on dynamic response speed, adjust KD value to reduce overshoot and adjust time. The final selection of PID tuning parameters is kp=7,ki=0.1,kd=50

The resulting motor current and motor speed variation curves are as follows:

To facilitate readout of motor current regulation time and maximum overshoot, the model simulation time is shortened to 1.5s

Simulate (Dcmotorcontrolsystem, stoptime=1.5)

The maximum overshoot is 9.23%, the motor current regulation time is 0.08s, the maximum overshoot and the adjustment time of the dynamic response are very small, and there is no steady state adjustment error.

The complete code is as follows:

Type electricpotential = Real;

Type electriccurrent = Real (quantity = "Electriccurrent", unit = "A");

Type resistance = Real (quantity = "Resistance", unit = "Ohm", min = 0);

Type inductance = Real (quantity = "inductance", unit = "H", min = 0);

Type Voltage = electricpotential;

Type current = Electriccurrent;

Type force = Real (quantity = "force", unit = "N");

Type Angle = Real (quantity = "Angle", unit = "rad", DisplayUnit = "deg");

Type Torque = Real (quantity = "Torque", unit = "n.m");

Type angularvelocity = Real (quantity = "Angularvelocity", unit = "rad/s", DisplayUnit = "rev/min");

Type angularacceleration = Real (quantity = "Angularacceleration", unit = "rad/s2");

Type Momentofinertia = Real (quantity = "Momentofinertia", unit = "kg.m2");

Type time = Real (final quantity= "Time", Final unit= "s");

Connector rotflange_a "1D rotational flange (filled square)"

Angle Phi "Absolute rotational Angle of flange";

Flow Torque Tau "Torque in the flange";

End Rotflange_a; From Modelica.Mechanical.Rotational.Interfaces

Connector Rotflange_b "1D rotational flange (filled square)"

Angle Phi "Absolute rotational Angle of flange";

Flow Torque Tau "Torque in the flange";

End Rotflange_b; From Modelica.Mechanical.Rotational.Interfaces

Connector pin "pin of an electrical component"

Voltage V "potential at the pin";

Flow current I, current flowing into the pin;

End Pin; From Modelica.Electrical.Analog.Interfaces

Connector Positivepin "Positive pin of an electrical component"

Voltage V "potential at the pin";

Flow current I, current flowing into the pin;

End Positivepin; From Modelica.Electrical.Analog.Interfaces

Connector Negativepin "Negative pin of an electrical component"

Voltage V "potential at the pin";

Flow current I, current flowing into the pin;

End Negativepin; From Modelica.Electrical.Analog.Interfaces

Connector InPort "Connector with input signals of type Real"

Parameter Integer n = 1 "Dimension of Signal vector";

Input real signal[n] "real input signals";

End InPort; From Modelica.Blocks.Interfaces

Connector OutPort "Connector with output signals of type Real"

Parameter Integer n = 1 "Dimension of Signal vector";

Output real signal[n] "real output signals";

End OutPort; From Modelica.Blocks.Interfaces

Partial model Rigid//rotational class Rigid

"Base class for the rigid connection of rotational 1D flanges"

Angle Phi "Absolute rotation Angle of component";

Rotflange_a rotflange_a "(left) driving flange (axis directed into plane)";

Rotflange_b Rotflange_b "(right) driven flange (axis directed out of plane)";

Equation

Rotflange_a.phi = phi;

Rotflange_b.phi = phi;

End Rigid; From Modelica.Mechanics.Rotational.Interfaces

Model inertia "1D rotational component with inertia"

Extends Rigid;

Parameter Momentofinertia J = 1 "moment of inertia";

angularvelocity w "Absolute angular velocity of component";

Angularacceleration a "Absolute angular acceleration of component";

Equation

W = der (phi);

A = der (W);

J*a = Rotflange_a.tau + Rotflange_b.tau;

End inertia; From Modelica.Mechanics.Rotational

Partial model Twopin//Same as Oneport in Modelica.Electrical.Analog.Interfaces

"Component with II electrical pins p and N and current I from P to n"

Voltage V "Voltage drop between the pins (= p.v-n.v)";

Current I "current flowing from pin p to pin n";

Positivepin p;

Negativepin N;

Equation

v = p.v-n.v;

0 = p.i + n.i;

i = P.I;

End Twopin;

Model Dcmotor "DC Motor"

Extends Twopin;

Extends Rigid;

OutPort sensorvelocity (n=1);

OutPort sensorcurrent (n=1);

Parameter Momentofinertia J "total inertia";

Parameter resistance R "armature resistance";

Parameter inductance L "armature inductance";

Parameter Real Kt "Torque Constant";

Parameter Real Ke "EMF Constant";

angularvelocity W "Angular Velocity of motor";

Angularacceleration a "Absolute angular acceleration of motor";

Torque Tau_motor;

Rotflange_b Rotflange_b; Rotational Flange_b

Equation

W = der (Rotflange_b.phi);

A = der (W);

v = r*i+ke*w+l*der (i);

Tau_motor = Kt*i;

J*a = Tau_motor + Rotflange_b.tau;

SENSORVELOCITY.SIGNAL[1] = W;

SENSORCURRENT.SIGNAL[1] = i;

End Dcmotor;

Class resistor "Ideal linear electrical Resistor"

Extends Twopin; Same as Oneport

Parameter Real R (unit = "OHM") "resistance";

Equation

R*i = v;

End resistor; From Modelica.Electrical.Analog.Basic

Class inductor "Ideal linear electrical inductor"

Extends Twopin; Same as Oneport

Parameter Real L (unit = "H") "inductance";

Equation

v = l*der (i);

End inductor; From Modelica.Electrical.Analog.Basic

Class Ground "Ground node"

Pin p;

Equation

P.V = 0;

End Ground; From Modelica.Electrical.Analog.Basic

Model Pwmvoltagesource

Extends Twopin;

InPort Command (n=1);

Parameter time T = 0.003;

Parameter Voltage Vin = 200;

Equation

T*der (v) + v = VIN*COMMAND.SIGNAL[1]/10;

End Pwmvoltagesource;

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=7;

Parameter Real ki=0.1;

Parameter Real kd=50;

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;

Block Commandsignalgenerator

OutPort OutPort (n=1);

Real ACC;

Equation

If time <= 1 then

ACC = 60;

ElseIf Time <3 Then

ACC = 0;

ElseIf Time <4 Then

ACC =-60;

Else

ACC = 0;

End If;

Der (outport.signal[1]) = ACC;

End Commandsignalgenerator;

Model Pwmvoltagesource

Extends Twopin;

InPort Command (n=1);

Parameter time T = 0.003;

Parameter Voltage Vin = 200;

Equation

T*der (v) + v = VIN*COMMAND.SIGNAL[1]/10;

End Pwmvoltagesource;

Model Dcmotor "DC Motor"

Extends Twopin;

Extends Rigid;

OutPort sensorvelocity (n=1);

OutPort sensorcurrent (n=1);

Parameter Momentofinertia J "total inertia";

Parameter resistance R "armature resistance";

Parameter inductance L "armature inductance";

Parameter Real Kt "Torque Constant";

Parameter Real Ke "EMF Constant";

angularvelocity W "Angular Velocity of motor";

Angularacceleration a "Absolute angular acceleration of motor";

Torque Tau_motor;

Rotflange_b Rotflange_b; Rotational Flange_b

Equation

W = der (Rotflange_b.phi);

A = der (W);

v = r*i+ke*w+l*der (i);

Tau_motor = Kt*i;

J*a = Tau_motor + Rotflange_b.tau;

SENSORVELOCITY.SIGNAL[1] = W;

SENSORCURRENT.SIGNAL[1] = i;

End Dcmotor;

Block Commandsignalgenerator

OutPort OutPort (n=1);

Real ACC;

Equation

If time <= 1 then

ACC = 60;

ElseIf Time <3 Then

ACC = 0;

ElseIf Time <4 Then

ACC =-60;

Else

ACC = 0;

End If;

Der (outport.signal[1]) = ACC;

End Commandsignalgenerator;

Model Dcmotorcontrolsystem

Ground Ground1;

Inertia inertia1 (J = 3, w (fixed = true));

Dcmotor Motor1 (J = 1,r = 0.6,l = 0.01,kt=1.8, ke= 1.8,rotflange_b (phi (fixed = true));

Commandsignalgenerator SG1;

Controller Con1;

Pwmvoltagesource PowerSource1;

Equation

Connect (Sg1.outport, Con1.command);

Connect (Con1.feedback, Motor1. sensorvelocity);

Connect (Con1.outport, Powersource1.command);

Connect (POWERSOURCE1.P, MOTOR1.P);

Connect (Motor1.rotflange_b, inertia1.rotflange_a);

Connect (POWERSOURCE1.N, GROUND1.P);

Connect (GROUND1.P, MOTOR1.N);

End Dcmotorcontrolsystem;

Simulate (Dcmotorcontrolsystem, stoptime=5)

Plot ({MOTOR1.I,MOTOR1.W})

DC Motor Speed Control simulation operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.