This repository contains the mathematical modeling, simulation scripts, and control system design files for an Inverted Pendulum semester project. The project explores both classical and modern control techniques, including PID controllers, root locus analysis, state-space representations, pole placement, and Linear-Quadratic Regulator (LQR) design with observer-based feedback—applied to an industrial mechatronic system.
The physical system relies on industrial components managed via a Schneider Electric PLC and motion servo drives:
-
Motor: Schneider Electric BSH AC Servomotor (
$0.9\text{ Nm}$ ,$6000\text{ RPM}$ , BSH0552T01A2A) - Datasheet / Product Link - Servo Drive: Lexium 32 Single-Phase Servo Drive (LXM32CU90M2) - Product Link
- Feedback Sensors: Kuebler Motion Control Encoders - RS Components | Kuebler Details
- Gearbox: Neugart Planetary Gearbox (PLE60) - Product Link
- Controller Unit: Schneider Electric Modicon TM241 PLC (TM241CEC24T) - Product Link (Help & Documentation)
- Safety Module: Modicon TM3 Safety Module (TM3SAF5R) - Product Link
- Analog Output Module: Modicon TM3 4-Output Module (TM3AQ4) - Product Link
The nonlinear dynamics of the cart-pendulum system are derived using Lagrangian mechanics in MATLAB (modellering.m, modelleringB.m, modelleringC.m, modelleringD.m).
-
Kinetic and Potential Energy: Formulated for cart mass
$M$ , pendulum mass$m$ , pendulum length$l$ , and moment of inertia$I$ . -
Linearization: The equations of motion are linearized around the upright unstable equilibrium point (
$\theta = \pi$ or$0$ depending on convention) using Jacobians to form the state-space matrices$(A, B, C, D)$ . -
Transfer Functions: Derived individual transfer functions for both the cart position (
$x$ ) and pendulum angle ($\phi$ ).
The project implements and simulates multiple control strategies:
-
Classical PID & Root Locus: Single-input, single-output (SISO) loops tuned via root locus (
rlocus) and automated tuning (pidtune) with discretization for PLC deployment ($T_s = 0.001\text{ s}$ ). -
Full-State Feedback & LQR: Optimal control weighting matrices (
$Q$ and$R$ ) configured to balance cart displacement tracking and pendulum stabilization, paired with precompensation scaling (rscale). - State Observers: Designed full-order observers via pole placement to estimate unmeasured states from sensor outputs.
modellering.m/modelleringC.m/modelleringD.m: Core symbolic derivation, Lagrangian formulation, Jacobian linearization, and state-space model generation.alternative_method.m: Transfer function modeling based on classical control references (e.g., University of Michigan control tutorials).Controlability.m/Observability.m: Controllability and observability matrix rank checks and canonical form transformations.Hardware.md: Datasheet references and configuration notes for physical Schneider Electric hardware.