Pages

Friday, December 23, 2011

Why Modeling is Important?

 By K.H. Ng

First of all, the open problem is what is a model? Specifically, what is a model in control system sense? The word model is generally quite wide and has many uses. A fashion model is for displaying certain cloths design, a market model is used to predict the profit and deficit, while a business model is the strategic planning in an organization.

Model in control system sense is more to a mathematical model. An extremely simple model is y = 2 * x. Give x to a function and it will return the double of the original value. A more complicated model is the Fourier series, where given a variable in function of time, it will return the amplitudes of the DC gain, sine harmonics and cosine harmonics.

While in control system, dynamic systems are more of interest where the ordinary differential equation comes in the game. This is when the variables and the derivatives comes to form a balanced equation for example the Newton's Second Law of Motion or the Kirchoff Voltage Law.

A dynamic model gives the output when excited with certain inputs. In other words, a model gives the output description in function of time when given a certain inputs, also in function of time. For example, when a motor is given an voltage for one second, what is the expected angle it will turn?

There are various method to analyze a model. Or put differently, there are many methods to work on a certain model. One might go for the most basic time domain method, which is the convolution of linear time invariant system. Another simpler method is to apply La Place transform to a signal and work from there. The most recent and popular approach is the state space approach.

Now comes to the main part of the article, why it is important? Although one might not use a model in controlling certain plant, it is important in the controller design process. For example, when someone wants to control a motor, they do not just buy a motor and test it. They start off with the model. And also, plants might not be cheap to start with.

Another example is water level control in a tank. One do not buy a tank and experiment on it. They would have to come up with a model of the tank, the pumps, the pipes, etc. After deriving the model, one can obtain the water level in function of time given the opening of a water flow valve in function of time.

To have a model is important to validate a controller design. Let's give an example of PID controller. To determine the effectiveness of the controller in controlling water level, it is important to have the model at hand for simulation purposes.

A model can be linear or non linear. But most plants in the real world is a non linear one. Even Ohm's Law is not linear if the voltage variation is too large. Also given an example in a motor. Motors have a certain dead zone where small voltage will not move the motor. The usual cause is friction. Motors also have saturation where the current cannot gets too high or it will burn out the motor.

Therefore, it is a challenge to come up with the nonlinear model. Modeling a non linear plant is never an easy task. It takes experience and a lot of computation to come up with the perfect model. There are also many method emerging in modeling. Some are fuzzy modeling, neural nets modeling, statistical modeling, etc.

In the end of the day, model is just a part of control system design and analysis. But understanding the plant to control is very important for understanding of the whole control system.

Tuesday, November 29, 2011

Cliche vs Creativity

Let's play a game. Help yourself to a piece of pen and paper, write down as many functions of a paper clip that you can figure out. It can be anything, let the imagination runs wild.


How many functions of paper clip that one can found out? Did you know average adult can find up to 30 functions while a child can have up to 100 function. Why is this so?

Also check out this interesting poll regarding artistic freedom in relation to age [link]. Majority chosen youth and teenagers than adult and elderly. It is clear that people are more creative when they were young.

Cliche

As people grow, they get more bounded by rules and regulations. As a result, human are bound to a cliche or pattern. For example in schools, higher institutes or working organizations.

Let's take the example of the paper clip. A small children might not know the function of a paper clip if one shows them the first time. As their imagination is wild, they can use that for almost anything. While for an adult, a paper clip is used just for clipping papers.

As adults grow, their thinking are getting more and more inside the box.

Creativity vs Innovation

Creativity and innovation sounds different from each other but they are quite connected in some way or another. Being creative is to do things differently, to think outside of the box, to think outside of a cliche. Being innovative means to implement an idea to generate new idea.

Tan Sri Lim Kok Wing mentioned that people and stressing on innovation but no one stresses on creativity [link]. This is quite true based on his article in the link. Why is that so? One thing, innovation drives the market. Consumer says it all. If there is no market, means any organization will not generate revenue.

Put for example, person A in Alpha Company, uses an idea to create a product to sell. That is called innovation. Putting it another way, that person can copy an idea from Beta Company and use it for their own. It is still called innovation.



But who are the ones to create those idea? This is where creativity comes into place. It takes less resources to generate an idea than to get a well established idea and use it. So to speak, innovation is more important to generate money than creativity.

