The meaning of PID algorithm and its application, PID Foundation, suitable for people who do not understand the PID algorithm to see!

Source: Internet
Author: User

first inserted sentence advertisement, I QQ522414928, not familiar with PID algorithm can exchange learning together, at any time online

  in the formal entry to the text, to supplement my study of the background of the PID algorithm, first introduce myself: I a junior electronic professional students, what school you leave it, school general, ordinary two of the institutions. By now it can be said that I have studied fast two years of PID, this period has done the windsurfing angle control system, has done the balance car, has done the inverted pendulum, has done the cricket control system, has done the OPENMV small ball tracking system, has done four rotors and so on. Can say now is very familiar with the PID algorithm, including the single-stage PID algorithm and multistage pid algorithm. to now feel in fact this PID algorithm is still very classic, very useful, then a few lines of simple code, you can achieve automatic tracking, automatic follow, balance and other operations, the use of a wide range. If you do not PID algorithm, most of the control actually you can not achieve, if this classic and simple algorithm you will not, and other control class algorithm estimate you will not. May let you do a product or participate in certain control competitions, obviously, do not PID these algorithms, you can only do simple logic control, and logic control is too simple, a few if () sentence judgment is clearly not satisfied with the needs of the control class design. In addition, many do not need PID algorithm design can also be added to the PID algorithm, which can make your design more stability and challenge, some must need PID algorithm design, no PID can not form a closed-loop control, is simply can not be completed.

  Not much to say, I like simple rough, like to simplify the complex things, a lot of electronic tutorial although the PID algorithm introduced is very comprehensive, but the complexity of writing, today I use the language of easy to understand the complex problem simplification:

  let's explain the traditional bit-based algorithms, The simple logic algorithm:

① First take the thermostat, if you want to boil water to 80 degrees, The simple logic is to add a temperature sensor and an electric boiler in the water, and then use a single-chip microcomputer temperature, if the if (temperature <80), then you give the electric boiler heating water boil, if if (temperature >80 degrees), then I stopped heating. Think about it, and finally you get the water temperature will be 80 (can be slightly different from top to bottom) degree? The answer must be no. ( Here, do not dogma, do not ask why you will boil water to 80 degrees, directly to boil the water do not, if you have such a doubt, do not look again, you do not understand the algorithm. ) Why is this? Let me explain, when the sensor temperature reached 80 degrees, the SCM control heater stop heating, although the heater power off, but the heater is still more than the temperature of water, so the heater will not immediately stop heating, but continue to heat water for a while until the same temperature as water, when the water temperature will be higher than 80 degrees, Maybe the residual temperature of the heater will heat the water to 90 degrees, right! Then the water and the heater together to cool down, under normal circumstances, the heater cooling speed will be faster, so when the water temperature drops to 80 degrees, the temperature of the heater is less than 80 degrees, then the sensor detects that the water temperature is less than 80 degrees, the microcontroller also control heater heating, and at this time the heater temperature is not less than 80 degrees, So you need to warm up and then water heating, during the preheating period of time the water temperature may be reduced to 75 degrees before the heating began. Therefore, the water temperature can not be maintained at 80 degrees up and down slightly floating in the range, the water temperature has been in 75 degrees to 90 degrees floating between!

  ② again take the balance car system, you need a gyroscope sensor, such as (mpu6050), first said the principle of balancing the car, to avoid some people do not understand, balance the car why two wheels can stand, we must all military training, standing over the military posture, the instructor let you lean forward, but only a slight forward tilt, If you can lean forward 45 degrees, then you must not control the balance of the body, you need to move forward to achieve balance. Balance car with this principle is the same, if the car to fall forward, then I let the wheel to maintain balance, if the car back down, then I let the wheel after the maintenance of balance, the principle should understand it! ( If this principle does not understand the proposal do not learn, but also do not control the direction, to avoid learning for a while to change the time to waste ) to continue, assuming that the car gyro angle 0 degrees when the car is balanced, if the angle is greater than 0 degrees I let the wheel forward, if the angle is less than 0 degrees I let the wheel turn, Obviously, the car is not balanced, due to the inertia of the car, a bit may be over the tune, directly down. The principle is similar to boiling water, not much to say.

Let's start with the PID algorithm:

  First of all, the PID three parameters, p is the proportion, I is the integral, d is differential; many people know these three parameters, but do not understand the meaning behind the representative, why use proportional integral differential. Do not hurry to listen to my slow to introduce you, as long as I introduced, you will understand.

  First of all, introduce the proportion of p,p, light with a proportional algorithm its structure is this:

ERR (Error) =setpoint (setpoint)-actual_value (the actual value measured by the sensor) (the concept of error should be understood by everyone)

Output (input value such as PWM) =p (scale factor) *err (Error)

Continue tomorrow, the roommates are sleeping today, do not disturb.

The meaning of PID algorithm and its application, PID Foundation, suitable for people who do not understand the PID algorithm to see!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.