루덴스코드 Blog

[START]

USB 를 이용한 기본 실험환경를 만들어 본다.

PC 에서 USB 를 사용해 외부 소형 보드에 연결하고, 보드에 붙어있는 LED 를 켜고 끄는 작업을 진행한다.


[참고사이트]

  1. FTDI 사이트
    1. http://www.ftdichip.com/
    2. USB 사용할 수 있는 칩제조사
    3. Evaluation Board 자료가 있다.
    4. FT245R, FT245BM 에 대한 자료
    5. http://www.ftdichip.com/Drivers/VCP.htm
    6. VCP (Virtual Com Port) Driver URL, D2XX Drivers URL,
  2. DLP Design
    1. http://www.dlpdesign.com/
    2. Visual C++ 사용한 소스코드제공
    3. http://www.dlpdesign.com/usb/usb245.shtml
  3. M2CV (국내회사)
    1. http://www.m2cv.co.kr/
    2. FT245 USB Module
    3. DLP Design 의 DLP-USB232M-G 과 동일
  4. 디바이스마트
    1. http://www.devicemart.co.kr/
    2. FT245 로 검색하면 관련 칩과 모듈이 검색됨

결론 : (잠정적)

회로도와 부품들을 살펴보고 PCB를 제작, 직접 모듈을 제작할 수도 있으나 부품을 구하기가 번거롭고, 제작시 칩형 부품들의 납땜에 에러가 발생할 것이 우려되어 모듈을 직접 구입하여 동작시켜 보기로 한다.


M2CV









DLP Design



FTDI














USB 를 이용한 제어 실험 - 첫번째
http://electoy.tistory.com/132
JelicleLim(2008.10.10)

Comment +0

Ball and Beam problem using PID Control

In this digital control version of the ball and beam experiment, we are going to use the PID control method to design the digital controller. If you refer to the Ball and Beam Modeling page, the open-loop transfer function was derived as
사용자 삽입 이미지
.....m........mass of the ball...............0.11 kg
.....g........gravitational acceleration.....9.8 m/s^2
.....d........lever arm offset...............0.03 m
.....L........length of the beam.............1.0 m
.....R........radius of the ball.............0.015 m
.....J........ball's moment of inertia.......9.99e-6 kgm^2
.....R(s).....ball position coordinate (m)
.....theta(s).servo gear angle...............0.25 rad

The design criteria for this problem are:
  • Settling time less than 3 seconds
  • Overshoot less than 5%
Digital PID controller
If you refer to any of the PID control problem for continuous systems, the PID transfer function was expressed as
사용자 삽입 이미지
As you noticed the above transfer function was written in terms of s. For the digital PID control, we use the following transfer function in terms of z.
사용자 삽입 이미지
Discrete transfer function
The first thing to do here is to convert the above continuous system transfer function to discrete transfer function. To do this, we are going to use the Matlab function called c2dm. To use this c2dm, we need to specify four arguments: numerator and denominator matrices, sampling time (Ts), and the 'method'. You should already be familiar with how to enter numerator and denominator matrices. The sampling time should be smaller than 1/(30*BW) sec, where BW is the closed-loop bandwidth frequency. The method we will use is the zero-order hold ('zoh'). Assuming that the closed-loop bandwidth frequency is around 1 rad/sec, let the sampling time be 1/50 sec/sample. Now we are ready to use c2dm. Enter the following commands to an m-file.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....Ts = 1/50;

.....[numDz,denDz]= c2dm (num,den,Ts,'zoh')

Running this m-file in the Matlab command window gives you the following matrices.

.....numDz =
..........1.0e-0.4 *
..........0    0.4200    0.4200

.....denDz =
..........1    -2    1

From these matrices, the discrete transfer function can be written as
사용자 삽입 이미지
Open-loop response
Now we will observe the ball's response to a step input of 0.25 m. To do this, enter the following commands to an new m-file and run it in the command window. You should see the following response.

.....numDz = 0.0001*[0.42 0.42];
.....denDz = [1 -2 1];

.....[x] = dstep(0.25*numDz,denDz,251);
.....t=0:0.02:5;
.....stairs(t,x)
사용자 삽입 이미지
From this plot, it is clear that the open-loop system is unstable causing the ball to roll off from the end of the beam.

Proportianal Control
Now we will add the proportional control (Kp) to the system and obtain the closed-loop system response. For now let Kp equal to 100 and see what happens to the response. Enter the following commands to an new m-file and run it in the command window.