Science , Technology and Engineering

As can be seen, creativity and innovation are closely related to science, technology and engineering. It takes a lot of creativity to explore in science. A good example is Einstein. 


According to Professor Brian Cox, science, especially curiosity led science is underfunded [link]. It is underfund because there is no direct profit from funding science. One might satisfy a curiosity of another by explore in science but it does not generate market for the consumers. This is why stress is given on an innovation led economy, not a creativity led economy.

But imagine, if there is not science, there will be not technology. Without technology, engineers could not come up with consumer products.

Tools for Creativity

Nevertheless, creativity is important in one way or another. But how creativity can be encouraged with all those rules and cliche? Edward de Bono, a renowned thinker comes up with a lot of tools to generate creative ideas, for example the Lateral Thinking [link]. In his book, he mentioned about creativity and how it was blocked by cliche in human mind.

Concluding Remark

Innovation seems to be more important than creativity because they generates more profit than creativity. But without creativity, innovations cannot comes into hand. One of the factor that stops people from being creative is the rules and cliche they are bounded to.

Saturday, November 26, 2011

Understanding the DC Motor Part IV

The final part of understanding motor control is regarding control the position of the permanent magnet direct current motor. But this is applicable to the speed or torque. This control method is called the cascade control and it is inspired by the Faulhaber motion control module.

Again, the motor model is from Roger Asenstrup. All the parameters are from the model.

Motor Position Control with Single Loop PID

A simple position feedback using the angle feedback from the motor. Kp = 1, Ki = 0, Kd = 0.


Figure 1. Position control with Kp = 1, Ki = 0, Kd = 0.



Figure 2. Result from Figure 1

As seen from Figure 2, the Proportional only control is good enough to control the motor position.

Dead Zone Problem

But this is when the nonlinearity kicks in. In Figure 3, a dead zone was added to approximate the Coulomb friction. The value of dead zone is -0.1 to 0.1 volts. 
Figure 3. P control (Kp = 1) with dead zone


Figure 4. Result from Figure 3

Figure 4 shows the result with the presence of dead zone. The motor position will not converge to desired value of position. One method to solve this is to use proportional and integral control (PI control).
Figure 5. PI control (Kp = 1, Ki = 3) with dead zone

After applying the PI control, the value will converge to the desired value slowly, shown in Figure 5.

Saturation Problem

Using PI control is not good for saturation problem. It will cause the error to integrate really quickly and causing a large overshoot.
Figure 6. PI control (Kp = 1, Ki = 3) with dead zone and saturation


Figure 7. Result of Figure 6.

As seen from Figure 7, the motor will overshoot due to integration of the saturation.

Cascaded PID Control

To solve the problem, a cascade controller was proposed. The position error will be fed into a PID with velocity feedback.
Figure 8. Position P Control (Kp = 5) cascade with Velocity P Control (Kp = 3)


Figure 9. Result of Figure 8

From Figure 9, seems that the performance of the motor position control has improved although the reaching time is slower. Even with presence of dead zone, and saturation, the control still be able to perform well.


Motor Driver Current Problem

There is another problem to address, which is the motor current. The current is needed to drive the torque of the motor. If the simulation in Figure 8 was modified (Figure 10) to include motor current plot, it can be seen in Figure 11 that the motor current can spike at more than 5 Ampere.

Figure 10. Modified to include motor current plot


Figure 11. Same result as Figure 9, zoomed

Triple Cascade Control

Another loop of PID was used to control the motor current. In this strategy, only integral control (I control) was used. In other word, the overall system is Proportional (Position) - Proportional (Velocity) - Integral Control (Current).

Figure 12. Position P Control (Kp = 5) cascade with Velocity P Control (Kp = 3) cascade with Current Integral Control (Ki = 1)


Figure 13. Result from Figure 12

After adding the current controller, the performance is quite similar to the controller without it, in Figure 9.

But notice the peak current was reduced from more than 5 A to 0.57 A.


Concluding Remark

This concludes the "Understanding the DC Motor" section. Although this is only simulation, application in the real motor is still far away. It includes the feedback sensor (like position, velocity and current) and the motor driver. Making the position control as a whole is not as easy as it seems. But if one do not understand the nature of motor, it is quite hard to start with.

