Thursday, March 14, 2013

Friendship With State Space

Last post we saw how to represent any system in a block diagram and barely touched upon mathematical representation of it called state space. Today I will try to make you believe how simple it is to convert any system into state space representation and give a few “Engineering Secrets” to you.

Best way is to go through an example and then generalize it. Let’s recall Newton (He has tortured us many times before! :-/). So (simplified) Newton’s second law is can be represented by 

Where “m” is the mass of the body, “a” is its acceleration and “F” is the force applied on it. We all have used this equation a million times before. We use this equation to answer the question “What force “F” is required to maintain/attain acceleration “a” of a mass “m”??) Now let’s try to convert this to the form I mentioned in the last post, which is

To do this we need values for “A”, “B” and “C”. Looking at this we can easily answer the question that we need an input “u” to maintain/ attain a state ([X]) ̇ where X is a vector of all the states of the system. So relating this to the answer mentioned above: We have Force (F) as an Input (u) and acceleration as an output (y)!! We can also represent the above equation as 


Engineering Secret 1!: “Generally the number of states in a state space representation is equal to the highest derivative in the differential equation of the system”

Hence in above equation (d^2 x)/(dt^2 ) suggests the highest derivative is second order. Hence the number of states (length of X vector) is 2!!

Engineering Secret 2!: List all the states X1…Xn. To guess the states, let the first state X1 be the original variable itself, in this case “x”. Let the second state, X2, be the derivative of first state, the third be the derivative of second state and so on!
So now we get 

Now computing LHS of the state space equation which is given by the matrix below is super easy!


We have all the ingredients! 
So,

Engineering Secret 3! How do you know the dimensions of A and B???
Well.. we know LHS is 2*1 and is 2*1 hence if A is m*n then 2*1 = (m*n)X(2*1). So n should be equal to 2 (for a valid matrix multiplication) and m should be 2 for valid dimensionality.  Thus A is 2*2. Similarly if LHS is 2*1 and u is 1*1 then 2*1 = (m*p)X(1*1). Hence p = 1 and m =2. So B is 2*1 matrix.

Dimensions of C depend on dimensions of “y”. That means if you  are going to measure both the states the Y is 2X1 and hence C will be 2X2. If you are measuring only X1 (displacement) then C will be 1X2.


Engineering Secret 4!: To rearrange this into state space format  write the skeleton first (according to the dimensions you derived from the above trick!) and then fill in the values for A and B using matrix multiplication rules

And then filling in the values we get


Hence to Summarize:
  1. Determine highest order in the system equation (given to you by physics!). Your number of  states is equal to the highest order of derivative. 
  2. Let first state be the variable itself, second be its derivative, third be second’s derivative and so on.. Calculate values for all states. 
  3. Calculate LHS by taking first derivative of each state. And write all equations. 
  4. Derive the dimensions of A, B  and C matrices
  5. Write the SS skeleton and then fill in the numbers according to the equation coefficients you got from step3!



 So.. how does that feel? I will try to go over a more real life example in next post so that you may get more familiar to this. 



Saturday, March 9, 2013

The Basics of Controls and State Space Behavior



Hey Guys.. I will try to share some tools that I learnt during the course of my Masters and in the industry. In my last post I mentioned a few things related to controls that you will learn during your 3rd or 4th year. Today I will discuss a few things that are important and always needed in industry. These may or may not be covered in the class and hence I felt I could share these.

In this field you will be given a task of modeling a particular system and then designing a controller for it which will help you attain desired behavior. If you consider a black box model your entire work could be represented by the block diagram shown below. Let’s discuss the parts of this which will result as a perfect segway into state space (the most important tool to design systems).

Block Diagram

  1. The block “A” is called the plant. This is defined by the laws of physics and is the guy that we  have to control. E.g. This could be a car going uphill at constant speed, a tap filling water in a tank, a line follower robot, a hydro electric power plant etc. All you need to remember is.. the behavior of this plant is defined by physical laws and is constant. You don’t have any control over its definition.
  2. The block “B” is your controller. You design this so that you can control “A” as you want. E.g You will have a flexibility to design a controller “B” that will maintain the speed of your car going uphill at 50Km/Hr or maintain the robot on the black line all the time. 
  3. The block “C” is your output that you can measure or observe and then use it in your controller. E.g It can be the speed of the car or velocity of the line follower. 
  4. The signal “u” is the control. This is the signal that is generated from your controller which is fed to the plant to control it as you want. 
  5. And finally, this controller will be responsible to control a particular “state” of your system. Your system can have many states. One of these many states is your “output” that you observe/ measure with the help of block “C”.

So, the ingredients of the any damn system are: the Plant (A), the Controller (B),the control input (u), the state (x) and the output that you measure (y). And mathematically, any damn system can be represented as


