Complete design, simulation, and hardware implementation of a non-linear controlled two-degree-of-freedom (2-DOF) planar robotic arm. The project covers mathematical modeling using the Euler–Lagrange formulation, non-linear stability analysis via Lyapunov methods, feedback linearization control synthesis, MATLAB/Simulink simulation, and real-time embedded implementation on an Arduino microcontroller.
Paper — Non-Linear Control of a 2-DOF Robotic Arm: Complete Design, Simulation, and Hardware Implementation (PDF)
Fully assembled 2-DOF robotic arm prototype with 3D-printed PLA+ links, 25GA370 DC gear motors, L298N driver, and Arduino Mega 2560.
- Overview
- Key Results
- Hardware
- Simulation Results
- Hardware Design
- Repository Structure
- MATLAB Workflow
- Arduino Workflow
- Authors
- References
- License
The system controls a planar 2-DOF arm with joint variables
A feedback linearization controller cancels all non-linear terms, producing a linearized closed-loop system. The control law computes:
with reference acceleration
Lyapunov stability is guaranteed via
| Metric | Value |
|---|---|
| Steady-state position error | < 0.01 rad |
| Circular trajectory phase error | < 0.02 rad |
| Amplitude error | < 1 % |
| Control loop rate | 100 Hz (10 ms) |
| Controllability rank | 4 (full) across entire workspace |
| Component | Specification |
|---|---|
| Motors | 25GA370 DC gear motor, 12 V, 50:1 gear ratio, 0.44 N·m stall torque |
| Encoders | Integrated quadrature, 550 counts/rev |
| Controller | Arduino Mega 2560 |
| Driver | L298N dual H-bridge (2.5–46 V, 2 A/channel) |
| Links | 3D-printed PLA+, SolidWorks-designed |
Two gain configurations were compared for step response (
| Characteristic | Low Gains ( |
High Gains ( |
|---|---|---|
| Overshoot | ~0.05 rad | ~0.01 rad |
| Settling time | ~3 s | ~1.5 s |
| Control effort | Low | High |
| Noise sensitivity | Low | High |
End-effector commanded to trace a circle of radius
Circular trajectory tracking: measured joint angles (solid) closely follow desired references (dashed) with minimal phase lag.
The full sequence (OFF → POSITION → CIRCLE) demonstrates seamless mode transitions managed by a Stateflow state machine:
Stateflow state machine governing mode transitions: OFF → POSITION → CIRCLE.
Closed-loop equilibrium response: joint angles converge to zero (top), velocities decay (middle), and control voltages settle (bottom).
SolidWorks CAD assembly showing both links, motor housings, and mounting points.
Left: 25GA370 DC gear motor with integrated quadrature encoder. Right: 6-pin encoder interface (Motor±, Encoder±, channels A/B).
1. Read encoder counts → compute joint angles: q = 2π · count / 550
2. Estimate velocities via filtered finite differences:
q̇_filt[k] = 0.7·q̇_filt[k-1] + 0.3·Δq/Ts
3. Evaluate state machine (OFF / POS / CIRCLE), generate references
4. Execute feedback linearization → compute τ_des → convert to PWM
5. Apply saturation (±12 V) → output to L298N
.
|-- matlab/
| |-- Advanced_trial.slx
| |-- init_params.m
| |-- check_controllability.m
| `-- check_nonlinear_controllability_lie.m
|-- arduino/
| |-- end_effector_circle/
| | `-- end_effector_circle.ino
| |-- joint_space/
| | `-- joint_space.ino
| |-- nonlinear_trajectory/
| | `-- nonlinear_trajectory.ino
| `-- nonlinear_trajectory_alt/
| `-- nonlinear_trajectory_alt.ino
`-- docs/
|-- Nonlinear_Control_2DOF_Arm.pdf
`-- figures/ # Extracted from the report
- Open MATLAB in the
matlab/directory. - Run
init_params.mto initialize arm and motor parameters. - Execute:
check_controllability.mcheck_nonlinear_controllability_lie.m
- Open
Advanced_trial.slxfor simulation and controller testing.
- Open one sketch folder under
arduino/in Arduino IDE. - Select the board and COM port matching your hardware.
- Upload one of the control sketches:
end_effector_circle.inojoint_space.inononlinear_trajectory.inononlinear_trajectory_alt.ino
nonlinear_trajectory_alt is preserved as an alternate trajectory/controller variant.
- This repository intentionally keeps multiple controller implementations to compare behavior across trajectory spaces and tuning choices.
- Update pin definitions and hardware constants in each sketch before deployment if your wiring differs.
| Name | Affiliation |
|---|---|
| Ahmed Mostafa | Mechatronics Engineering, GUC |
| Andrew Abdelmalak | Mechatronics Engineering, GUC |
| Hazim Alwakad | Mechatronics Engineering, GUC |
| Mazen Amr | Mechatronics Engineering, GUC |
| Samir Yacoub | Mechatronics Engineering, GUC |
| Youssef Youssry | Mechatronics Engineering, GUC |
The authors thank Prof. Ayman A. El-Badawy and Eng. Karim Abdelsalam for their guidance and instruction throughout this project.
The full project report is available in docs/Nonlinear_Control_2DOF_Arm.pdf.
- J. E. Slotine and W. Li, Applied Nonlinear Control, Prentice-Hall, 1991.
- M. W. Spong, S. Hutchinson, and M. Vidyasagar, Robot Modeling and Control, 2nd ed., Wiley, 2020.
- B. Siciliano et al., Robotics: Modelling, Planning and Control, Springer, 2009.
- A. A. El-Badawy, "Advanced Mechatronics Tutorial Notes," GUC, 2025.
- Ampere Electronics, "25GA370 DC gear motor with encoder specifications," 2023.
- V. H. Benitez et al., "Design of an affordable IoT open-source robot arm for online teaching," HardwareX, 8, 2020.
Released under the MIT License. See LICENSE.