Check out the full series

Part I
Part II
Part III
Part II, III - Interlude
Part IV

Understanding the DC Motor Part II, III - Interlude

The motor nonlinearities will be discussed in this part. Before jumping in, let's dive in to the concept of Liner Time Invariant or the LTI.

Linear Time Invariant
LTI concept is very important to understand linear control theory. Two basic characteristics of LTI is linear and time invariant.

Equation 1 - Linearity
Let:
y=f(x), then ay=f(ax).
Intepretation:
A function taking x and returning y, if multiplied with a constant, a in x, will give a product of a and y.

Equation 2 - Time
Let:
y(t) = g(x,t), then y(t-b) = g(x,t-b)
Intepretation:
A function y in time, t, of g in x and time, if the time is delayed by b, the output will give the same.

DC Motor Nonlinearities
A direct current motor is subject to at least two types of nonlininearities, namely the saturation and dead zone. Another type of nonlinearity is the performance due to the decay of the motor mechanism and carbon brush. This is a type variant system but usually was not taken into account due to slow decay.

Dead Zone
Let's say V = 10 volts applied to the motor. After steady state, the motor will turn with an angular velocity of 100 rpm. If V applied is 1 volts, the motor will turn with 100/10 = 10 rpm. But given V = 0.1 volts, the motor will not turn due to the dead zone. Example of cause of dead zone is Coulomb friction. Coulomb friction is hard to model and it changes with many variables.

Saturation
Let's put it again V = 10 volts yield 100 rpm, giving 20 volts will yield 200 rpm, but giving 30 volts might only produce 240 rpm. This might not be the nonlinearity in the motor but in the motor driver. It depends on the voltage supplied to the motor.

Decay
Let's say again, V = 10 volts yields 100 rpm, but after one year, V = 10 volts might yield only 95 rpm.

Concluding Remark
Nonlinearity is a pain in control system. This is why simulation and real application is so different.


Check out the full series

Part I
Part II
Part III
Part II, III - Interlude
Part IV

Tuesday, November 22, 2011

Understanding the DC Motor Part III

In this part, simulations for the permanent magnet DC motor will be shown. Several cases will be given to show the nature of the DC motor and how they act. Although simulation can give a good representation of the motor, the simulation will not be exactly like the real motor because of modelling error and unmodeled dynamics.

Modelling error and Unmodeled Dynamics

Quick fact about modelling error and unmodeled dynamics. Modelling error is when the parameters in the simulation is not exactly like the real motor for example motor resistance. Maybe one could measure the resistance but the value is prone to error due to measurements error. Secondly, the unmodeled dynamics. Although the model can be derived from first principle, surely there are some "things" that cannot be expected from the motor. Maybe there are some imperfection in the motor that causes the motor cannot turn correctly. This is when the order of the motor increases.

Simulation Model

Moving on, the simulation was done in simulink using a model by Roger Asenstrup.
Model in Simulink
The motor parameters used in this simulation is the original value in the motor model (except for the damping friction).

Resistance: 2.06 Ohm
Inductance: 0.238 mH
Back EMF Constant: 1/((406*2*pi)/60)
Torque Constant: 0.0235 Nm/A
Rotoe Inertia: 1.07e-6
Mechanical Damping: 12e-5 Nms/rad

Of course this value is not exactly the same for all motors. Each motors has their own parameters. Also to explain, the motor current, motor speed and motor position were plotted.

Simulation Cases

Three cases will be shown:
1) The normal situation for a motor
2) If there is not friction
3) If the load is very big (heavy)

Case 1: Normal situation
Case 1 plot

Case 1 plot (zoomed)
In a normal situation, a motor will work like so: The applied voltage will cause a surge in motor current. It will increase with a decay due to the motor inductance. As soon as the motor current causes the motor to rotate, the back EMF will reduce the current to the motor. In the end, the motor will move in a constant speed (as long as the applied voltage is constant). Note that there is a constant value in the motor current (This will be explain in the second case).

Case 2: Zero Friction
Case 2 plot