Believe me, with this representation, it becomes super easy to analyze the system compared to writing huge differential equations by drawing free  body diagrams as we all learn in Math 3 and Physics! This representation is called state space and next time we will  see how we generate this state space from any given damn system.

State Space should be your friend and  you should be comfortable in playing with it!

Sunday, March 3, 2013

A Blend of Theory and Practice: A Control Systems Example


My last article states the importance of having a blend of theory and practical exposure in your engineering education. I would like to give you an example of how actually you can go about developing it.

We all have control systems as one of the compulsory courses that we need to pass before we get an engineering degree.  It’s a very important course.  Be it any system in any field, you will, at some point, have to control it to achieve certain objectives. The course that we study during our undergrad spans the following aspects of control systems
  1. What is a system and representing a system in a block diagram.
  2. Mathematical representations of any system by transfer functions and state space (If your professor does not teach state space, go ahead and learn it by yourself. It’s super important in industry). You lean about deriving transfer functions on paper. 
  3. Time and frequency response of that system. Comparison of such responses with higher order systems (You learn big mathematical formulae and derivations to represent different parameters like settling time, overshoot, gain frequency, phase margin etc etc). 
  4. Root Locus, Bode plots, Nyquist plots. You learn all the rules and learn how to sketch these on a graph paper by following the rules.
  5. PID Controller design: You learn about the structure of PID controller and if there is sufficient time in the semester you will learn how to implement it on paper.

So, after giving your final exam, you are proficient in drawing block diagrams, root loci, bode plots on paper, deriving settling time, overshoot numbers given a particular system, changing a system from transfer function form to state space form etc.

This is important to understand the math behind controls. Is it sufficient for the industry?  What else should you do??

  1. Software Implementation: You can do each and every thing mentioned above in MATLAB. When you learn a certain concept, say root locus, in the class, try to plot the same locus using MATLAB. Try to plot a step response and see if it matches to what you sketched in the class. Analyze the system properties (settling time, overshoot etc) by interactively moving the poles and zeros and see the effect. You will have derived relations between the system properties and pole positions in the class. Try to replicate them in MATLAB. 
  2. Take a transfer function change it into state space and vice versa using MATLAB. Design a PID controller and see how the system properties are affected when you change the proportional, integral and derivative gains. 
  3. Get comfortable in plotting and analyzing root loci and bode plots using SISOTOOL in MATLAB.

This skill set with develop an understanding of quickly analyzing the system and coming up with a set of controllers that will satisfy your requirements on settling time, overshoot, steady state errors etc.

Hardware Implementation: If more interested you can also use micro controllers to actually see your controller in action on say a DC motor. Implement DC motor speed control. It’s a classic example to try out and is explained in every single control’s book.

Why I am telling this?
In industry no one will ask you to derive expressions, or ask you a proof of how you did what you did. They will want to see results, see your controllers in action. And 99% of the time it’s about designing a PID controller and tweaking the three gains to achieve the system performance.
All you will do ità Model the system in MATLAB, design a PID controller, tweak the gains and check for a) stability, b) system properties (settling time, overshot etc) and c) tracking (steady state error) and d) robustness. So be sure before you call it a day for control systems, you are comfortable in the above mentioned aspects of the system and controller.

To sum up: Be sure to go one step ahead than a textbook oriented course and get familiar with MATLAB tools (tf(), ss(), pid(), rlocus(), sisotool(), bode() etc commands) to be able to use MATLAB to do what you would otherwise spend time on doing by hand. This one subject will then open arenas like controls, mechatronics, robotics, instrumentation, modeling & development and much more which you can focus if you go for higher studies.

Good Books you can refer for the basics:
Feedback Control Systems by Franklin Powell


Hope these links help you.

(If you are interested in controls/ mechatronics I have designed few projects that I can share with you. Let me know via email at bits2world@gmail.com and I will email them to you)

Wednesday, February 27, 2013

A Blend Of Theory And Practice


This article briefly compares what we study and what is required in industry! In a couple other articles I will try to give a few examples on how you can acquire best of both the worlds so that you have a better picture of it and try to work towards it.

What’s our education system like
Compulsory Disciplinary Courses (CDCs) are the mandatory courses that you will have to do in your 3rd and 4th years of engineering to get a bachelor’s degree. I was in your shoes a few years back and it’s sad but true that most of us memorize formulae and get good grades in these CDCs. Indian education system is very textbook oriented. Be it any university, we have a certain prescribed textbook and the professor teaches exactly from that textbook. If that textbook- professor combination is good, you like that subject and you explore more, otherwise you bunk classes.