.....numDz = 0.0001*[0.42 0.42];
.....denDz = [1 -2 1];

.....Kp=100;
.....[numDzC,denDzC]=cloop (Kp*numDz,denDz);

.....[x] = dstep(0.25*numDzC,denDzC,251);
.....t=0:0.02:5;
.....stairs(t,x)
사용자 삽입 이미지
As you can see, the addition of proportional control does not make the system stable. You may try to increase the proportional gain (Kp) and confirm that the system remains unstable.

Proportional-Derivative control
Now we will add a derivative term to the controller. Keep the proportional gain (Kp) equal to 100, and let the derivative gain (Kd) equal to 10. Copy the following code to an new m-file and run it to view the system response.

.....numDz = 0.0001*[0.42 0.42];
.....denDz = [1 -2 1];
.....Kp=100;
.....Kd=10;
.....numpd = [Kp+Kd -(Kp+2*Kd) Kd];
.....denpd = [1 1 0];
.....numDnew = conv(numDz,numpd);
.....denDnew = conv(denDz,denpd);
.....[numDnewC,denDnewC] = cloop(numDnew,denDnew);
.....[x] = dstep(0.25*numDnewC,denDnewC,251);
.....t=0:0.02:5;
.....stairs(t,x)
사용자 삽입 이미지
Now the system is stable, but the rise time is too long. From the PID Tutorial page, we see that the increasing the proportional gain (Kp) will decrease the rise time. Let's increase the proportional gain (Kp) to 1000 and see what happens. Change Kp in the above m-file from 100 to 1000 and rerun it in the command window. You should see the following step response.
사용자 삽입 이미지
As you can see, all of the design requirements are satisfied. For this particular problem, no implementation of an integral control was needed. But remember there is more than one solution for a control problem. For practice, you may try different P, I and D combinations to obtain a satisfactory response.

Comment +0

Ball & Beam Problem Using the State-space Design Method

The state-space representation of the ball and beam example is given below:
사용자 삽입 이미지
Remember, unlike the previous examples where we controlled the gear's angle to control the beam and ball, here we are controlling alpha-doubledot. By doing this we are essentially controlling a torque applied at the center of the beam by a motor. Therefore, we do not need a gear and lever system.

The design criteria for this problem are:
  • Settling time less than 3 seconds
  • Overshoot less than 5%
To see the derivation of the state-space equations for this problem refer to the ball and beam modeling page.

If you are interested in running an animation of this example based on the control techniques used in the state-space tutorial please go to the Ball & Beam Animation Page after completing this tutorial.

Full-State Feedback Controller

We will design a controller for this physical system that utilizes full-state feedback control. A schematic of this type of system is shown below:
사용자 삽입 이미지
Recall, that the characteristic polynomial for this closed-loop system is the determinant of (sI-(A-BK)), where s is the Laplace variable. For our system the A and B*K matrices are both 4x4. Hence, there should be four poles for our system. In designing our full-state feedback controller we can move these poles anywhere we want.

For our design we desire an overshoot of less than 5% which corresponds to a zeta of 0.7 (please refer to your textbook for the relationship between overshoot and damping ratio). On a root locus this criterion is represented as a 45 degree line emanating from the origin and extending out into the left-half plane. We want to place our poles on or beneath this line. Our next criterion is a settling time less than 3 seconds, which corresponds to a sigma = 4.6/Ts = 4.6/3 = 1.53, represented by a vertical line at -1.53 on the root locus. Anything beyond this line in the left-half plane is a suitable place for our poles. Therefore we will place our poles at -2+2i and -2-2i. We will place the other poles far to the left for now, so that they will not affect the response too much. To start with place them at -20 and -80. Now that we have our poles we can use Matlab to find the controller (K matrix) by using the place command. Copy the following code to an m-file to model the system and find the K matrix:

NOTE: Matlab commands from the control system toolbox are highlighted in red.


.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....J = 9.99e-6;

.....H = -m*g/(J/(R^2)+m);
         
.....A=[0 1 0 0
........0 0 H 0
........0 0 0 1
........0 0 0 0];
.....B=[0;0;0;1];
.....C=[1 0 0 0];
.....D=[0];

.....p1=-2+2i;
.....p2=-2-2i;
.....p3=-20;
.....p4=-80;

.....K=place(A,B,[p1,p2,p3,p4])

Run your m-file and you should get the following output for the K matrix:

.....place: ndigits= 15

.....K =
..........1.0e+03 *
..........1.8286    1.0286    2.0080    0.1040