Case 2 plot (zoomed)
In the second case, the damping value in the simulation was reduced to zero. The applied voltage will cause the surge in motor current. After the motor current causes the motor to rotate, the back EMF will reduce the motor current to zero. Due to zero friction, the motor need not have any torque to keep it moving (Newton's First Law of Motion). In other words, in a motor with friction, the current is actually used to counter the friction.

Case 3: Heavy Load / Stalled
Case 3 plot
The value of damping is 12e-5 but the value of inertia is 1.07. In the case of stalled motor, the applied voltage will cause the motor current to surge, then the value will not reduce due to no back EMF present (The motor cannot move because it is stalled). This is when care should be taken to the motor driver design. If the driver cannot withstand high continuous current, the drive will burn.

Concluding Remarks

Now, we have known the motor nature, more or less but note that all this simulation was done in open loop configuration. Let's say 1 V will cause the motor to move in certain velocity, changing the motor load will change the velocity. In the next part, let's move into motor control using proportional, integral and derivative controller.

p/s: Please click on the pictures to enlarge.


Check out the full series

Part I
Part II
Part III
Part II, III - Interlude
Part IV

Thursday, November 17, 2011

Understanding the DC Motor Part II

This part is about understanding the derivation of the motor model. (Actually this is obtained from Control System Engineering Book by Nise, so credit to that fellow). Someone new to control theory might wonder what the heck is a model. Let's put that a model is used to calculate an output given an input. Like a simple function like y=f(x). The input is x and output is y. But in control model, it is more to dynamic model or model which involves ordinary differential equation. Let's proceed.

Modeling Electrical Characteristics

Electrical Schematic
Starting off with the electrical characteristics. From the motor schematics, we can draw the Kirchoff Voltage Law (KVL) line.

Equation 1
According to KVL, the total voltage in the line is zero.

Equation 2
Therefore, we can come up with Equation 2.
Equation 3
Taking the form of La Place in Equation 3 with all initial values zeroed. 
Equation 4
The equation then can be arrange in term of current (Equation 4),
Equation 5
Or in the form of transfer function (Equation 5).

Modeling Mechanical Characteristics

After the electrical part, let's move on to the mechanical part:
Mechanical Schematic
The schematic above shows the free body diagram.
Equation 6
Start off with Newton's law, where torque equals moment of inertia, angular acceleration
Equation 7
In Equation 7, there are three acting torque, (1) the torque from the motor, (2) the viscous friction from where the higher the speed of rotation the higher the friction force is, and (3) the Coulomb friction where the friction counters the movement. For simplicity, the Coulomb friction can be assumed constant or zero. 
Equation 8
Rearranging in terms of motor speed, omega.
Equation 9
Applying La Place transform with zero initial values.
Equation 10
Rearranging in terms of omega,
Equation 11
Or in terms of transfer function.
Equation 12
Equation 12 is an auxiliary equation, just for completeness, where speed is the derivation of motor position, theta
Equation 13
Applying La Place transform with zero initial value,
Equation 14
And arranging it in transfer function form.
Equation 15
Equation 15 and 16 are additional equations where they are need to "connect" the electrical and mechanical parts. Equation 15 connects the motor current to the torque produced.
Equation 16
Equation 16 is the back electromotive force produces with a certain motor speed.

The Complete Model

Arranging Equation 5, 11, 14, 15 and 16, we obtain the motor model like in the figure below.


From this figure, it can be seen that a motor have six unknown parameters, (1) motor resistance, (2) motor inductance, (3) load moment of inertia, (4) load viscous friction, (5) torque constant, Kt, and (6) speed constant, Ke. This is when the external torque, T1 is assumed zero.

In the next part, the simulation and interpretation will be shown, using some values for all these parameters. It is also interesting to know that there are topics in parameter estimation or system identification to identify the parameter values. Most probably this will not be covered here because it is quite extensive.


Check out the full series

Part I
Part II
Part III
Part II, III - Interlude
Part IV

Wednesday, November 16, 2011

Understanding the DC Motor Part I

It took me quite some time to understand the permanent magnet direct current motor or people like to just call it DC motor. In order to properly control a DC motor, they should understand the motor nature first before applying the control algorithm. The dangerous part is, a motor can get over current easily, not only spoiling the driver but the motor itself will get burned.

The figure below shows a typical DC motor. Amateur hobbyist like to apply the motor voltage directly to the motor and expect the performance of the motor to be the same every time. This is not the case. Applied voltage, Va, is not directly related to the motor speed, omega. In fact, the motor is a third order system with Type 1.

In layman term, third order means, in between the applied voltage and the angle, there are motor current and motor speed. Type 1 means, if the applied voltage is removed, the angle of rotation of the motor will not go back to the original position. To understand the nature or characteristics of the motor, read on.  
Typical motor. Photo credit: Cytron.com.my
First, we should understand the built up of the motor, or the motor schematic. Not exactly how a motor was constructed but rather, what can be used to represent a motor. The figure below (motor schematic) is a good representation of a DC motor.

Motor is built up of winding coil, therefore it is represented with the motor inductance, La. With long motor coil, there is expected to have resistance, Ra. Most important part of the motor is the back electromotive force, EMF. The concept of EMF is quite hard go grasp at the beginning but it is quite simple. Back EMF is actually "virtual". In other word, it cannot be measured directly. But the motor terminal can give a good estimate of the back EMF.

Another part of the DC motor is the mechanical part. The motor is always used to move a load, depicted as J and the load sure to have viscous friction and Coulomb friction, depicted with B and T1 respectively. Coulomb friction is sometimes represented with a constant value for simplicity. Which means, the torque will always go against the movement, either it is moving or in static. While the viscous friction appears only when the motor is moving, in fact, the faster the motor is moving, the higher the torque of the viscous friction is (approximated with a linear relationship).

After understanding this motor schematic, we should move on to the motor model. Model is the most important part to understand the motor. Using a model, one could predict how a motor react to certain applied voltage, either it is linear or in pulse width modulation form. 
Motor Schematic

I am not going to go too deep in the motor model derivation. To derive the motor model, two first principle rules are needed namely the Kirchoff Voltage Law and Newton's Law. It is also useful to use La Place transformation.

The Kirchoff Voltage Law can be used to derive the electrical characteristics while the Newton's Law can be used to derive the mechanical characteristics. Besides that, one should understand the the motor current is proportional with the motor produced torque and the back EMF is proportional with the motor speed. Using all this information, the motor can be put in the form depicted in picture below.
Motor Model (click to enlarge)

Perhaps in Part II, I will explain more about this motor model and how to derive it. Later on, I will discuss on a motor control method to properly control a motor.


Check out the full series

Part I
Part II
Part III
Part II, III - Interlude
Part IV

Monday, October 31, 2011

Giving Blessings

After watching this two videos, here and here, it really inspire me to write this post.

I still remember once, my family and I went for a dinner out at an open air cafe. Then we were approached by a monk. The monk hand over an alm to ask for donation. Well, I was thinking, alm was not suppose to be filled with money but food. But my dad, donated some cash. The monk did some form of blessing to us and went away.

Then I went, "That is a fake monk. Why donate?". My dad goes "It does not matter if it is real or fake". Well apparently, the day after, he came out in the newspaper. This guy is actually a fraud, pretending to be a monk and asks for donation. It was reported in some section of TheStar some time ago.

Only after a few years later, I realize, "Does it matter if he was fake?". The most important thing is the blessing that we give that counts. Even the donation of mere RM 2.00, it really will help a lot, although the monk was fake.

Let's put this in form of logic in four situations.
Case 1: The monk is fake and I do not donate. I will get demerit because of not donating and that person gets nothing.
Case 2: The monk is real and I do not donate. I will get demerit more because of not helping a monk. The monk will get nothing
Case 3: The monk is real and I donate. I will get merit and the monk can have something to eat.
Case 4: The monk is fake and I donate. I will get merit but that guy will get demerit for cheating.

After thinking for a while, it is the blessing that counts. Blessing someone is the best thing one can give to anyone, smile, donation or prayer. So what if the monk is fake? I still will get merit for blessing others. This is what we need in this world, like the videos, helping each other in time of needs.

Sunday, October 16, 2011

Thinking issue is more critical than global warming


This is a quote from my lecturer in creative thinking, "The most critical issue is not global warming but rather, the way people think" by Edward De Bono.

Come to think of this, it is really an argument that I would agree on. Not in a critical sense that people in IBM or Microsoft or Google think, but rather close to my home, in Malaysia.

I have also read this article here. Quite an inspiring article I would say. Tan Sri also focuses on the right thing to think and how to generate creativity.

And just recently, I thought back about a book my Edward De Bono, about lateral thinking. When come to think of it, thinking is really crucial in creating an empowering community. "Empowering creativity that empowers".

Tan Sri also mentioned about the importance of education system. Education methods in the 20th century cannot be used in the 21st century.

Whenever there are weakness in the Malaysia society, the education system were to be blamed. This seems to be a sickness in the society people like to stick to. Again, it is back to the thinking of the people themselves.

I am not sure what I would like to voice out here, but I would like to say that thinking is important. Thinking creates a society that excels. Thinking creates a creative community. Thinking will bring a bright future to everyone.

Friday, October 14, 2011

Robot Software

The concept of robot software is very important in developing robots. This software is different from normal software because of the real time requirement. Besides the structure of the software could be different based on the structure and requirement of the robot.

There are three basic concept that have to be understood:

1) Modularity
Every function in the robot can be split into modules rather than having them all clumped up in a software. Advantage of doing this is because it is easier to troubleshoot and easier for development. It is better for code understanding.