Good thing about our education system is the fact that we are molded fairly strongly in the mathematical aspect of any subject. We can analyze any particular engineering system optimally in a theoretical manner. But when it comes to building that system, we lack in experience and the tools. In the west what I experienced is something different. An undergraduate student may not be very proficient in calculus or differential equations or matrices (which are basically building blocks of engineering) but when it comes to building a working prototype of any phenomenon, they have the required tools.

What’s in the western education system?
The reason behind this is the western education system for engineering. They have something called as design projects/ semester long course projects in most of the courses. These either include a part of a research problem the course instructor is working on or any relevant project that students choose. Teams of students constitute MEs, EEs and CS guys and the work is divided accordingly. Each project has biweekly/ monthly design reviews by the professor where the teams present their progress in front of the class. During every design review, the professor gives guidelines for the next few weeks. Basically students learn a theoretical concept in class and in parallel apply that concept in their design project. At the end of the semester, every team comes up with a working prototype of the theory that they learnt in the class.

My personal experience
I can give you one example of such project I was involved in. In our mechatronics course we had to design a nano-positioning system which will position a certain object in all three co-ordinates. My team constituted of one doctoral (PhD) student working in the nano-positioning research area of the course instructor, one mechanical engineer, one hardware engineer and me. The PhD student contributed in the physical design of the system, the math/ physics behind it and how to model the system on paper. I was responsible for developing a controller that would control the system. The mechanical engineer was responsible for solid modeling and machining/manufacturing the system prototype and then the hardware engineer was in charge of deploying my controller on the actual hardware and interfacing it with the sensors and actuators! ….Result: We got a cool working mechatronic system by applying all the interdisciplinary knowledge that we learnt from the course, and we as a team learnt different aspects of engineering from each other.  Here is the link of the research if you are interested.


What you can do to take the best of both worlds!
So the giveaway is: Try to explore tools and try to get hands on experience in the CDCs that you like, or that you want to do your career in. Don’t waste your spare time in fetching new reference books and solving problems behind the chapters. Spend time in learning softwares relevant to the course (it could be softwares like MATLAB/ Simulink, Octave, Solid Works/ProE,  EagleCAD, Labview etc) or programming languages like C/ C++. Try to find interested people on campus and tag along with them to build something cool. Have simple tools like soldering iron, screws, hammers, pliers/ strippers, an arduino board, some resistors, capacitors, some wires handy. Make use of your campus workshop facility. It’s exciting to try out small things that your learn in your courses, even if it’s just blinking an LED, or using a mosfet to switch high loads: that will give you immense satisfaction and enthusiasm to build more. As you dive more and more into your discipline during your engineering years, you will develop a good blend in formulating any system on paper and then building a small prototype of it!

So.. good luck! Get your hands dirty! :) ..A combination of strong mathematical background and hands on experience will do wonders when you go into the industry!

Saturday, February 23, 2013

BITS Top 10

This article is mainly for current and aspiring-to-be BITSians. After talking to many I realized that they made a decision to study at BITS based on its brand name and what it stands for. To understand "what it stands for" from outside is not that easy. To many, it stands for knowledge being power supreme. While a number of industries and universities consider it to be an equivalent to IITs, a few regard it being better in some aspects.

I've had a chance to work with BARC, Tensilica, Cisco, Qualcomm and Purdue so far. I believe this to be a varied set of institutions. I've engaged in many conversations with colleagues and friends and tried to form my opinion on "what makes BITS unique and special". Here's what I think about my Alma mater.

Top 10 things that make BITS (and BITSians) special:

10. On-campus organizations: give many a chance to get involved in activities of their choice and cultivate extra-curricular interests.

9. BITSAT (admissions): is India's first online entrance test considered having a very low rate of acceptance and is reservation-free.     

8. Excellent textbook choices: provide (an opportunity to learn) state-of-the-art knowledge of a topic.

7. Diversity: among students and faculty ensures that we share a stronger bond of being a BITSian.

6. Hostel life: teaches how to manage one's own life.

5. Mini-tests: ensure we don't fall out of track and follow the same academic standards as that of any US/UK university or an MBA school.

4. International recognition: is not just a "feel-good" factor, but helps summarize your educational background in a few words to many across the world. 

3. Emphasis on basic sciences: helps one shape her ideas and get on to the basics.

2. The BITSian network: always reaches out to a fellow BITSian for guidance and help when needed.

1. Practice school: is the most important factor why industries and academia like us.

Interdisciplinary Skills - A Taste of Robotics and Bio-mechanics



So, as mentioned  in the previous article (dated Feb 17, 2013), let’s go over some of the varieties of Mechanical Engineering. I mentioned a few branches which you can explore (like MEMS, Energy Harvesting, Computational Mechanics etc).  All the fields I mentioned are very interdisciplinary. This means that you will see a confluence of many other disciplines along with mechanical engineering.