After adding the K matrix, the state space equations now become:
사용자 삽입 이미지
We can now simulate the closed-loop response to a 0.25m step input by using the lsim command. Add the following to your m-file:

.....T = 0:0.01:5;                  
.....U = 0.25*ones(size(T));             
.....[Y,X]=lsim(A-B*K,B,C,D,U,T);     
.....plot(T,Y)

Run your m-file and you should get the following plot:
사용자 삽입 이미지
From this plot we see that there is a large steady state error for which we will need to add reference input (explained in next section). However, the overshoot and settling time criteria are met. If we wanted to reduce the overshoot further than we would make the imaginary part of the pole smaller than the real part. Also, if we wanted a faster settling time we would move the poles further in the left-half plane. Feel free to experiment with the pole positions to see these trends.

Reference Input
Now we want to get rid of the steady-state error. In contrast to the other design methods, where we feedback the output and compare it to the reference input to compute an error, with a full-state feedback controller we are feeding back both states. We need to compute what the steady-state value of the states should be, multiply that by the chosen gain K, and use a new value as our reference for computing the input. This can be done by adding a constant gain Nbar after the reference. The schematic below shows this relationship:
사용자 삽입 이미지
Nbar can be found using the user-defined function rscale (copy it to the directory that your m-file is in). Copy the following to your m-file and run it to view the step response with Nbar added.

.....Nbar=rscale(A,B,C,D,K)

.....T = 0:0.01:5;                  
.....U = 0.25*ones(size(T));             
.....[Y,X]=lsim(A-B*K,B*Nbar,C,D,U,T);     
.....plot(T,Y)

Note: Non-standard Matlab commands used in this example are highlighted in green.

Your output should be:

.....place: ndigits= 15
.....Nbar =
..........1.8286e+03
사용자 삽입 이미지
Now the steady-state error is gone and all the design criteria are satisfied.

Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. For practice you may want to go back and try to change the pole positions to see how the system responds.

Comment +0

Ball & Beam Problem Using Frequency Response Method

The open-loop transfer function of the plant for the ball and beam experiment is given below:
사용자 삽입 이미지
The design criteria for this problem are:
  • Settling time less than 3 seconds
  • Overshoot less than 5%
To see the derivation of the equations for this problem refer to the ball and beam modeling page. A schematic of the closed loop system with a controller is given below:
사용자 삽입 이미지