2) Hierarchy
Even with modules, there should be some hierarchy to determine the level of the module. Either it be input output module, filtering module, utility modules, or application modules. With this, it is better when defining a module and to classify them.

3) Connection
Even with module or without, connecting the component is not easy. Communication from one module to another should be put in a defined and standard manner. This is important due to the complexity when number of modules are increasing.

This is a presentation I have made to compile the work my colleague and I have done for a year. http://www.mediafire.com/?800hk4cu44qrsxq

Enough of say...

There is a blog that I would recommend. A blog by Professor Adrian Boeing. http://adrianboeing.blogspot.com/

Tuesday, October 11, 2011

A Promise to Myself

I have promised that the previous change of blog template was the last one. But this time I changed. Well, mostly it is because the previous template was too messy and looks to punk-y. I think this is the last time I will change this blog template.

Friday, October 7, 2011

Random Post

Still, control engineering never seems to stop fascinating me. The main idea of control engineering is about need. Whenever there is need, surely there is  way to do it.

Wednesday, September 7, 2011

Culture Determines Winning or Losing

- The recent trip to Bangkok made me learned a lot.
- From the performance of the Malaysia ROBOCON team, I could say, we are still far from reaching the standard of the real winner of the ABU ROBOCON.
- The cause of this problem is the technology used.
- China and Hong Kong manage to use dead reckoning in their mobile robot navigation with gyroscope.
- Even Japan can do dead reckoning by only encoder.
- What amaze me is the Kinect used for their robotic application.
- Kinect is a relatively new sensor in the industry and they have already manage to apply it in the game for 2011.

