Saturday, May 25, 2013

PID Controller



Hi : ) today I’ll focus on the most important thing, which designing is highly recommended. After my last accident we decided that until we start flying again, we have to prepare some automatic stability control based on PID controller.
Fig. 1 - Schematic of PID Controller
 The main idea of using controller is to compensate position by using a feedback. At first, we have to achieve some state. We starting from initial position, and our goal is to obtain assuming position. After every step we have to measure somehow our state and compensate it. Main idea is shown in above picture.  PID controller contains of few independent parts. It comes from age of analog devices and names of particular parts are cooperated with some setups of operation amplifiers. The simplest controller consist of proportional (P) part only. In more complicated circuits it can be found also other parts, like integral (I)  or derivative (D). Depending of using one or few parts in same time, the controller could be called: P (only proportional), PI (proportional + integral) or PID (proportional + integral + derivative). In above picture are  presented some equations which are describing each part. There are also some mixed controllers (ID or PD only) but I don’t want to describe it. There is some differences between using all of mentioned parts:
-          - Proportional: is the easiest feedback  control  to  implement, and simple proportional control is probably the most common kind of  control  loop.  A  proportional controller  is  just  the  error  signal multiplied by a constant and fed out to the drive. Below picture shows the differences between setting some gains. For small gains (kp = 1) the motor goes to the correct target, but it does so quite slowly. Increasing the gain (kp = 2) speeds up  the  response  to  a  point.  Beyond that point (kp = 5, kp = 10) the motor starts out faster, but it overshoots the target. In the end the system doesn’t settle out any quicker than it would have with lower  gain,  but  there  is  more overshoot. If we kept increasing the  gain  we  would  eventually reach a point where the system just oscillated around the target and never settled out-the system would be unstable.
Fig 2. Impulse response of proportional part
-          - Integral: Integral control is used to add long-term precision to a control loop. It is almost always used in conjunction with proportional control. Integral control by itself usually  decreases  stability,  or  destroys  it  altogether. Next figure  shows the motor and gear with pure  integral  control  (pGain  = 0).  The  system  doesn’t  settle. Like  the  precision  actuator  with proportional  control,  the  motor and  gear  system  with  integral control  alone  will  oscillate  with bigger  and  bigger  swings  until something hits a limit. Another figure  shows  the  motor and  gear  with  proportional  and integral  (PI)  control. The position  takes  longer  to  settle out  than  the  system  with  pure proportional  control,  but  it  will not settle to the wrong spot.
Fig 3. Impulse response of pure integral part

Fig 4. Impulse response of proportional + integral parts together
-          In general, if you can’t stabilize a plant with proportional control, you can’t stabilize it with PI control. We know that proportional control deals with the present  behavior  of  the  plant,  and that  integral  control  deals  with the past behavior of the plant. If we  had  some  element  that  predicts  the  plant  behavior  then this  might  be  used  to  stabilize the plant. A differentiator will do the trick. The  differential  term  itself  is the  last  value  of  the  position minus the current value of the position. This gives you a rough estimate  of  the  velocity  (delta position/sample  time),  which predicts where the position will be in a while. With  differential  control  you can stabilize the precision actuator system. Below figure shows the response  of  the  precision  actuator system with proportional and derivative (PD) control. The next figure shows  the  heating system with PID control. You can see  the  performance  improvement to be had by using full PID control with this plant.
Fig 5. Impulse response of proportional + derivative parts together

Fig 6. Impulse response of proportional + integral + derivative parts all together

When PID is implemented, an important issue is to set gains of every part in that way, to achieve proper characteristic. The most common cases are presented below:
Fig 7. Different impulse responses
Above figure illustrates the two mutual excluding wishes presented above, and the compromise. The figure shows the response in the process output variable due to a step change of the set point. (The responses are with three different controller gains in a simulated control system.) It is useful to have this compromise in mind when you perform controller tuning.

