Application Center - Maplesoft

App Preview:

Harmonic Oscillator

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

Harmonic Oscillator 

? Maplesoft, a division of Waterloo Maple Inc., 2008 

This application illustrates a second order harmonic oscillator under different control strategies. The proportional (P), proportional-integral (PI), and proportional-integral-derivative (PID) controller structures are shown. 

System Analysis 

Model Description 

P Controller 

PI Controller 

PID Controller 

Drawing-Canvas 

 

System Analysis 

The model corresponds to a second order system with u(t) as the input and y(t) as the output. The system is defined by the angular frequency omega, the attenuation theta, and the gain A. 

 

Input variable u(t) 

Output variable  

Parameters: 

Angular frequency omega 

Attenuation theta 

Gain A 

Model Description 

The system is defined with the following differential equation (DE): 

`+`(diff(y(t), t, t), `*`(2, `*`(omega, `*`(theta, `*`(diff(y(t), t))))), `*`(`^`(omega, 2), `*`(y(t)))) = `*`(`^`(omega, 2), `*`(A, `*`(u(t)))) 

`+`(diff(diff(y(t), t), t), `*`(2, `*`(omega, `*`(theta, `*`(diff(y(t), t))))), `*`(`^`(omega, 2), `*`(y(t)))) = `*`(`^`(omega, 2), `*`(A, `*`(u(t)))) (2.1)
 

 

The transfer function that results from this DE is: 

`:=`(Gs, DETransferFn(`+`(diff(diff(y(t), t), t), `*`(2, `*`(omega, `*`(theta, `*`(diff(y(t), t))))), `*`(`^`(omega, 2), `*`(y(t)))) = `*`(`^`(omega, 2), `*`(A, `*`(u(t)))), u(t), y(t), t, s)) 

`/`(`*`(`^`(omega, 2), `*`(A)), `*`(`+`(`*`(2, `*`(s, `*`(omega, `*`(theta)))), `*`(`^`(s, 2)), `*`(`^`(omega, 2))))) (2.2)
 

 

 

Button# Uncontrolled Step Response 

Embedded componenttheta 

Embedded component    omega 

 

Embedded component 

By changing the slider values for θ and ω, the step response for the corresponding system is displayed. 

 

In this example, θ controls the damping, such that a system with `<`(theta, 1) results in a system that is under damped and results in an overshoot.  For the cases with `>`(theta, 1)the system is over damped and the response has no overshoot.  If theta = 1 the system is critically damped, resulting in the fastest rise time of the system without overshooting the final value. The parameter ω is the natural frequency of the system. 

 

The amplitude A is set to 1 for this example. 

P Controller 

`:=`(CsP, Kr); -1 

 

Open Loop Transfer Function 

`:=`(GosP, `*`(CsP, `*`(Gs))) 

`/`(`*`(Kr, `*`(`^`(omega, 2), `*`(A))), `*`(`+`(`*`(2, `*`(s, `*`(omega, `*`(theta)))), `*`(`^`(s, 2)), `*`(`^`(omega, 2))))) (3.1)
 

 

Closed Loop Transfer Function 

`:=`(GcsP, simplify(`/`(`*`(GosP), `*`(`+`(1, GosP))))) 

`/`(`*`(Kr, `*`(`^`(omega, 2), `*`(A))), `*`(`+`(`*`(2, `*`(s, `*`(omega, `*`(theta)))), `*`(`^`(s, 2)), `*`(`^`(omega, 2)), `*`(Kr, `*`(`^`(omega, 2), `*`(A)))))) (3.2)
 

 

Button# P Controller Step Response 

 

 

 

Embedded component 

P 

Embedded component 

The values of the parameters theta and omega are obtained from the dial settings in the previous sections. 

By changing the value of the P gauge, the proportional controller gain is adjusted and the response is displayed. 

 

Note that the final value of the controlled system does not actually reach the desired final value. The controller has an offset error. 

 

PI Controller 

`:=`(CsPI, `/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))))), `*`(s, `*`(Tn)))) 

`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))))), `*`(s, `*`(Tn))) (4.1)
 

 

