├── 10.png ├── 3.png ├── 4.png ├── 9.png ├── README.md ├── SystemDynamicsTwolinks.m ├── circularPIDResults.m ├── plots.m ├── robotics1_report.pdf ├── simulink.PNG ├── trajectory.m ├── twolinkDynamics.slx ├── twolinkDynamics.slxc ├── twolinkDynamics2012b.slx ├── twolinkDynamics2012b_acc.mexw64 └── twolinkDynamics2012b_sfun.mexw64 /10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/10.png -------------------------------------------------------------------------------- /3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/3.png -------------------------------------------------------------------------------- /4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/4.png -------------------------------------------------------------------------------- /9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/9.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PID-control-of-twolink-robotic-arm 2 | Developed a PID control system for two-link robotic arm in SIMULINK/MATLAB 3 | 4 | twolinkDynamics.slx is the main file which twolink robotic arm is tracking circular motion using PID control. 5 | simulink.PNG is the image of the simulink model design for PID control of twolink robotic arm. 6 | trajectory.m contains the trajectory which the robot is provides (circular trajectory). 7 | 8 | plots.m is used to generate the results after tracking the trajectory provided to the robot. 9 | 10 | rest of the png's are the tracking results. 11 | -------------------------------------------------------------------------------- /SystemDynamicsTwolinks.m: -------------------------------------------------------------------------------- 1 | function [actual_th1_dd,actual_th2_dd]= fcn(T1, T2,des_th1_dd,des_th1_d,des_th2_dd,des_th2_d,des_th1,des_th2) 2 | 3 | 4 | 5 | N=1; 6 | jm1=0.01; 7 | jm2=0.01; 8 | cm1=0.1; 9 | cm2=0.1; 10 | M1=1; 11 | M2=0.5; 12 | L1=2; 13 | L2=1; 14 | g=9.8; 15 | 16 | th1=des_th1 17 | th2=des_th2 18 | th1dd=des_th1_dd 19 | th1d=des_th1_d 20 | th2dd=des_th2_dd 21 | th2d=des_th2_d 22 | 23 | M=[((M1+M2)*(L1^2)+ (M2*L2^2)+ (2*M2*L1*L2*cos(th2))) (M2*L2^2+ M2*L1*L2*cos(th2)); 24 | (M2*L2^2+M2*L1*L2*cos(th2)) (M2*L2^2)]; 25 | 26 | 27 | V=[((-M2*L1*L2)*(2*th1d*th2d+th2d^2)*sin(th2)); 28 | (M2*L1*L2*th1d^2*sin(th2))]; 29 | 30 | 31 | 32 | 33 | G= [((M1+M2)*g*L1*cos(th1)+M2*g*L2*cos(th1+th2)); 34 | M2*g*L2*cos(th1+th2)]; 35 | 36 | Tt1= N*T1 -N^2* jm1*des_th1_dd -N^2*cm1 *des_th1_d 37 | Tt2= N*T2 -N^2* jm2*des_th2_dd -N^2*cm2 *des_th2_d 38 | 39 | NJ=[N*jm1 0; 40 | 0 N*jm2] 41 | 42 | NT=[N*T1; 43 | N*T2] 44 | 45 | NC=[N*cm1 0; 46 | 0 N*cm2] 47 | 48 | thd=[des_th1_d; 49 | des_th1_d] 50 | 51 | 52 | actual_th_dd= inv(M+NJ) *(NT -V- G-(NC*thd)); 53 | v= actual_th_dd(1) 54 | w=actual_th_dd(2) 55 | 56 | actual_th1_dd=v 57 | actual_th2_dd=w 58 | -------------------------------------------------------------------------------- /circularPIDResults.m: -------------------------------------------------------------------------------- 1 | plot(xd,yd) 2 | title('Circular Desired path for the Robot') 3 | xlabel ('X-axis') 4 | ylabel ('Y-axis') 5 | xlim([0 2]) 6 | ylim([0 2]) 7 | figure 8 | plot(x,y) 9 | xlabel ('X-axis') 10 | ylabel ('Y-axis') 11 | xlim([0 2]) 12 | ylim([0 2]) 13 | title('Circular path drawn by the robot') 14 | figure 15 | plot(tout,des_th1) 16 | hold on 17 | plot(tout,actual_th1) 18 | title('Graph between Actual and Desired theta1') 19 | xlim([0 360]) 20 | ylim([0 0.6]) 21 | xlabel ('time') 22 | ylabel ('Amplitude') 23 | 24 | figure 25 | plot(tout,des_th2) 26 | hold on 27 | plot(tout,actual_th2) 28 | title('Graph between Actual and Desired theta2') 29 | xlim([0 360]) 30 | ylim([2 2.9]) 31 | xlabel ('time') 32 | ylabel ('Amplitude') 33 | 34 | figure 35 | plot(tout,x) 36 | hold on 37 | plot(tout,xd) 38 | title('Graph between Actual and Desired X-cordinates') 39 | xlim([0 360]) 40 | ylim([2 2.9]) 41 | xlabel ('time') 42 | ylabel ('Amplitude') -------------------------------------------------------------------------------- /plots.m: -------------------------------------------------------------------------------- 1 | 2 | %plots 3 | plot(x,y); 4 | hold on 5 | plot(xd,yd); 6 | xlabel ('Input (RED) Vs Output (BLUE) trajectory') 7 | figure; 8 | for i=1:1:361 9 | error_x(i)=xd(i)-x(i); 10 | end 11 | for i=1:1:361 12 | error_y(i)=yd(i)-y(i); 13 | end 14 | plot(time,error_x) 15 | hold on 16 | plot(time,error_y) 17 | plot(x,y); -------------------------------------------------------------------------------- /robotics1_report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/robotics1_report.pdf -------------------------------------------------------------------------------- /simulink.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/simulink.PNG -------------------------------------------------------------------------------- /trajectory.m: -------------------------------------------------------------------------------- 1 | times=1:1:301; 2 | a=3*ones(1,301); 3 | z=0:0.01:3; 4 | x_traj=[times;a]'; 5 | y_traj=[times;z]'; -------------------------------------------------------------------------------- /twolinkDynamics.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/twolinkDynamics.slx -------------------------------------------------------------------------------- /twolinkDynamics.slxc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/twolinkDynamics.slxc -------------------------------------------------------------------------------- /twolinkDynamics2012b.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/twolinkDynamics2012b.slx -------------------------------------------------------------------------------- /twolinkDynamics2012b_acc.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/twolinkDynamics2012b_acc.mexw64 -------------------------------------------------------------------------------- /twolinkDynamics2012b_sfun.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muhammad-Arsalan03/PID-control-of-twolink-robotic-arm/fecfec9c97d90ac639eb7cf446aba7b1fa17755d/twolinkDynamics2012b_sfun.mexw64 --------------------------------------------------------------------------------