As an example, consider Mechatronics and Robotics. The applications of this branch spans from, say, spot welding robots in the auto industry, through the Da Vinci robot performing automated surgeries, through the Curiosity Mars rover that is exploring mars all by itself.
Here are some interesting links of such applications:


         
To design these systems you need decent knowledge various aspects of mechanical engineering like solid modeling, stress analysis, right tolerance and dimensional analysis,  actual manufacturing of the robot, material science to select right materials that would sustain external pressures, temperatures etc etc.. list is endless. But this is not sufficient. You need heavy electronics to make the robot do what you designed it for. Any mechatronic system will have sensors to sense the environment and actuators to do the action..which are nothing but electrical signals read by some electronic PCBs. In addition to electronics, you need computer science. You will need to add intelligence to the robot to do the task which it is designed for and for that you need good grasp on programming languages (embedded C, C++, python etc) that will talk to the electronic micro controllers inside the bot.

Ok Okay… well..you as a single entity need not be an expert in all these.. I mean..if you are.. Great! ..but if not.. That’s fine too.. usually there are teams of people doing such specialized tasks. But you as a Mechanical engineer..should be at least aware of all these (so that people don’t fool you around! :)).

Same is the case with other fields like say Bio Mechanics or medical instrumentation. What do you think is the basis of all the surgical tools? .. Mechanical Engineering! A good mechanical engineer will be able to design, model and manufacture various surgical tools for different surgeries. Some innovators invent tools which can be used in multiple ways. If you look at Intuitive Surgicals’ website you will realize how many Mechanical Engineers they want. Here are some of the professors at UM which are in Mechanical department and involved in Biomechanics and Bio systems engineering. ..and there are many such universities too.. I will leave that to you to do a research if you are really interested in this area.

So..my point is..being a mechanical engineer.. you need not constrain yourself to manufacturing or securing a job on an assembly line doing some QA crap! (that sucks L).. or switch to MBA! You can explore many things without shifting fields.. keep one thing in mind.. Mechanical engineering, now, is not just constrained to itself. Wherever you go, you will have to interact with people from electronics, people from computer science and people specializing in the application specific areas (like doctors if you are into medical instrumentation or physicists if you are in a team designing Mars rovers at NASA!)

So..make sure you develop that skill set too!

(In few articles I will try to go over some electronics/ electrical engineering and some tools that will help you in building an all-round personality around your respective discipline! Some of my other friends specialized in these disciples will also share  there experience with you guys!)

C u soon!
--Tejas

Sunday, February 17, 2013

Mechanical Engineering: Not Only About Drilling Holes In A Block Of Metal!



Before I begin… What is all this??   Well..we are a group of guys (like you.. who a few years back were behind good grades or addicted to counter strike :) ..but now are working in various industries or universities in different parts of the world) who will try to write articles (spanning over wide variety of disciplines) that will give you a glimpse of academia and industry, touch upon some exciting technical topics and try to create a platform to share and discuss ideas!.. Believe me..something which is infinitely exciting when you stumble upon some random group of people with same interests. 

A little bit about myself: 
I did my Mechanical Engineering from BITS-Pilani Goa Campus. After my undergraduate studies I pursued my Masters from University of Michigan in Ann Arbor and currently I am working in Automotive domain mainly focused on electric powertrains.. the so-called future of  cars.

So as a common misconception of most of the first yearites (including me).. mechanical engineering is not only about designing cars or spending time in workshop doing manual labor :) . There are so many different facets of this discipline that one can explore… and it becomes very exciting when it gets interdisciplinary. As a broad division you all know mech spans design, thermal, fluids, and solid mechanics. But these are very broad categories and I feel before you graduate you should be aware of the numerous more branches that you can focus on. So here are some more fields that I can think of..
  1. Automotive
  2. Control Systems
  3. Mechatronics and Robotics
  4. MEMS and NanoTechnology
  5. Energy Harvesting (Renewable resources)
  6. Dynamics and Vibrations
  7. Computational Mechanics
  8. Fracture Mechanics
  9. CFD
  10. Bio Mechanics and Bio systems engineering ….umm.. and I guess a lot more.

There are so many universities abroad that specialize in these areas of mechanical engineering (like MIT, UM, Berkeley, UT Austin, RWTHAachen etc etc) and I feel a funded gateway to such research labs is the knowledge about these fields and possibly a couple relevant projects on your resume.. and good contacts.

So, even though I know the CDCs are important and will provide you the basis for the discipline.. and are mandatory for a good GPA ;) … I feel we can spend some time in exploring a few of these. In next coming articles I will try to glance over some of these and try to give you guys a picture of what all exciting things are waiting for you …if you remain in engineering :)

Cya soon…..
--Tejas