pid_vs_lqr_ballandbeam
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
pid_vs_lqr_ballandbeam [2016/07/13 14:41] – joaomatos | pid_vs_lqr_ballandbeam [2016/07/13 14:59] (current) – joaomatos | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{ :: | + | ===== Lego Ball and Beam ===== |
**Keywords: | **Keywords: | ||
Line 21: | Line 21: | ||
===== Parts List and Source ===== | ===== Parts List and Source ===== | ||
- | . Parts List. | + | [[ballandbeam_parts|Parts List]] |
Line 36: | Line 36: | ||
===== System Modeling ===== | ===== System Modeling ===== | ||
- | . System Modeling. | + | . [[ballandbeam_modelling|System Modeling.]] |
Line 43: | Line 43: | ||
===== Programming ===== | ===== Programming ===== | ||
- | . Programming | + | . [[ballandbeam_code|Programming]] |
Line 49: | Line 49: | ||
- | **SUMMARY** | ||
- | PID CONTROL: | ||
- | #1:Ball and Beam Transfer Function Derivation. | ||
- | #2:Motor Transfer Function Derivation. | ||
- | #3:Motor system modeling on Simulink. | ||
- | # | ||
- | #5:Working Video / Simulating Disturbance. | ||
- | # | ||
- | #7:NXT CODE. | ||
- | LQR CONTROL: | ||
- | #8:State Space representation. | ||
- | #9:Motor Parameters. | ||
- | #10:LQR [A], | ||
- | #11:Matlab code to find [K] matrix. | ||
- | #12:LQR Control results. | ||
- | |||
- | PID VS LQR CONTROL: | ||
- | #13:PID vs LQR Control results. | ||
- | . | ||
- | |||
- | . | ||
- | ** __PID CONTROL__ ** | ||
- | We can analyze the whole system into two distinct transfer functions , one for the ball and beam , and one for the motor. After , we can analyze the whole system putting these two transfer functions together in a block diagram. | ||
- | |||
- | ** __Ball and Beam Transfer Function Derivation__** | ||
- | {{ :: | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | |||
- | ** __Motor Transfer Function Derivation__ ** | ||
- | |||
- | One easy way to get the motor' | ||
- | |||
- | {{:: | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | By the graphic response , we can assume the motor system as a second order system (because of the oscillatory and overshoot response). As known , a second order is characterized by two parameters , natural frequency (σ) and damping ratio (ξ).We can get these parameters by the following steps: | ||
- | |||
- | | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | We know that a second order transfer function is: | ||
- | |||
- | | ||
- | |||
- | So the motor' | ||
- | | ||
- | | ||
- | |||
- | ** __Motor system modeling on Simulink__ ** | ||
- | |||
- | We can simulate the motor system on Simulink and compare the result to the experimental result , to verify if the derivation is correct. | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | ** __SIMULATING THE WHOLE SYSTEM WITH PID CONTROL__ ** | ||
- | |||
- | We can simulate the whole system using the ball and beam together with the motor' | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | ** Working Video / Simulating Disturbance ** | ||
- | |||
- | | ||
- | |||
- | On the video ,was simulated first a heavy disturbance , and then two small disturbances. | ||
- | |||
- | ** Comparison Simulink vs Real System ** | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | ** NXT CODE ** | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | ** TUNING THE CODE ** | ||
- | |||
- | After introducing the file saving function and the necessary commands to get the data , the system response was slowed down. ( oscillating more than before ). So i made some tuning: | ||
- | * KP=1 and KD=0.60 | ||
- | * No waiting time inside the if statements | ||
- | * 50ms waiting before starting the control loop again. | ||
- | |||
- | The new result is: | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- | . | ||
- | |||
- | . | ||
- | |||
- | ** __LQR CONTROL__ ** | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | . | ||
- | |||
- | . | ||
- | |||
- | ** __PID VS LQR CONTROL__ ** | ||
- | |||
- | | ||
- | |||
- | *note here that both methods can show pretty similar results , hand-tuning the gains after the initial guess. The PID version of the controler was intended to stop the ball fast , the LQR version of the controller was intended to stop the ball without overshooting too much. Again , both methods can be adjusted to control the overshoot or the rise time. | ||
- | |||
- | | ||
- | |||
- | | ||
- | |||
- |
pid_vs_lqr_ballandbeam.1468446096.txt.gz · Last modified: by joaomatos