Open Loop Transfer Function 

`:=`(GosPI, `*`(CsPI, `*`(Gs))) 

`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`^`(omega, 2), `*`(A)))), `*`(s, `*`(Tn, `*`(`+`(`*`(2, `*`(s, `*`(omega, `*`(theta)))), `*`(`^`(s, 2)), `*`(`^`(omega, 2))))))) (4.2)
 

 

Closed Loop Transfer Function 

`:=`(GcsPI, simplify(`/`(`*`(GosPI), `*`(`+`(1, GosPI))))) 

`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`^`(omega, 2), `*`(A)))), `*`(`+`(`*`(2, `*`(`^`(s, 2), `*`(Tn, `*`(omega, `*`(theta))))), `*`(`^`(s, 3), `*`(Tn)), `*`(s, `*`(Tn, `*`(`^`(omega, 2)))), `*... (4.3)
 

 

Button# PI Controller Step Response 

 

Embedded component   P 

 Embedded component  Tn 

  

Embedded component 

By changing the value of the P dial (for the value of Kr) and the Tn slider, the proportional controller gain and the integral controller gains are adjusted and the response is displayed. 

 

Note that by adding the integral component to the proportional controller, the offset error can been eliminated. 

 

However, if the value of Tn is too small and combined with a relatively high P gain, the system may become unstable and begin oscillating out of control. 

PID Controller 

`:=`(CsPID, `/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`+`(1, `*`(s, `*`(`+`(Tv, Tc))))))), `*`(s, `*`(Tn, `*`(`+`(1, `*`(s, `*`(Tc)))))))) 

`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`+`(1, `*`(s, `*`(`+`(Tv, Tc))))))), `*`(s, `*`(Tn, `*`(`+`(1, `*`(s, `*`(Tc))))))) (5.1)
 

 

Open Loop Transfer Function 

`:=`(GosPID, `*`(CsPID, `*`(Gs))) 

`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`+`(1, `*`(s, `*`(`+`(Tv, Tc)))), `*`(`^`(omega, 2), `*`(A))))), `*`(s, `*`(Tn, `*`(`+`(1, `*`(s, `*`(Tc))), `*`(`+`(`*`(2, `*`(s, `*`(omega, `*`(theta))))... (5.2)
 

 

Closed Loop Transfer Function 

`:=`(GcsPID, simplify(`/`(`*`(GosPID), `*`(`+`(1, GosPID))))) 

`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`+`(1, `*`(s, `*`(Tv)), `*`(s, `*`(Tc))), `*`(`^`(omega, 2), `*`(A))))), `*`(`+`(`*`(2, `*`(`^`(s, 2), `*`(Tn, `*`(omega, `*`(theta))))), `*`(`^`(s, 3), `*...
`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`+`(1, `*`(s, `*`(Tv)), `*`(s, `*`(Tc))), `*`(`^`(omega, 2), `*`(A))))), `*`(`+`(`*`(2, `*`(`^`(s, 2), `*`(Tn, `*`(omega, `*`(theta))))), `*`(`^`(s, 3), `*...
`/`(`*`(Kr, `*`(`+`(1, `*`(s, `*`(Tn))), `*`(`+`(1, `*`(s, `*`(Tv)), `*`(s, `*`(Tc))), `*`(`^`(omega, 2), `*`(A))))), `*`(`+`(`*`(2, `*`(`^`(s, 2), `*`(Tn, `*`(omega, `*`(theta))))), `*`(`^`(s, 3), `*...
(5.3)
 

 

Button# PID Controller Step Response 

 

Embedded component   P  

 

Embedded component   Tn  

Embedded component 

By changing the value of the P slider and the Tn slider, the proportional controller gain and the integral controller gains are adjusted and the response is displayed. 

 

The values of Tv and Tc corresponding to the derivative controller are set as follows: 

 

`and`(Tv = `*`(Tn, `*`(Tc)), `*`(Tn, `*`(Tc)) = `+`(`*`(`/`(1, 10), `*`(Tn))))