The main goal is to compare the performance of a fixed-parameter controller versus a controller that uses Recursive Least Squares (RLS) estimation to adapt online to the plant parameters.
This project is a complete end-to-end practical demonstration of a control system — from theoretical modeling to hardware implementation.
- System Modeling: Derivation of the transfer function for a first-order RC circuit.
- Digital Control: Discretization of a continuous-time system G(s) into a discrete-time model G(z) using the step-invariance method.
-
Controller Design:
-
Traditional Dahlin: Calculation of a discrete-time controller to meet first-order closed-loop response specifications
$K'=1$ ,$\tau'=\tau/2$ . - Adaptive Dahlin (STR): Implementation of a self-tuning controller.
-
Traditional Dahlin: Calculation of a discrete-time controller to meet first-order closed-loop response specifications
-
Adaptive Systems: Use of the Recursive Least Squares (RLS) method with a forgetting factor
$\lambda$ to estimate the plant parameters$a_1, b_1$ in real time. - Simulation: MATLAB/Octave used to simulate and validate the closed-loop controller behavior.
- Practical Implementation (Hardware-in-the-loop): Experimental validation of the designed controllers using an Arduino Mega and Octave platform.
The project was divided into three main stages:
The plant is an RC circuit. From nodal analysis, the following continuous-time transfer function was derived:
Using nominal values (
- Gain: K ≈ 0.5043
-
Time constant:
$\tau$ ≈ 2.2118 s
With a sampling period
has parameters:
Designed for a closed-loop response with K' = 1 and
The resulting difference equation of the controller is:
(Caption: Controller Structure)
This controller implements the same logic, but the parameters
They are estimated at each time step n by the RLS estimator, producing
These estimates are used to recalculate the controller gains in real time:
Where
Both controllers were simulated and tested on the real plant.
The plot below shows the convergence of the estimated parameters
The fast convergence validates the effectiveness of the RLS estimator.
(Caption: Evolution of estimated parameters)
The most significant result comes from the practical Arduino experiment.
The plot compares the plant’s open-loop response with the Traditional Dahlin and the Adaptive Dahlin controllers.
(Caption: Real system responses – open loop vs. traditional Dahlin vs. adaptive Dahlin)
Both controllers successfully track the reference, unlike the open-loop system.
The Adaptive Dahlin controller exhibits a noticeably faster and more aggressive response, with a shorter settling time during step transitions.
The Traditional Dahlin controller is smoother but shows a larger overshoot in the practical test — something the adaptive controller managed to compensate for.
- Controller_Dahlin.m – Simulation script for the Traditional Dahlin Controller
- adaptative_Controller_Dahlin.m – Simulation script for the Adaptive Dahlin Controller with RLS
/pratic_test– Contains scripts and.matdata files for the practical Arduino implementation
- Clone this repository.
- Open MATLAB or Octave.
- Run
/Controller_Dahlin.mto simulate the traditional controller. - Run
/adaptative_Controller_Dahlin.mto simulate the adaptive controller.
- The practical experiment requires Arduino Mega hardware.
- The scripts in the
/pratic_testfolder are used to compute the control signal and send it to the Arduino via Serial communication.


