I. Introduction
I have a lot of experience in building cars, so my main focus in e-sports is building cars. The racing questions in this competition matched my team lineup, and with the help of two powerful team members, I achieved good results in the second grade!
2. Team introduction
It is composed of captain Zhao Jiahui (electronic control programming), team members Chen Weiqian (visual recognition) and Wu Jinying (mechanical design), two of whom are seniors and one is a junior.
3. Project Analysis
4. System solution
1. Selection of microcontroller
The arduinoMEGA2560 microcontroller is used as the main control. Due to its open source code, the code is simple and suitable for novices to use. Powerful library functions can greatly reduce development time. And for this problem, the calculation speed is sufficient, so it is adopted.
2. Movement system
Using 42 stepper motor. This motor has high rotation accuracy, large torque, rated current of less than 2A , and simple control. It will not cause deviations in the number of rotation steps due to different drive voltages. It can walk out of a very good straight line without using closed-loop control and is not easy to go awry. , the motion displacement can be accurately controlled within a short distance. The driver adopts TB6600 H- bridge bipolar constant phase current driver. The drive and motor adopt Taobao finished product kits, and the drive subdivision is set to 800. Since the drive volume is large and the current of the 42 stepper motor is small when running, the metal casing (radiator) of the drive module can be removed, thereby greatly reducing the size and weight.
The front wheel is supported by a bullseye wheel. It is best to choose a bull's eye wheel with low friction. The bull's-eye wheel used in this work has high friction, so the speed of the motor cannot be increased too high, otherwise the friction will disrupt the movement of the car and make it tremble when walking.
3. Tracking system
An eight-channel grayscale sensor is used (only 4 channels are actually used). Adjust the threshold well to accurately distinguish red and white. It is recommended to use the grayscale sensor shown below. The tracing function can be completed by detecting the tracing code with very simple digital logic.
4. Vision system
The handheld ward number is identified by template matching. The reason is that the handheld ward number can dynamically adjust the distance and angle, and template matching can also be successfully identified quickly.
The ward number numbers on the ground are identified using the OpenMV4 H7 Plus neural network method. Compared with template matching, the recognition success rate is extremely high, as high as over 90%. Due to limited performance, the running image only has 2 to 3 frames, and it needs to stop in front of the ward number for a few tenths of a second to allow the image to stabilize to identify the digits.
When openmv is powered on, it executes a template matching algorithm to identify the handheld ward number. After identifying it, it sends the corresponding number to the microcontroller, and then openmv itself saves this "destination ward number". Then wait for the microcontroller to send '1'. Then the microcontroller controls the car to stop in front of the intersection. After sending '1', openmv uses a deep learning algorithm to identify the ward number on the ground, and compares it with the previously stored "destination ward number". If it is the left ward number posted on the ground If it matches the 'destination ward number', it will send '1', if it matches the right ward number, it will send '2', if it doesn't match, it will send '0'. The microcontroller controls the car based on the received 0, 1, and 2: go straight to the next intersection and resend '1', turn left to the destination ward number, and turn right to the destination ward number.
5. Communication system
Use HM-10 Bluetooth module for dual-machine communication. The master Bluetooth can only receive information from the slave Bluetooth and cannot transmit information to the slave Bluetooth. Therefore, the slave Bluetooth connects to car No. 1, and the main Bluetooth connects to car No. 2. Car No. 2 only needs to receive instructions from Car No. 1 to complete all tasks. Note: AT commands need to be set in advance to set the master-slave mode and automatically connect to Bluetooth.
6. Others
An OLED screen is used to display whether the reading of the ward number is successful this time, and to display the running status of some trolleys in real time to facilitate debugging. Set red, green and yellow indicator lights, buzzer prompts and other functions.
Use bilateral self-reset buttons as reset keys. Since the working levels of the main control microcontroller and OpenMV are inconsistent, the reset pin cannot be connected to the same button, so this button can be used to reset two microcontrollers with one click.
For drug detection, a simple infrared obstacle avoidance module can be used to detect high and low levels.
5. Schematic circuit analysis
1. Main control microcontroller expansion board
Since the PCB of this work is prepared in advance, many preset functional interfaces are not used, so only the schematic diagrams of the used parts are explained.
(1) Microcontroller and external pins
Among them, D2-D5 of arduino are connected to the motor drive module as IO ports to drive two stepper motors (each stepper motor is controlled by DIR and PUL). Some of the pins of D23-D37 are connected to the 8 numbers of the grayscale sensor. Signal port.
(2) Power input and output
12V is input from the round hole DC5.5 series interface, and goes straight out to power the stepper motor driver and stepper motor. The other way goes through the 5V voltage stabilizing module to power the microcontroller and other modules. Lead out 8 sets of 5V power interfaces for easy expansion.
(3) Buzzer drive circuit
(4) Traffic light drive circuit
There is no such design in the schematic diagram. This is made by on-site welding circuit. The three lights are connected to the D8, D9 and D10 interfaces of the microcontroller respectively.
2. Stepper motor drive signal integration board
Two stepper motors require two driver boards, which require more signal lines and power lines, which will lead to messy and loose wiring. For better stability, we made this signal integration board and used XH2.54 red and white strip cables. The connection is not easy to loose and is easy to plug and unplug.
(1) Schematic diagram
It is divided into 12V power input and output, and the wiring matches the IO distribution of the microcontroller expansion board.
(2) PCB and simulation diagram
The corresponding IO port numbers are added to the printing layer, and the dialer status corresponding to the stepper motor drive subdivision is marked. Moreover, the hole position and size of the PCB are completely suitable for the stepper motor drive module after the heat dissipation shell is removed, and can be directly installed on the drive, saving space.
6. PCB design analysis
Since the main difficulty lies in electronic control programming, PCB wiring is less difficult, as long as you have a certain foundation, and there is nothing that requires special attention.
7. Physical display
Car 1 and car 2 both use the same plan and model. Due to cost reasons, our team only has one openmv4plus on hand, and deep learning can only be run on 4plus. Therefore, Car 2 is equipped with openmv4 and uses template matching for identification.
8. Assembly of works
1. Complete vehicle model
The picture shows the 3D diagram of the mechanical structure of the car . The front wheel uses two bull's-eye wheels for auxiliary support, and the rear wheel is a power wheel driven by a stepper motor. Length 21cm , width 19.5cm , height 24.5cm .
In the picture, 1 is the bull's eye wheel, 2 is the eight-channel grayscale sensor module, 3 is the car base plate, 4 is the hexagonal copper column, 5 is the microcontroller and PCB expansion board, 6 is the camera bracket fixed base, 7 is the OpenMV camera, and 8 is the medicine. , 9 is the medicine bin, 10 is the infrared beam module, 11 is the stepper motor drive board, 12 is the ordinary wheel, 13 is the stepper motor, 14 is the 12V lithium battery, and 15 is the support base.
2. Chassis diagram
The picture shows the CAD drawing of the car chassis, which is made of laser-cut acrylic. The thickness is about 4mm.
9. Programming
1. Motion function
Take forward as an example: control the number of steps of the stepper motor through the number of pulses. If you want the motor to move around once, you need to give 800 pulses, and the displacement corresponds to the circumference of the wheel. The speed (frequency) of the pulses determines how fast the motor rotates.
The same goes for backward, clockwise and counterclockwise, only the directions of the A and B motors are different.
2. Tracking function
Q3-Q6 are the four middle grayscale sensors, which detect their levels and control the car to turn left or right according to the levels. In the function: (Anit)ClockwisePX(10,3000) is the (counter)clockwise micro-movement function, 10 is the step number, and 3000 is the speed (the smaller the faster). Advance(50,1800) is the advance function, 50 is the number of steps, and the speed is 1800.
3. Read ward number function
Among them, inData is a global variable of character type, which stores the received information and caches it. Aim is the destination global variable, and its numerical value represents the identified destination ward number.
4. Read the ward number function at the fork in the road
Customize the communication protocol with openmv, and start to identify the ward number at the fork in the road when 0x31 is sent. After receiving the returned characters, corresponding to left turn, right turn, and forward, the display will also display the corresponding Z, Y, and N. The u8g2 class function is the display function of OLED. You can learn how to use it by yourself, which is relatively simple.
5. Car 1 sends location information to Car 2
Define the absolute coordinates of the ward number. After the car 1 arrives at a certain receiving point, it will send the absolute coordinates of the receiving point (3 or 4, currently it has not completed tasks 5-8). After receiving this absolute coordinate, car 2 reaches the pause point. After the return of car 1 is completed, an executable command will be sent to car 2. At this time, car 2 will go directly to the corresponding mid-end ward based on the absolute coordinates received.
The code is not truncated because the following part is to send the absolute coordinates of the remote ward numbers 5-8. Without that step, this part is useless. The Mid variable in the function records the action of car 1 when it arrives at the middle ward. Mid=0 corresponds to a left turn, Mid=1 corresponds to a right turn, and Mid=2 moves forward. This is used to determine whether the end point of trolley 1 is in the middle ward or the far ward. The same variable is Long.
6. Visual code flow chart
7. Neural network training results
The training results based on some image data have reached 100% recognition rate. The confidence level of the actual detection results reaches more than 90% , which is enough to meet the identification requirements.
10. Summary
1. Choose the solution you are best at. For example, I have used stepper motor solutions in many car competitions. I have rich experience and a lot of old code, which saves a lot of coding time. Don't try other unfamiliar solutions, because 4 days and 3 pages is really urgent.
2. As the captain, you should set tasks according to the strengths and weaknesses of each team member. The captain should take on the important task of schedule planning, which is often "single-core and multi-thread" work. Every team member must have a strong sense of responsibility, which is key in selecting team members. For example, our team has a machine that is responsible for car assembly and 3D modeling and printing. It is extremely efficient. It was designed in half a day and the first car was assembled in less than a day, which saved our team a lot of valuable debugging time. .
3. Luck is also a part of strength. The topic of this competition is very suitable for our team's lineup. Car electronic control, neural network, and machinery perfectly match the advantages of the three of us. Maybe these are destined.
11. Attachments
Station B demo video: https://www.bilibili.com/video/BV1Qb4y1i7Sn/
See attachment for code.
Devices | Class | introduce | Datasheet |
---|---|---|---|
2501S-5P | The connector;Line of plate/line of wire connector | Number of pins: 5 Connector type: Header Contact type: Male Pin spacing: 0.098" (2.50mm) Series: XH XH connector XH2.50 | Download |
2501S-4P | The connector;Line of plate/line of wire connector | Number of pins: 4 Connector type: Header Contact type: Male Pin spacing: 0.098" (2.50mm) Series: XH XH connector XH2.50 | Download |
1MS3T1B1M2QES-5 | H=10.41mm | Download |
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet