How to generate the transfer function of a DC motor?
80 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chak Chan
el 21 de Dic. de 2017
Respondida: MUHAMMAD IBRAR
el 20 de Jul. de 2022
Hi,
I'm designing a PID controller for a DC motor. The motor is controlled by a board based on STM32F4, so my question is, is there a way to automatically generate PID code on the board by measuring real-time input/output with Simulink? Any detailed answers/tutorials/videos would definitely help!
Thank you in advance!
0 comentarios
Respuesta aceptada
Birdman
el 21 de Dic. de 2017
Editada: Birdman
el 21 de Dic. de 2017
Well, there is no online tool that will generate PID code for the controlled system. For that purpose, as usual, the best you can do is to model the DC motor with its transfer function model. For this, you can estimate its parameters. There are several videos and tutorials for this. All you need to do is to excite the system with some test inputs and record the output and the use Estimation Tool for it. All the things I mentioned will be done offline. Check the following links:
Also for the record, I leave the link of STM32F4 library in Simulink:
3 comentarios
Birdman
el 21 de Dic. de 2017
Of course, you can use the analog input/output pins of the board and analog input/output blocks from the Simulink.
Más respuestas (2)
Arkadiy Turevskiy
el 20 de Jun. de 2019
Starting in R2017b we are shipping capabilities for online tuning of PID controllers.
The best way to do this is by using Closed-Loop PID Autotuner block. You add this block to your Simulink model that you will generate code from, and you configure the model to activate autotuning based on a provided trigger signal.
The algorithm in this block will conduct an online experiment on your plant by injecting a small excitation signal and measuring the output. Beasued on measured data it will estimate plant frequency response and will compute PID gains that can automatically update existing PID gains once tuning is finished.
To tune PID gains on hardware (in generated code) with this capaility, you will need access to a license of Simulink Control Design and Simulink Coder.
0 comentarios
MUHAMMAD IBRAR
el 20 de Jul. de 2022
% This program will simulate the Armature controlled DC Motor Transfer
% funcations along with the step out waveform
disp('In order to use the program all motor parameters must be converted to SI units')
disp('If the maxium operating speed is not given please enter zero')
wmax=input('What is the maximum operating speed, Wmax(rad/s)>');
Imax=input('What is the maximum armature current, Imax(A)>');
Ke=input('What is the Voltage constant, Ke(V*s/rad)>');
Kt=input('What is the Torque constant, Kt(N*m/A)>');
Tf=input('What is the Friction torque, Tf(N*m)>');
R=input('What is the Armature resistance, R(ohms)>');
L=input('What is the Armature inductnace, L(H)>');
Jm=input('What is the Armature moment of inertia, Jm(N*m*s^2/rad)>');
Bm=input('What is the Armature viscous friction, Bm(N*M*s/rad)>');
disp('Does the motor have speed reducers and load specifications?');
ans=input('Enter 1 for YES; Enter 0 for No>')
if ans==1;
N1=input('How many teeth are on the first(N1) speed reducer>');
N2=input('How many teeth are on the second(N2) speed reucer>');
JL=input('What is the Load inertia (JL)>');
BL=input('What is the Load friction (BL)>');
disp('The Mechanical time constant is (sec)')
Tm=Jm/Bm
pause
disp('The Electrical time constant is (sec)')
Te=L/R
pause
disp('The Voltage-driven Transfer Funcation of the Motor (OhmM(s)/Ea(s)')
X0=(R*Bm)+(Ke*Kt);
X1=(R*Bm*(Tm+Te));
X2=(R*Bm*Tm*Te);
X10=(X0/X2);
X11=(X1/X2);
X12=(X2/X2);
X13=(Kt/X2);
num=[Kt];
den=[X2 X1 X0];
t1=tf(num, den)
step(t1)
pause
disp('The simplified of Above Transfer funcation')
num=[X13];
den=[X12 X11 X10];
t0=tf(num, den)
step(t0)
pause
disp('Therefore the natural damped frequency of the motor is>')
w=sqrt(X10)
pause
disp('Therefore the damping factor is>')
df=(X11/(2*(w)))
pause
disp('The Simplified gain is (rad/v*s)')
Ks=((Kt)/((R*Bm)+(Ke*Kt)))
pause
disp('The simplified time constantis (s)')
Ts=((R*Jm)/((R*Bm)+(Ke*Kt)))
pause
disp('The simplified velocity Motor transfer function is(ohmM(s)/Ea(s)')
num=[Ks];
den=[Ts 1];
t2=tf(num, den)
step(t2)
pause
disp('The simplified Motor position transfer funcation is (thetaM(s)/Ea(s)>')
num=[Ks];
den=[Ts 1 0];
t3=tf(num, den)
step(t3)
pause
disp('The current-driven Motor velocity transfer funcation is (ohmsM(s)/Ia(s)>')
Kc=Kt/Bm;
num=[Kc];
den=[Tm 1];
t4=tf(num,den)
step(t4)
pause
disp('The current-driven Motor poistion tranfer function is thetaM(s)/Ia(s)>')
num=[Kc];
den=[Tm 1 0];
t5=tf(num,den)
step(t5)
pause
disp('The inertia of motor and load is, (N*m*s^2/rad)')
Jt=(Jm+(((N1/N2)^2)*JL))
pause
disp('The friction of motor and load is, N*m*s/rad')
Bt=(Bm+(((N1/N2)^2)*BL))
pause
disp('The torque time constant is, (s)')
Tt=Jt/Bt
pause
disp('The velocity transfer function (of Voltage-Driven Motor,speed Reducer and Load) is ohmsL(s)/Ea(s)>')
X3=((R*Bt)+(Ke*Kt));
X4=((R*Bt)*(Tt+Te));
X5=((R*Bt*Tt*Te));
N=(Kt*(N1/N2));
X15=N/X5;
X16=X3/X5;
X17=X4/X5;
X18=X5/X5;
num=[N];
den=[X5 X4 X3];
t6=tf(num,den)
step(t6)
pause
disp('The simplified of Above Transfer funcation')
num=[X15];
den=[X18 X17 X16];
t00=tf(num,den)
step(t00)
pause
disp('The poistion transfer funcation is thetaL(s)/Ea(s)>')
num=[N];
den=[X5 X4 X3 0];
t7=tf(num,den)
step(t6)
pause
disp('The simplified of Above Transfer funcation')
num=[X15];
den=[X18 X17 X16 0];
t000=tf(num,den)
step(t000)
pause
disp('Thank for using my program')
disp('Program created by Taptej Khachh (Humber College Student)')
else
ans==0;
disp('The Mechanical time constant is (sec)')
Tm=Jm/Bm
pause
disp('The Electrical time constant is (sec)')
Te=L/R
pause
disp('The Voltage-driven Transfer Funcation of the Motor (OhmM(s)/Ea(s)')
X0=(R*Bm)+(Ke*Kt);
X1=(R*Bm*(Tm+Te));
X2=(R*Bm*Tm*Te);
X10=(X0/X2);
X11=(X1/X2);
X12=(X2/X2);
X13=(Kt/X2);
num=[Kt];
den=[X2 X1 X0];
t1=tf(num, den)
step(t1)
pause
disp('The simplifed of Above Transfer Funcation>')
num=[X13];
den=[X12 X11 X10];
t0=tf(num, den)
step(t0)
pause
disp('Therefore the natural damped frequency of the motor is>')
w=sqrt(X10)
pause
disp('Therefore the damping factor is>')
df=(X11/(2*(w)))
pause
disp('The Simplified gain is (rad/v*s)')
Ks=((Kt)/((R*Bm)+(Ke*Kt)))
pause
disp('The simplified time constantis (s)')
Ts=((R*Jm)/((R*Bm)+(Ke*Kt)))
pause
disp('The simplified Motor velocity transfer function is (ohmM(s)/Ea(s)')
num=[Ks];
den=[Ts 1];
t2=tf(num, den)
step(t2)
pause
disp('The simplified Motor position transfer funcation is (thetaM(s)/Ea(s)>')
num=[Ks];
den=[Ts 1 0];
t3=tf(num, den)
step(t3)
pause
disp('The current-driven Motor velocity transfer funcation is (ohmsM(s)/Ia(s)>')
Kc=Kt/Bm;
num=[Kc];
den=[Tm 1];
t4=tf(num,den)
step(t4)
pause
disp('The current-driven Motor poistion tranfer function is thetaM(s)/Ia(s)>')
num=[Kc];
den=[Tm 1 0];
t5=tf(num,den)
step(t5)
pause
end
0 comentarios
Comunidades de usuarios
Más respuestas en Power Electronics Control
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!