Open-loop Bode Plot
The main idea of frequency based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot, therefore changing the closed-loop response. Let's first draw the bode plot for the original open-loop transfer function. Create an m-file with the following code and then run it in the Matlab command window:

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....bode(num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.


You should get the following Bode plot:
사용자 삽입 이미지
From this plot we see that the phase margin is zero. Since the phase margin is defined as the change in open-loop phase shift necessary to make a closed-loop system stable this means that our zero phase margin indicates our system is unstable. We want to increase the phase margin and we can use a lead compensator controller to do this. For more information on Phase and Gain margins please refer to the Frequency Response Tutorial.

Phase-Lead Controller
A first order phase-lead compensator has the form given below:
사용자 삽입 이미지

The phase-lead compensator will add positive phase to our system over the frequency range 1/aT and 1/T, which are called the corner frequencies. The maximum added phase for one lead compensator is 90 degrees. For our controller design we need a percent overshoot of 5, which corresponds to a zeta of 0.7. Generally zeta * 100 will give you the minimum phase margin needed to obtain your desired overshoot. Therefore we require a phase margin greater than 70 degrees.

To obtain "T" and "a", the following steps can be used.

1. Determine the positive phase needed:

      We need at least 70 degrees from our controller.

2. Determine the frequency where the phase should be added (center frequency):

      In our case this is difficult to determine because the phase vs. frequency graph in the bode plot is a flat line. However, we have a relation between bandwidth frequency (wbw) and settling time (refer to the Bandwidth Frequency page for this equation) which tells us that wbw is approximately 1.92 rad/s. Therefore we want a center frequency just before this. For now we will choose 1.

3. Determine the constant "a" from the equation below, this determines the required space between the zero and the pole for the maximum phase added.
사용자 삽입 이미지
.....where phi refers to the desired phase margin. For 70 degrees, a = 0.0311.

4. Determine "T" and "aT" from the following equations:
사용자 삽입 이미지
사용자 삽입 이미지
..... For 70 degrees and center frequency (w) = 1, aT = 0.176 and T = 5.67

Now, we can add our lead controller to the system and view the bode plot. Remove the bode command from your m-file and add the following:

.....k=1;
.....numlead = k*[5.67 1];
.....denlead = [0.176 1];

.....numl = conv(num,numlead);
.....denl = conv(den,denlead);

.....bode(numl,denl)

You should get the following bode plot:
사용자 삽입 이미지

You can see that our phase margin is now 70 degrees. Let's check the closed-loop response to a step input of 0.25m. Add the following to your m-file:

.....[numcl,dencl] = cloop(numl,denl);
.....t=0:0.01:5;
.....step(0.25*numcl,dencl,t)

You should get the following plot:
사용자 삽입 이미지
Although the system is now stable and the overshoot is only slightly over 5%, the settling time is not satisfactory. Increasing the gain will increase the crossover frequency and make the response faster. Make k = 5, your response should look like:
사용자 삽입 이미지
사용자 삽입 이미지
The response is faster, however, the overshoot is much too high. Increasing the gain further will just make the overshoot worse.

Adding More Phase
We can increase our phase-lead compensator to decrease the overshoot. In order to make the iterative process easier use the following program. Create an m-file and copy the function from your web-browser into it (make sure the function command starts in the first column of the m-file).

.....function[ ] = phaseball()

.....%define TF
.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....%ask user for controller information
.....pm = input('Phase Margin?.......');
.....w  = input('Center Frequency?...');
.....k  = input('Gain?...............');

.....%view compensated system bode plot
.....pmr = pm*pi/180;
.....a = (1 - sin(pmr))/(1+sin(pmr));
.....T = sqrt(a)/w;
.....aT = 1/(w*sqrt(a));

.....numlead = k*[aT 1];
.....denlead = [T 1];

.....numl=conv(num,numlead);
.....denl=conv(den,denlead);
.....figure
.....bode(numl,denl)

.....%view step response
.....[numcl,dencl]=cloop(numl,denl);
.....t=0:0.01:5;
.....figure
.....step(0.25*numcl,dencl,t)

With this m-file you can choose the phase margin, center frequency, and gain. Run your m-file with the following values and you should see the plots below on your screen.

.....Phase Margin?.......80
.....Center Frequency?...1
.....Gain?...............1
사용자 삽입 이미지
사용자 삽입 이미지
The overshoot is fine but the settling time is just a bit long. Try different numbers and see what happens.

Using the following values the design criteria was met.

.....Phase Margin?.......85
.....Center Frequency?...1.9
.....Gain?...............2
사용자 삽입 이미지
사용자 삽입 이미지
Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. For practice you may want to go back and change the added phase, gain, or center frequency.

Comment +0

Solution to the Ball & Beam Problem Using Root Locus Method

The open-loop transfer function of the plant for the ball and beam experiment is given below:

사용자 삽입 이미지
The design criteria for this problem are:
  • Settling time less than 3 seconds
  • Overshoot less than 5%

To see the derivation of the equations for this problem refer to the ball and beam modeling page. A schematic of the closed loop system with a controller is given below:

사용자 삽입 이미지

Open-loop Root Locus

The main idea of the root locus design is to estimate the closed-loop response from the open-loop root locus plot. By adding zeroes and/or poles to the original system (adding a compensator), the root locus and thus the closed-loop response will be modified. Let us first view the root locus for the plant in open loop. Create an m-file with the following Matlab code in order to model the plant and plot the root locus.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....rlocus(num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

Now, run the m-file and you should see the following root locus plot:

사용자 삽입 이미지
As you can see the system has two poles at the origin which go off to infinity along the imaginary axes.

The design criteria can also be plotted onto the root locus using the sgrid command. This command generates a grid of constant damping ratio and natural frequency. The damping ratio and natural frequency were found using the following equation, which relates the them to our percent overshoot (PO) and settling time (Ts) requirements:

사용자 삽입 이미지
사용자 삽입 이미지
Note, that the equation with Ts is found by assuming settled is when the response remains within 2% of it's final value. From these equation damping ratio and natural frequency were found to be 0.7 and 1.9 respectively.

.....sgrid(0.70, 1.9)
.....axis([-5 5 -2 2])

사용자 삽입 이미지
The area between the two dotted diagnol lines represents locations where the percent overshoot is less than 5%. The area outside the curved line represents locations where the setttling time is less than 3 seconds. Note that no region of the plot falls within the design criteria shown be these lines. To remedy this and bring the root locus into the left-hand plane for stability we will try adding a lead-compensator to the system.

Lead Controller
A first order lead compensator tends to shift the root locus into the left-hand plane. For a more detailed description of lead compensators refer to the Lead & Lag Compensator Design page. A lead compensator has the form given below:

사용자 삽입 이미지
where, the magnitude of zo is less than the magnitude of po.

Now, let us add the controller to the plant and view the root locus. We will position the zero near the origin to cancel out one of the poles. The pole of our compensator will be placed to the left of the origin to pull the root locus further into the left-hand plane. Add the following lines of Matlab code to your m-file.

.....zo = 0.01;
.....po = 5;

.....numlead = [1 zo];
.....denlead = [1 po];

.....numl = conv(num,numlead);
.....denl = conv(den,denlead);

.....rlocus(numl,denl)
.....sgrid(0.70, 1.9)


Run your m-file in the Matlab command window and you should see the following:

사용자 삽입 이미지
Now, the branches of the root locus are within our design criteria.

Selecting a Gain
Now that we have moved the root locus into the left-hand plane, we may select a gain that will satisfy our design requirements. We can use the rlocfind command to help us do this. Add the following onto the end of your m-file.

.....[kc,poles]=rlocfind(numl,denl)

Go to the plot and select a point near those indicated by the cross mark on the plot below:

사용자 삽입 이미지
You should see in the Matlab command window something similar to the following (your numbers will be slightly different):


.....selected_point =
.....  -2.4988+ 1.2493i
 
.....kc =
.....   37.3131
 
.....poles =
.....  -2.4950+ 1.2493i
.....  -2.4950- 1.2493i
.....  -0.0101       


Now, we can plot the response with this gain.

Plotting the Closed-loop Response
This value of kc can be put into the system and the closed-loop response to a step input of 0.25 m can be obtained. Add the following lines to your m-file to perform this analysis.

.....numl2 = kc*numl;
.....[numcl,dencl] = cloop(numl2,denl);
.....t=0:0.01:5;
.....figure
.....step(0.25*numcl,dencl,t)

Run your m-file and you select a point on the root locus similar to the selected point above. The step response should look like the following:

사용자 삽입 이미지
From this plot we see that when a 0.25m step input is given to the system both the settling time and percent overshoot design criteria are met.
Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. Try running your m-file several more times selecting a different point each time and study the effect this has on the step response. For practice you may also want to go back to the original open-loop root locus and try to find other ways to add zeros and poles to get a better response.

Comment +0

Solution to the Ball & Beam Problem Using PID Control

The open-loop transfer function of the plant for the ball and beam experiment is given below:

사용자 삽입 이미지
The design criteria for this problem are:
  • Settling time less than 3 seconds
  • Overshoot less than 5%

To see the derivation of the equations for this problem refer to the ball and beam modeling page.


Closed-loop Representation
The block diagram for this example with a controller and unity feedback of the ball's position is shown below:

사용자 삽입 이미지
First, we will study the response of the system shown above when a proportional controller is used. Then, derivative and/or integral control will be added if necessary.

Recall, that the transfer function for a PID controller is:

사용자 삽입 이미지

Proportional Control
The closed-loop transfer function for proportional control with a proportional gain (kp) equal to 100, can be modeled by copying the following lines of Matlab code into an m-file (or a '.m' file located in the same directory as Matlab)

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....kp = 1;
.....numP = kp*num;

.....[numc, denc] = cloop(numP, den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

You numerator and denominator should be:

.....numc =..... 
.....         0         0    0.2100

.....denc =
.....    1.0000         0    0.2100

Now, we can model the system's response to a step input of 0.25 m. Add the following line of code to your m-file and run it:

.....step(0.25*numc,denc)

You should get the following output:

사용자 삽입 이미지
As, you can see the addition of proportional gain does not make the system stable. Try changing the value of kp and note that the system remains unstable.

Proportional-Derivative Control
Now, we will add a derivative term to the controller. Copy the following lines of code to an m-file and run it to view the system's response to this control method.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....kp = 10;
.....kd = 10;
.....numPD = [kd kp];

.....numh = conv(num, numPD);
.....[numc, denc] = cloop(numh, den);
.....t=0:0.01:5;
.....step(0.25*numc,denc,t)

Your plot should be similar to the following:

사용자 삽입 이미지
Now the system is stable but the overshoot is much too high and the settling time needs to go down a bit. From the PID tutorial page in the section on characteristics of P, I, and D controllers, we see that by increasing kd we can lower overshoot and decrease the settling time slightly. Therefore, make kd = 20 in your m-file and run it again. Your output should be:
사용자 삽입 이미지
The overshoot criterion is met but the settling time needs to come down a bit. To decrease the settling time we may try increasing the kp slightly to increase the rise time. The derivative gain (kd) can also be increased to take off some of the overshoot that increasing kp will cause. After playing with the gains a bit, the following step response plot can be achieved with kp = 15 and kd = 40:
사용자 삽입 이미지
As you can see from the above plot all the control objectives have been met without the use of an integral controller (settling time for this example is considered achieved when the response is less than 2% of it's final value). Remember, that for a control problem there is more than one solution for the problem.

Comment +0

VIA[CTM]

Modeling the Ball and Beam Experiment

Problem Setup

A ball is placed on a beam, see figure below, where it is allowed to roll with 1 degree of freedom along the length of the beam. A lever arm is attached to the beam at one end and a servo gear at the other. As the servo gear turns by an angle theta, the lever changes the angle of the beam by alpha. When the angle is changed from the vertical position, gravity causes the ball to roll along the beam. A controller will be designed for this system so that the ball's position can be manipulated.

사용자 삽입 이미지



For this problem, we will assume that the ball rolls without slipping and friction between the beam and ball is negligible. The constants and variables for this example are defined as follows:

  • M.........mass of the ball  0.11 kg 
  • R.........radius of the ball  0.015 m 
  • d.........lever arm offset  0.03 m 
  • g.........gravitational acceleration  9.8 m/s^2 
  • L.........length of the beam  1.0 m 
  • J.........ball's moment of inertia  9.99e-6 kgm^2 
  • r.........ball position coordinate  
  • alpha.....beam angle coordinate  
  • theta.....servo gear angle  

The design criteria for this problem are:

  • Settling time less than 3 seconds
  • Overshoot less than 5%


System Equations

The Lagrangian equation of motion for the ball is given by the following:

사용자 삽입 이미지
Linearization of this equation about the beam angle, alpha = 0, gives us the following linear approximation of the system:
사용자 삽입 이미지
The equation which relates the beam angle to the angle of the gear can be approximated as linear by the equation below:
사용자 삽입 이미지

Substituting this into the previous equation, we get:

사용자 삽입 이미지

1. Transfer Function
Taking the Laplace transform of the equation above, the following equation is found:

사용자 삽입 이미지

NOTE: When taking the Laplace transform to find the transfer function initial conditions are assumed to be zero.

Rearranging we find the transfer function from the gear angle (theta(s)) to the ball position (R(s)).

사용자 삽입 이미지
It should be noted that the above plant transfer function is a double integrator. As such it is marginally stable and will provide a challenging control problem.

2. State-Space
The linearized system equations can also be represented in state-space form. This can be done by selecting the ball's position (r) and velocity (rdot) as the state variables and the gear angle (theta) as the input. The state-space representation is shown below:

사용자 삽입 이미지
However, for our state-space example we will be using a slightly different model. The same equation for the ball still applies but instead of controlling the position through the gear angle, theta, we will control alpha-doubledot. This is essentially controlling the torque of the beam. Below is the representation of this system:
사용자 삽입 이미지
사용자 삽입 이미지
Note: For this system the gear and lever arm would not be used, instead a motor at the center of the beam will apply torque to the beam, to control the ball's position.


Matlab Representation and Open-Loop Response


1. Transfer Function

The transfer function found from the Laplace transform can be implemented in Matlab by inputting the numerator and denominator as vectors. To do this we must create an m-file and copy the following text into it:

.......m = 0.111;
.......R = 0.015;
.......g = -9.8;
.......L = 1.0;
.......d = 0.03;
.......J = 9.99e-6;

.......K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.......num = [-K];
.......den = [1 0 0];
.......printsys(num,den)

Your output should be:

.......num/den =   0.21 / ( s^2 )

Now, we would like to observe the ball's response to a step input of 0.25 m. To do this you will need to add the following line to your m-file:

.......step(0.25*num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

You should see the following plot showing the balls position as a function of time:

사용자 삽입 이미지
From this plot it is clear that the system is unstable in open-loop causing the ball to roll right off the end of the beam. Therefore, some method of controlling the ball's position in this system is required. Three examples of controller design are listed below for the transfer function problem. You may select from PID, Root Locus, and Frequency Response.

2. State-Space
The state-space equations can be represented in Matlab with the following commands (these equations are for the torque control model).

.......m = 0.111;
.......R = 0.015;
.......g = -9.8;
.......J = 9.99e-6;

.......H = -m*g/(J/(R^2)+m);
  
.......A=[0 1 0 0
.......   0 0 H 0
.......   0 0 0 1
.......   0 0 0 0];
.......B=[0;0;0;1];
.......C=[1 0 0 0];
.......D=[0];

The step response to a 0.25m desired position can be viewed by running the command below:

.......step(A,B*.25,C,D)

Your output should look like the following:

사용자 삽입 이미지
Like the plot for the transfer function this plot shows that the system is unstable and the ball will roll right off the end of the beam. Therefore, we will require some method of controlling the ball's position in this system. The State-Space example below shows how to implement a controller for this type of system.

Comment +0

기본적인 문제 중 하나다.
F(s)가 주어졌을때 어떻게 시간함수인 f(t)를 구할것인지에 대한 한 예제의 풀이과정이다.

사용자 삽입 이미지

개별근을 가질 경우는 풀이가 쉽다. 중근을 가질 경우 풀이가 어렵다기 보다는 한번 더 생각하면 된다. 보통 미분을 이용해서 풀이하지만 여기서는 문제의 특성상 간단한 대입으로 K1, K2, K3 를 구할 수 있다.

사용자 삽입 이미지

K1, K2, K3 를 구했으면 그것으로 F(s)를 위와 같은 모습으로 재구성하고 각각에 대해서 라플라스 역변환을 한다. 역변환의 기본 공식은 위의 공식을 참조하면 된다. 선형성을 가지므로 각각에 대한 라플라스 역변환을 거친 후 다시 더하면 최종적으로 구하고자 하는 값이 된다.

사용자 삽입 이미지

F(s) 의 라플라스 역변환 된 시간 함수 f(t)는 위와 같이 정해진다.

라플라스 역변환 풀이
http://electoy.tistory.com/108
JelicleLim(2008.7.19)

Comment +2

사용자 삽입 이미지

라플라스변환은 시간영역에서 해를 구하기 어려운 미분방정식의 경우 보다 간단한 대수방정식으로 그 해를 구할 수 있게 해주는 특징을 가진다. 즉 복잡한 미분방정식의 해를 직접 구하기보다는 그 방정식을 라플라스 트랜스폼으로 변환시켜 주파수 영역에서 대수방정식으로 만들어 해를 구하고 그것의 역변환을 취해 최종적인 시간영역에서의 해를 구하게 된다.

함수 f(t)의 라플라스 변환은 모든 실수 t ≥ 0 에 대해, 다음과 같은 함수 F(s)로 정의된다.

    F(s) = amath L { f } (s) = \int_{0^-}^\infty e^(-s*t) f(t) dt endamath

이때 amath  0^- 는 lim_{epsi->+0} -epsi endamath 의 약자이다. 실제 사용시에는 엄밀히 정확하지는 않은 다음의 표기를 사용하기도 한다.

    F(s) = amath L { f(t) }  = \int_{0^-}^\infty e^(-s*t) f(t) dt endamath

보통은 Lapalece 변환의 정의를 다음과 같이 사용한다.

...`L[f(t)] = F(s) = \int_0^\infty f(t) e^(-st) dt`

...`s = sigma + j omega`

Laplace 역변환은 다음과 같이 사용한다.

...`L^(-1) F(s) = f(t) = 1 / {j 2 pi } \int_{c-j omega}^\{c+j omega} F(s) e^(st) dt`


시간함수 f(t)에 대한 라플라스변환 함수 F(S) 를 표로 나타낸 것은 다음과 같다.

사용자 삽입 이미지

이울러 f(t) 의 미분, 적분, t 와의 곱 등으로 변형된 형태의 라플라스 변환은 다음과 같다.

사용자 삽입 이미지


참고자료 : 제어시스템과 라플라스변환 공식


라플라스 변환에 관한 이해
http://electoy.tistory.com/101
JelicleLim(2008.7.12)

Comment +0

사용자 삽입 이미지

기본적인 시스템의 모양은 위와 같다. 입력이 있고 그에 따른 출력이 있다.
입력을 r(t) 라고 하고 출력은 c(t)로 표현한다. 물론 위에서 출력부분에 되먹임(feedback)을 넣어서 다시 입력 부분으로 돌리는 것은 closed loop system 이라고 부른다. 일반적으로 위의 다이어그램은 신호처리(signal system)을 의미하고 feedback 이 들어간 시스템을 control system 이라고 부른다.

사용자 삽입 이미지

라플라스변환에 관한 기본 공식이다. 라플라스 변환은 일반 대수함수를 라플라스함수로 바꾸는 것을 말한다.

사용자 삽입 이미지

기본함수들에 대한 라플라스 변환식이다.
라플라스변환을 사용하는 이유는 식의 간편성때문이다. 일반 대수함수, 특히 미방의 경우 그 풀이가 상당히 어렵다. 반면에 라플라스로 변환된 식은 간단하고 명료하게 풀이 된다. 이런 점에서 라플라스변환은 제어쪽에서 주로 사용된다.
일반식을 라플라스변환으로 S 도메인 상의 공식으로 만들고 그것을 푼다. 풀이는 미방이 아닌 선형방정식이 된다. 그렇게 풀어진 최종값을 다시 역변환을 거쳐 최종식을 만들어낸다. 라플라스변환에 주로 사용되는 식은 위 테이블에 제공된다.


Comment +0

ASCIImathML.js 을 사용 tistory에서 수식을 사용 하는 방법이다.

1. ASCIImathML.js 파일을 다운 받는다. [LINK]

2. 다운받은 파일을 홈페이지나 블로그에 올린다. 티스토리의 경우 [admin]으로 들어가서 [스킨]->[직접올리기] 를 통해 파일을 올리면 된다. 그 경우 image/ 라는 폴더에 ASCIImathML.js 가 올라간다.

3. 스킨에서 html/css 를 직접 코드로 수정한다. skin.html 을 수정할 때 <body> 윗부분에 있는 <head> </head> 사이에 다음의 코드를 삽입한다.

<script type="text/javascript" src=" ./images/ASCIIMathML.js"></script>

이때 src="파일의 경로" 에서 ./images/ASCIIMathML.js 이 부분이 ASCIImathML.js 파일의 경로를 포함한 전체 이름이 된다.

4. 사용시 앞과 뒤에 amath endamath 를 넣으면 된다.
즉,
amath y = 1/2a x^2 + 1/3  endamath 
위 수식은 이렇게 보여진다.
amath y = 1/2a x^2 + 1/3 endamath
더 자세한 수식표현법은 다음 사이트의 주소를 참고해서 보면 된다.



http://www1.chapman.edu/~jipsen/mathml/asciimath.html
http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html


홈페이지에서 수식사용하는 법
http://electoy.tistory.com/99
JelicleLim(2008.7.11)

Comment +0

제어에 관한 기본적인 다이어그램이다. 제어에서 필요한 것은 나온 결과를 다시 일정한 양만큼 입력으로 넣는 것이다. 이를테면 자동차의 제어를 위해서 출력(속도)를 측정하고, 그것을 다시 제어를 위한 입력으로 하는 것이다.
사용자 삽입 이미지

물론 위 그림에서 보듯이 입력과 그에 따른 수학적, 정량적 계산결과만이 있는 것이 아니라 외부 노이즈가 존재한다. 이를테면 동일한 가솔린을 사용하더라도 바람이 뒤에서 부는지 앞에서 부는지에 따라 차의 속도는 달라지는 것 따위다. 다양한 종류의 노이즈를 완벽히 계산할 수 없기 때문에 그것은 그냥 들어오는 것으로 처리한다. 결과값, 즉 RPM 을 측정하여 그것을 다시 입력으로 처리하는 것이다.
사용자 삽입 이미지

위 [Controller] 박스의 Gain 을 어떻게 처리하느냐에 따라서 위와 같은 결과 곡선이 만들어진다. Gain 을 크게 잡으로 반응은 매우 빠르게 나타난다. 즉시 결과값에 가까운 값으로 가고, 넘어가고, 다시 줄어드는 식으로 일정한 값을 찾아가게 된다. 반면 Gain 값을 작게 잡으면 서서히 증가하여 최종값이 수렴하는 식의 그래프가 그려진다.

제어에서 Gain 을 어떻게 잡는지가 제어기의 성능을 결정한다. 최종결과치에 가능한 짧은 시간에 도달하게 하는 것이 좋은 제어기이기도 하다. 동시에 특정한 제어기의 경우 Overshoot 을 허용하지 않기도 한다. 이를테면 벽면에 붙어 있는 스위치를 켜고 끄는 로봇팔 같은 경우 Overshoot 이 일어난다는 것은 로봇팔의 망가뜨릴수 있는 치명적인 결점이 된다.


제어 01 : 제어공학과 기본 다이어그램
http://electoy.tistory.com/97
JelicleLim(2008.7.11)

Comment +0