Depending on every information presented earlier, we perform a small application to tune PID, which we want to apply in quadrocopter. For now it is a very simplified version, and it will extended in nearest future. Below we are presenting how it behaves:



Fig 8. Our PID simulation and overshot parameters

 
Fig 9. Our PID and long-time stabilizing signal (a lot of oscillations)

Fig 10. Our PID and quite fast stabilizing of signal

As you can see, tuning of PID controller is not a simplest issue. That’s all for today. Have a nice weekend :)

References:
1. http://blog.nikmartin.com/2012/11/process-control-for-dummies-like-me.html
2. http://home.hit.no/~hansha/documents/control/theory/tuning_pid_controller.pdf
3. http://nicisdigital.wordpress.com/2011/06/27/proportional-integral-derivative-pid-controller/
4. http://igor.chudov.com/manuals/Servo-Tuning/PID-without-a-PhD.pdf

Monday, May 20, 2013

Remote controller - part 3.



Welcome everybody :)
Our last posts contains a lot of text. Now it’s time to show you some photos and pictures of what did we achieve in the last few weeks. Photos are arranged in order of manufacturing process of PCB. At the end there are some photos of our (from now) wireless  and mobile PS2 PAD, which will be used as a remote controller to our quadrocopter. In the last photo we can see a comparison – from what we started, and where we are.
That’s all for now. Enjoy! ;)

Electrical schematic of PCB
Top layer of PCB
Bottom layer of PCB
Both (top and bottom) layers of PCB (designing program view)

PCB after etching (top)
PCB after etching (bottom)
PCB after tin plating (top)
PCB after tin plating (bottom)
PCB after soldering (top)
Description of the main components (top)
PCB after soldering (bottom)
Description of the main components (bottom)
 
 
 
 
 
 
 
 
 
 
 
First version vs final results


Sunday, May 12, 2013

Additional external devices


Hello. Today I’ll describe an additional devices, which could be useful during quadrocopter’s flight.

             1)      Accelerometer/Gyroscope
Nowadays, there’s increasing amount of both devices “hidden” in one package, so I’ll describe it together.
Accelerometer is a kind of devices, which measure the acceleration in different directions. The main force, which act on us every time is gravity, but by moving something we can produce acceleration. This force is visible for example during moving by cars or other means of communication, and physics have described it well for hundred year. Accelerometer can measure force acts on different directions, but most common type is three-axis device. It measures acceleration like in Cartesian coordinate system (z axis corresponds to gravity force). Also, if accelerometer rest relative to the Earth's surface, it will indicate approximately 1 g force.
There’s a few kind of electrical accelerometers: piezoelectric, piezoresistive, capacitance, and MEMS (micro electro-mechanical systems), and all of devices acts in different way. In piezoelectric accelerometers every change of acceleration change a charge of piezoelectric crystal. Changes can be observed by an implemented circuit and then transmitted to the user. Piezoresistive devices change its resistivity due to outer forces, and the Wheatstone bridge implemented in core helps to detect it. Capacitance devices act by changing a capacitance of built-in sensitive capacitor. It’s changing its charge depending on accelerate force. Then, the very precise analog-to-digital converter reads this value (after an amplification) and sends it to user. MEMS sensors works in the other idea. It contains a small heater at the bottom of a very small dome, which heats the air inside the dome to cause it to rise. A thermocouple on the dome determines the levels of signal - temperature (like ADC before) and in this way the acceleration is detected.
Accelerometers can be used to measure vibration on cars, machines, buildings, process control systems and safety installations. They can also be used to measure gravity, seismic activity, inclination, machine vibration, dynamic distance and speed with or without the influence of gravity. Nowadays, accelerometers are more and more popular in smartphones, tablets and other kind of electronic amusement, where movement has a significant influence of contest. There is a lot of software applications which react on move of user (and there are usually connected with some gyroscope). Nevertheless, now almost every new phone, tablet has accelerometer (it has also gyroscope, which is described below).
Gyroscopes measure angle of rotation or movement.  Mathematically, it is easier to works with accelerometer in Cartesian coordinates. Using gyroscope, it is easier to use cylindrical coordinate system. Gyroscope is more complicated than accelerometer, so if anyone is interested in: how it exactly works, please refer into some more specialist literature. Electronic devices are usually based on similar constructions like those mentioned earlier. Applications also are similar.
 Gyroscope also can act in three dimensions (due to different coordinate system, there are not similar to accelerometer’s one, but the main rule is exactly the same). And if our device has three axis accelerometer and three axis gyroscope, we can call it 6-axis motion device.