Culture
- Back to the issue, the root cause would be the culture.
- After coming back from Bangkok, I add a few friends from Japan on Facebook and I am surprised to find out they are only first year or second year students.
- Apparently, they know how to use upper level undergraduate knowledge like PID, self tuning, path planning and path tracking
- And another surprising fact is that they learn all by themselves.
- Compared to culture in Malaysia, it is a big difference.
- Take for example the UESTC from China. Although they do not win the domestics game in China, from their robots performance, we can see the technology used is far advance than Malaysia ROBOCON standard. Their training game field do not even have lines.

Problem
- The problem here is apparent.
- We have a culture problem that need fixing.
- One culture that we lack is the culture of knowledge.
- The knowledge is there, just no one wants to appreciate them.
- And if they do have the knowledge, implementing in real life is a hard part.
- Again, I would like to state is, what makes difference between winning and losing is culture.

Transformation
- Therefore, if we kept on using our current system, we will never be able to catch up with them.
- They have their own standard and inevitably, in five years time or so, they will increase exponentially.
- The world of robotics is vast and is getting vaster.
- Problems like kinematic, path planning and tracking are deemed to be classical knowledge already.
- New knowledge like obstacle avoidance, artificial intelligence and human interactions are coming in.
- Who knows the standard of ROBOCON will be growing into. Like the 2011 game, robots need to deal with environment dynamics.
- Solution?

Tuesday, August 9, 2011

Somewhere around Ipoh and Kampar

Stayed at Kampar for one night and went to few places.Including Ipoh.















Creative Commons License
This photography is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.