├── _config.yml ├── PWM.slx ├── DC_motor.slx ├── DC_motor_control_loop.slx ├── DC_motor_control_loop_pwm.slx ├── DC_motor_control_calculations.m └── README.md /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /PWM.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mick001/DC-motor-control-simulation/HEAD/PWM.slx -------------------------------------------------------------------------------- /DC_motor.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mick001/DC-motor-control-simulation/HEAD/DC_motor.slx -------------------------------------------------------------------------------- /DC_motor_control_loop.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mick001/DC-motor-control-simulation/HEAD/DC_motor_control_loop.slx -------------------------------------------------------------------------------- /DC_motor_control_loop_pwm.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mick001/DC-motor-control-simulation/HEAD/DC_motor_control_loop_pwm.slx -------------------------------------------------------------------------------- /DC_motor_control_calculations.m: -------------------------------------------------------------------------------- 1 | % Motor params 2 | R = 5.5; % [Ohm] 3 | L = 0.0028; % [H] 4 | phi = 0.5; % [Wb] 5 | k = 1; % [] 6 | J = 0.5; % [kg m^2] 7 | Cr = 0.1; % [Nm] Assumed Cr constant. 8 | V = 24; 9 | 10 | % Building the system 11 | H = [L 0; 0 J]; 12 | A = inv(H)*[-R -k*phi; k*phi 0]; 13 | B = inv(H)*[V ; -Cr]; 14 | C = [0 1]; 15 | 16 | % Steady state solution with a unit voltage step input 17 | -inv(A)*B % current / angular speed 18 | % OUTPUT 19 | % 20 | %ans = 21 | % 22 | % 0.2000 23 | % 45.8000 24 | 25 | % State space system 26 | sys = ss(A, B, C, 0, 'StateName',{'Current' 'Angular speed'},'InputName','Voltage'); 27 | 28 | % System response to unit voltage step 29 | step(sys) 30 | 31 | %% 32 | % Series connection with PI regulator and then negative feedback 33 | t = feedback(series(pid(5,1), sys), 1); 34 | % New system response to a unit voltage step 35 | step(t) 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## DC motor control simulation in Matlab and Simulink 2 | 3 | A simulation of a control loop for a DC motor. 4 | 5 | Two control strategies have been implemented through the use of a PI regulator: 6 | 7 | 1. Linear voltage control 8 | 2. PWM control 9 | 10 | The files in this repository are the following: 11 | 12 | - DC_motor.slx which is the Simulink model of the DC motor 13 | - PWM.slx which is a simulink model for a PWM block (input=analogue voltage from 0 to 1 V, output=PWM signal to static switch) 14 | - State space system: motor parameter, state space system and step response 15 | - DC-motor-analogue-control.slx: Simulink model of a linear voltage control through a PI regulator 16 | - DC-motor-pwm-control.slx: Simulink model of a PWM control through a PI regulator 17 | 18 | The regulator was tuned with some overshoot using the tuning utility in Matlab. 19 | 20 | ### Control loop 21 | ![PWM control](https://user-images.githubusercontent.com/13961654/53666004-3df3cb00-3c6d-11e9-8f61-2fe56ec14dc8.png) 22 | ![Linear voltage control](https://user-images.githubusercontent.com/13961654/53666006-3f24f800-3c6d-11e9-87f5-8113fb4e0dcb.png) 23 | 24 | ### DC motor model implementation 25 | ![dc-motor](https://user-images.githubusercontent.com/13961654/53666767-4ea54080-3c6f-11e9-9af9-219a589f9025.png) 26 | 27 | #### Speed [rad/s] over time [s] 28 | ![speed-control-example](https://user-images.githubusercontent.com/13961654/53666772-52d15e00-3c6f-11e9-933a-781240180f96.png) 29 | --------------------------------------------------------------------------------