stm32 Bluetooth balanced car production project experience (a)

Foreword

Since the liver so much punctuality atom stm32 video, the project has not been done to practice. The balance of the car project can be said to be very suitable for practicing hand, also has some challenges, especially novice first time doing, to complete the overall framework is a certain degree of difficulty, I do not know where to start.

From experience started about half a month, finally realized Bluetooth remote control of the balance of the car, the way stumbled out of the pit has been repeated then climb out again fall into a pit next, write down here both to record and summarize this period of time to learn the knowledge and experience, on the other hand hopes to mine for other beginners. After all, I was doing when also been references to other bloggers and businesses, but also want to be able to help yourself mine. (The following are the author's own opinion, what is wrong, and the great God who can contact me correct)

Let's start demining:

Hardware articles:

1, the car's board, the proposal should be painted himself PCB, a holiday here because I forgot to go home electric iron, plus the epidemic had to buy businesses of the board. Here really want to Tucao about an intelligent AWE board, MPU6050 the break did not waste a pick, a key to download but also their own pull jumper, very inconvenient. Very limited time to develop, and some can only follow him to write.

2, the balance of the car is saying the effect of the hardware structure is actually a great relationship, in theory, the center of gravity closer to the car's axle, the easier it is to balance the car. So for starters, do not follow the structure of the car wash business, like treasure, avoid the top-heavy balance of the car is not easy. These relatively heavy battery like, may be considered in the following. I was like this:

Here Insert Picture Description

3, the wiring of the motor, this briefly thousand million, usually geared motor connected to the power supply of about 12V, i.e. M +, positive and negative M-, encoder 5V VCC and the GND contact, then phase encoder AB io ports to pick stm32 thousand million, the microcontroller can obtain the frequency of the electrical output of the encoder is calculated by the speed io port.

PID articles:

Car PID algorithm requires primarily upstanding controlled car output speed loop, speed loop, the steering ring.

Standing ring:

Upright carriage is the most basic control loop is needed to use the PD control, i.e. P (proportional control) and D (derivative control), calculated:

Vertical_Out=Vertical_Kp*(Roll-Med_Angle)+Vertical_Kd*(gyroy-0);

Roll MPU6050 wherein the angle is offset from the acquired car y-axis, Med_Angle car equilibrium is desired angle, i.e. the value for the mechanical, gyroy MPU6050 is obtained for the y-axis direction of the trolley acceleration.

, The car can be achieved by reacting angularly offset adjusting Vertical_Kp and Vertical_Kd, and positive feedback to maintain a balance. Alone not enough to make the car standing ring stand, the proportional control will react to the deviation angle of the car results in low shock, and derivative control in order to suppress the shock of the car, so the car stabilized.

Speed ​​loop:

The role of the speed loop is designed to allow the car can be stabilized state, by calculating the current speed of the car, and the car speed before the accumulation, PI control (proportional control and integral control).

Velocity_Out=Velocity_KpNow_Speed+Velocity_KiSpeed_S;

Now_Speed current car speed calculation, Speed_S is the accumulated value of the obtained speed of the car.
That Speed_S + = Now_Speed;
then because of the speed of the car before and after the positive and negative, so the work is to make the car speed loop speed values add up to zero, that is, so that the car can be back in place when subjected to interference, which tends to be stable.

To trolley stand upright with words and velocity loops can basically, the general effect is as follows:

Here Insert Picture Description

Steering ring:

Since the two wheels of the motor may cause the same output value will be a little gap, the steering action is to adjust the ring wheel speed difference between the two, i.e., using the acquired MPU6050 trolley acceleration offset from z-axis, and z-axis acceleration according different size assigned to the speed of wheels let it go straight.

Turn_Out = Turn_Kp * gyro_Z;
then let Turn_Out value plus a motor output, a further reduction Turn_Out thousand million. (Here we must note polarity.)

It is first introduced here, the next chapter is the software, I will write and write procedures pits the general framework of the program encountered are listed for your reference. During this busy time, after time I would put the whole project in my program to share public micro-channel number, there is a need to when you can download. If anxious can add micro-channel contact me on my public micro-channel number to me, I can share directly.

Readers want to be helpful, like it can look at my public, then I will study notes made in the above, we will be able to learn together!

Here Insert Picture Description
Alt

Published 19 original articles · won praise 12 · views 6094

Guess you like

Origin blog.csdn.net/Rosen_er/article/details/104710821