Control Systems course project | Facultad de Ingeniería (FING), Universidad de la República, Uruguay | 2024
A MATLAB/Simulink simulation of a 4-motor coordinated control system for precision optical lens positioning. The system drives a lens along a pre-computed polar trajectory using independent PID-controlled DC and BLDC motors, with realistic physical effects including thermal dynamics, backlash, voltage saturation, and encoder feedback.
The machine positions an optical lens in polar coordinates (θ, r) using three coordinated actuators:
| Motor | Type | Axis | Control |
|---|---|---|---|
| Motor 1 | DC PMDC (12 V) | Angular position θ | PD |
| Motor 2 | DC PMDC (110 V) | Radial position r (ball screw) | PD |
| Motor 3 | BLDC (220 V) | Rotational speed ω (grinding) | PI |
| Motor 4 | DC PMDC (12 V) | Auxiliary / focus | P |
The lens contour is defined parametrically as a rounded rectangle and sampled into a setpoint sequence that the three main motors track simultaneously over a 100-second simulation window.
- Physical motor modeling — state-space models (armature circuit + mechanical dynamics) for all four motors, with temperature-dependent winding resistance
- Thermal dynamics — first-order thermal model (stator capacitance / thermal resistance) per motor
- PID control — gains designed via Ziegler-Nichols; interactive
pidTunerworkflow included - Stability analysis — open-loop pole computation, controllability/observability rank tests, closed-loop pole placement verification, phase and gain margins
- Derating — automatic gain reduction when stator temperature exceeds 75 % of the rated limit
- Backlash — gear backlash modelled in the Simulink plant
- Voltage saturation — supply-voltage clamps on all drive signals
- Current limiting — per-motor peak current constraints
- Encoder feedback — configurable PPR; sensor noise injection
- Discrete-time mode — full ZOH-discretised closed-loop model (
motor_1_2_3_discreto.slx) - Lens geometry generation — parametric polar-profile generator with adjustable corner radii
- MSE / max-error metrics — quantitative comparison between the commanded and achieved lens contour
Proyecto/
├── run.m # Entry point — run this file
├── run_flags.m # Simulation configuration flags
│
├── DC_Motor_params_01.m # Motor 1 parameters (12 V DC, angular axis)
├── DC_Motor_params_02.m # Motor 2 parameters (110 V DC, linear axis)
├── BLDC_Motor_params_03.m # Motor 3 parameters (220 V BLDC, speed axis)
├── DC_Motor_params_04.m # Motor 4 parameters (12 V DC, auxiliary)
│
├── Env_params.m # Environmental constants (g, etc.)
├── materiales.m # Material densities (AISI 316 steel)
├── filter_params.m # Sensor filter coefficients
├── noise_params.m # Noise variance parameters
├── derating.m # Thermal derating thresholds and current limits
│
├── std_matrixes.m # State-space matrices (A, B, C) for all motors
├── PID_tuning.m # PID gains + interactive pidTuner workflow
├── otros_errores.m # Modelling error bounds
│
├── verify_ol_model.m # Open-loop step-response verification
├── verify_cl_pid.m # Closed-loop PID verification (single motor)
├── est_contr_obs.m # Controllability, observability, open-loop poles
├── est_cl.m # Closed-loop poles and phase/gain margins
│
├── generar_lente.m # Parametric lens contour generator (polar)
├── elaborar_consignas.m # Arc-length resampling of the lens trajectory
├── consigna_a_lente.m # Radial coordinate mapping helper
├── intersect_ray_polygon.m # Ray–polygon intersection (optical path)
├── intersect_segments.m # Segment–segment intersection primitive
│
├── use_machine_1.m # Full 3-motor coordinated simulation + plots
├── use_solo_motor_1.m # Standalone Motor 1 simulation
├── use_solo_motor_2.m # Standalone Motor 2 simulation
├── use_solo_motor_3.m # Standalone Motor 3 simulation
├── use_solo_motor_4.m # Standalone Motor 4 simulation
├── sensor_test.m # Sensor noise and resolution analysis
│
├── control_y_sistemas_0.slx # Simulink: single-motor open-loop plant
├── control_y_sistemas_1.slx # Simulink: single-motor closed-loop plant
├── motor_1.slx … motor_4.slx # Simulink: individual closed-loop motor models
├── motor_1_2_3.slx # Simulink: 3-motor continuous-time system
├── motor_1_2_3_discreto.slx # Simulink: 3-motor discrete-time system
└── machine.slx # Simulink: full machine assembly
- MATLAB R2022b or newer
- Simulink
- Control System Toolbox
- Open MATLAB and set the working directory to
Proyecto/. - Edit
run_flags.mto select which analyses or simulations to run (see the table below). - Run
run.m.
>> cd('path/to/Proyecto')
>> run| Flag | Default | Description |
|---|---|---|
USE_MACHINE_1 |
1 |
Full 3-motor coordinated simulation |
DISCRETE |
1 |
Use discretised plant model |
VERIFY_OL_MODEL |
0 |
Open-loop step-response test (Motor 1) |
OL_STABILITY_ANALYSIS |
0 |
Controllability, observability, OL poles |
CL_STABILITY_ANALYSIS |
0 |
CL poles and gain/phase margins |
VERIFY_CL_PID |
0 |
PID step-response verification |
USE_SOLO_MOTOR_1..4 |
0 |
Run individual motor simulations |
BACKLASH |
1 |
Enable gear backlash |
DERATING |
1 |
Enable thermal derating |
CURRENT_LIMIT |
1 |
Enable current saturation |
ENABLE_SENSORS |
1 |
Use realistic encoder/sensor models |
TUNE_PID |
0 |
Switch to PID tuning mode |
TUNE_PID_DESIGN |
[0,0,0,0] |
Open pidTuner for each motor |
The main simulation (USE_MACHINE_1 = 1) produces:
- Setpoint tracking plots — angular position (Motor 1), linear position (Motor 2), and angular velocity (Motor 3) vs. time
- Armature currents — per motor, showing saturation events
- Stator temperatures — thermal evolution under load
- Lens contour comparison — commanded vs. achieved contour in Cartesian coordinates
- Error metrics — MSE and maximum radial error between commanded and achieved lens shape (printed to console)
| Motor 1 | Motor 2 | Motor 3 (BLDC) | Motor 4 | |
|---|---|---|---|---|
| Supply | 12 V | 110 V | 220 V | 12 V |
| L_a | 7.5 mH | 3 mH | 5 mH | 33.6 µH |
| R_a (20 °C) | 0.5 Ω | 0.25 Ω | 0.35 Ω | 0.108 Ω |
| k_t | 0.25 Nm/A | 0.56 Nm/A | 0.30 Nm/A | 0.016 Nm/A |
| Gear ratio | 25 : 1 | 5 : 1 | 2 : 1 | 51 : 1 |
| Controller | PD | PD | PI | P |
- Course: Control y Sistemas
- Institution: Facultad de Ingeniería (FING), Universidad de la República, Uruguay
- Year: 2024