Why am I describing accelerometer and gyroscope? Because it is most important external device, which we will use in our quadrocopter project. Now I can tell that it is important to build reliable PID controller, and it is necessary during flight. We are using MPU-9150 from Invensense. It is MEMS sensor, including accelerometer, gyroscope and accelerometer and also can measure temperature . It is 9-axis motion device (3 axis for accelerometer, 3 axis for gyroscope and 3 axis for magnetometer); it is very precise low-power sensor with changeable ranges. It could communicate by I2C serial bus (100kHz and 400kHz). The most important thing is, that it has implemented DMP (Digital Motion Processor) with FIFO buffer and possibility of data fusion in few ways (for example: raw data, quaternions, Euler angles etc.) and sending it. It is very interesting device. 

             2)      GPS Tracking
GPS (Global Positioning System) is well known now, cause its popularity. It can be found in mobile phones, tablets, navigation devices, buses and trams – it is everywhere! The main rule of working such a system is comparing times of propagating and phases of electromagnetic waves transmitted from space satellites. Then, some complicated algorithms are able to determine the exact position. If anyone is interested how it exactly works – please refer to some special literature.
Why could it be useful in quadrocopter? To determine the position of vehicle in any time of flight (but please still remember that GPS device cannot refresh with higher frequency than 10 Hz), and then for example save it in memory (SD or MMC card) and display coordinates as a points on map on personal computer. 

             3)      Altitude meter
Altitude meter, or altimeter, is useful device to determine approximately altitude of flight. In some cases, it depends of Above Mean Sea Level, but not always. The most reliable way to determine altitude in quad is to measure air pressure differences (higher altitude=lower pressure) during the flight. The simplest way to obtain this is using some barometer or other sensor which can measure air pressure. Producers sometimes gives an equations to determine exact altitude while pressure is changing. Approximately, air pressure decreases with an increase of altitude—100 hectopascals per 800 meters. If we had respectively sense device, we can achieve even less than 1 meter accuracy of changing the altitude! I will not describe how barometer works, I can add that in some cases GPS can determine altitude (if 4 or more satellites are reachable in our reception, but it is not very precise way).
It is everything for today, in nearest future we will show our progresses with more detail. We will publish some schematics, PCB projects, how PS2 controller works and more details about PID controller implemented in microcontroller. Stay tuned with us!

References:
             1.       http://en.wikipedia.org/wiki/Accelerometer
             2.       http://www.sensr.com/pdf/practical-guide-to-accelerometers.pdf
             4.       http://en.wikipedia.org/wiki/Gyroscope
             5.       http://www.invensense.com/mems/gyro/mpu9150.html
             6.       http://en.wikipedia.org/wiki/GPS
             8.       http://en.wikipedia.org/wiki/Altimeter

More sophisticated links:
             1.       http://www.memsuniverse.com/1548-2
             2.       http://www.pcb.com/TechSupport/Tech_Accel.aspx#.UY-bUsrg2So
             3.       http://www.astrise.com/research/library/memsgyro.pdf
             4.       http://rhp.detmich.com/gps.html
             5.       http://www.hills-database.co.uk/altim.html
             6.       http://www.dutchops.com/Plane_Tech/Instruments/Altimeter.html