<> subject ：
Programmed wind pendulum （C topic ）
【 Infrastructure 】： One long about 60cm~70cm
Thin tube of （ Rigid pipe ） The upper end is fixed on the support with a hinge , A group of DC fans are suspended below , Form a wind pendulum . Install a downward laser pen on the wind pendulum , At rest , The lower end of the laser pen is not more than
20cm. Design a measurement and control system , Control and drive each fan to make the wind pendulum move according to a certain law , The laser pen draws the required trajectory on the ground .
【 Basic requirements 】：
* Field input 4 Coordinate points , The range of coordinate points is [-30,30] within , Make the wind pendulum start from static ,10s The internal control laser pen points to the specified position and the stability time is required to be no less than 3s, The error does not exceed ±2cm.
* Draw the swing angle on the upper computer α And coordinates x Curve over time , It can clearly reflect the current pendulum angle and laser point coordinate position information , The angle error does not exceed ±1°, Coordinate distance error does not exceed ±2cm.
* Control the laser point to start from the origin , Pass successively 0,-30cm,-20cm,-10cm,0 ,10cm,20cm,30cm Points at , The stabilization time at each point shall not be less than
3s, And use buzzer to prompt , The whole process does not exceed 40s.
【 Play requirements 】：
* Set coordinates x1,x2, Make the laser point on x1 and x2 Swing back and forth between 3 More than one round trip , The error does not exceed ±2cm.
* Customize motion mode . Key input command “a#b” Indicates the arrival of the laser point a Stability at b second , During this period, the buzzer will sound ; Input instructions “c@d#e” Then it means that the laser point is c and d Swing between
e Round trip , And emit a beep every time it reaches the endpoint ; Between instructions ‘;’ interval ; The whole of all instructions is ‘%’ start , with ‘&’ end . Enter at the end ‘&’
after , The wind pendulum operates in cycles according to preset instructions .（ The total length of the instruction does not exceed 100 Characters ）.
* input “%-25#2;-7@14#3;17#1;11#3;7#3;&”
* The wind pendulum moves to -25cm Stability at 2 Seconds and issue 2 Second beep ;
* The wind is swinging -7cm and 14cm Swing back and forth between 3 Round trip ;
* The wind pendulum moves to 17cm Stability at 1 Seconds and issue 1 Second beep ;
* The wind pendulum moves to 11cm Stability at 3 Seconds and issue 3 Second beep ;
* The wind pendulum moves to 7cm Stability at 3 Seconds and issue 3 Second beep ;
<> Programme plan ：
The overall process of the topic is divided into three parts ： Hardware architecture , Bottom terminal part , Upper computer part ：
<> Hardware architecture ：
Scheme I ： Use the universal joint as the node of swing
, However, the universal joint can still move left and right after it is stuck in the left and right directions , It is mainly due to the influence of the slit at the middle contact point of the two universal joints , When it acts on the whole lever, the influence error is large, so this direction is not selected finally .
： Use hinge as the node of swing , The hinge can only be moved back and forth , The overall effect is good , Even if there is a gap between the left and right, the whole will translate , The overall use effect is good . The hinge needs to be punched by itself to keep the whole balance and move back and forth .
<> Bottom terminal part ：
Devices on peripheral backplane ：
* Master control select use STM32C8T6.
* input 4 Coordinate points are input with matrix keyboard .
* I2C The screen prompts the selection of keys and titles .
* L298N Carry out motor drive .
Devices on hardware architecture ：
* Mpu6050 Put it on the hardware .
* Two hollow cup motors are placed below .
* A laser head .
<> Upper computer part ：
Scheme I ： Via Bluetooth to serial port + screen ＋32 The big board is used as the upper computer to display the upper data .
Scheme II ： Direct connection through serial port cable ＋32 The big board is used as the upper computer to display the upper data .
Scheme III ： Connect the computer directly through the serial port cable to display the data above the computer ,delphi Write the upper computer .
<> Implementation process steps ：
MPU6050 realization ：
The gyroscope part uses its own serial port conversion mpu6050, Read the subsequent angular acceleration after initializing the vertical position through the official protocol .
Key implementation ：
Using the matrix keyboard , Judge the current key number after reading the pin level of each port for matching .
Screen implementation ：
PID control PWM：
Set according to the current deviation from the direction PWM The output of is then imported into the motor , Judge whether it is stable by angle difference or position difference .
<> Demo pictures ：
<> Problem summary ：
<>Q1： It can only be achieved when full duty cycle is given 29cm Amplitude of
terms of settlement
： At the beginning, the lower plate was made of large plate acrylic , And the top is fixed by enamel plate . Although the overall stability, but the weight is too large , By replacing the large acrylic plate of the lower plate with a small acrylic plate , And passed the test after canceling the enamel disk . Under the same condition, the full duty cycle can be achieved 37cm. Or by changing the position of the motor , Using two-way motor to drive at the same time can meet the demand , But this method requires two sets PID Configure , So choose to reduce the weight to meet the requirements .
<>Q2：L298N Unable to enable
According to the official manual ,L298N stay 2.3V - VSS
It is considered as high level between . But when using regulated power supply for testing 5V It has normal output when the enabling end is input ; When given 4V It has normal output when the enabling end is input ; When given 3.3V When the enable end is input, the output is 0.1V. Obviously, the input level of the enabling end is inconsistent . but 32 The output voltage of single chip microcomputer itself has the maximum limit 3.3V.
terms of settlement
： Because the time is wired, it is output through an external circuit PWM The signal is amplified again and then connected L298N Enable end . through the use of s9013 Low power NPN Reverse amplification by triode . Can put 3.3VPWM Output magnified to 4V Meet the input enable . And due to the use of reverse amplifier , So when the input level is low, the high level can be output .
<>Q3：L298N Large output voltage drop
L298N Under normal circumstances , There will be a certain pressure drop through load control . But the voltage drop is very huge when using the hollow cup motor . And the power supply of hollow cup motor is required , A large number of tests are needed to determine the final power supply access voltage .
Test results after using peripheral circuits ：
6V Power connection Missed load 5.22V output Turn-on charge 2.26V output
7V Power connection Missed load 6.17V output Turn-on charge 2.56V output
8V Power connection Missed load 7.2V output Turn-on charge 3.02V output
9V Power connection Missed load 8.07V output Turn-on charge 3.38V output
<>Q4：STM32 Insufficient push-pull output voltage
need 32 Modify the connection method of jumper cap on .
【 summary 】： At the beginning of this competition, it took a long time to build the structure ,L298N Part of it takes a lot of time to test the performance of the module . Make later adjustment PID Limited time .