JFET

2021 Electric Competition-F Question-Intelligent Medicine Delivery Car-National Second Grade Work-Super God Sentai

 
Overview

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

①.Task
        Design and build an intelligent medicine delivery trolley to simulate the delivery and pickup of medicines in hospital pharmacies and wards. The structure of the hospital is shown in Figure 1. The walls on both sides of the hospital corridor are represented by solid black lines. A solid red line in the center is painted on the floor of the corridor , and a black numbered removable paper identifying the ward number is placed. The positions of the pharmacy and proximal ward numbers ( No. 1, 2) are fixed as shown in Figure 1, and the middle ward and distal ward numbers (No. 3-8) are randomly set during the test.
        Working process: The contestant manually places the trolley at the pharmacy (the front of the trolley is projected in the door area, facing the ward), holds a numbered paper, and the trolley identifies the ward number, and loads about 200g of medicine into the medicine delivery trolley at one time; trolley detection After the medicines are loaded, they will automatically start transporting; the car will automatically identify and find the path according to the identification information and deliver the medicines to the designated ward (the front of the car is projected in the door area), light up the red indicator light, and wait for the medicines to be unloaded; the ward will manually After unloading the medicine, the car automatically turns off the red indicator light and begins to return; after the car automatically returns to the pharmacy (the front of the car is projected in the door area, facing the pharmacy), the green indicator light turns on.
②.Requirements
1. basic requirements
(1) A single trolley delivers medications to designated proximal wards and returns to the pharmacy. The delivery and return times are required to be less than 20 seconds, and points will be deducted for overtime.
(2) A single trolley transports medicines to the designated central ward and returns to the pharmacy. The delivery and return times are required to be less than 20 seconds, and points will be deducted for overtime.
( 3) A single trolley transports medicines to designated remote wards and returns to the pharmacy. The delivery and return times are required to be less than 20 seconds, and points will be deducted for overtime.

 

 2. play part
(1) Two trolleys work together to transport medicines to the same designated central ward. Cart 1 recognizes the ward number and loads the medicines and starts transporting, and waits to unload the medicines after arriving at the ward; then, Cart 2 recognizes the ward number and loads the medicines and starts transporting, pauses after reaching the self-selected pause point, lights up the yellow indicator light, and waits for Cart 1 to unload. ; Cart 1 unloads the medicine and begins to return, while controlling car 2 to extinguish the yellow indicator light and continue transportation. It is required that the total time from when cart 2 starts transporting to when cart 1 returns to the pharmacy and cart 2 arrives at the ward (excluding the pause time when cart 2's yellow light is on), the shorter the better. If it exceeds 60 seconds, 0 points will be awarded.
( 2) Two trolleys work together to deliver and pick up medicines from different remote wards, with trolley 1 delivering medicines and trolley 2 picking up medicines . Cart 1 identifies the ward number and loads the medicines and starts transporting them. Cart 2 identifies the ward number at the pharmacy and waits for the order from Cart Cart 1 unloads the medicines and starts to return, and at the same time sends a command to start picking up medicines to Cart 2; Car 2 starts after receiving the medicine retrieval instruction and stops when it reaches the ward, with the red indicator light on. It is required that the total time from when cart 1 returns to the pharmacy and when cart 2 arrives at the medicine collection ward should be as short as possible. If it exceeds 60 seconds, 0 points will be awarded.
Topic analysis :
The tasks can be simply divided into 3 parts:
(1) Line patrol movement. Completing the most basic mobile functions is the basis of all functions. This work uses grayscale sensor tracking and stepper motor line-following movement solutions.
(2) Identify the ward number. OpenMV, k210, Raspberry Pi and other visual microcontrollers can be used for identification. Since there is no k210 prepared in advance, and the Raspberry Pi is large in size and consumes a lot of power, the most common openmv is used. To ensure sufficient performance, openmv4plus is used.
(3) Dual-machine communication. This work uses Bluetooth dual-machine communication to achieve data sharing.
After completing the above three tasks, it is time to conceive and think about the logic of the car code. The next step is to debug the code more and fix the bugs.
 

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.

uDL5w3a5dhVp6KNTgJIJZkTMcY5NZ4LJ0eJkDS42.png

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.

2zXauUpEuSMt80VRUAGWtaTvouo38fEb1enKnOrD.png

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.

x4g1gOPrRTNESrdLPqL9Z4FlTlYBq5hikwvZMugO.png

(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.

zqep039aVQmj8OredlicbjtU4ykdlMh3btZSz8FM.png

(3) Buzzer drive circuit

shfThaC5Z09xWAT0bvUaVevAndUHFhNaFdGDW1f6.png

(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.

RyZ2lxMnD33mYgpyscsAPxhzKpEEQWWWy36neS1l.png

 

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.

xACQ9MolK1rxVcBuWRGWfblEwLocSqakd726MQyb.png

(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.

PPtiXitdamwauLJ923TdUJOTsSo0zTJK5DW2ahaP.pngWRy9MwrXYFLN8XhBJOOzPbtZgWe4EbyPeF63oah3.png

 

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.

VVdGScRzlB4yu1RAfX2xFZ3yjWUNE6kZf2SoZQYZ.jpeg

 

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 .

wkzv0AH778LGiKcqeiIXCc4RhdQgFU20T1SKyaPP.png

    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.

uHkKA7H4yY2bUDHFqx1oVFv62aOlESl8sSZYR7TQ.png

 

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.

cSR4eYeVPgZE7Ld7oyV2wKW9cIZDqm98rDyymQbv.png

 

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.

pUhgYVffHBFfKLqQEftuM5WAkTjY7CxHRSECso63.png

 

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.

RHN8OkFD8RpSt7t8uka5jrgF7CSYEBm1KEye8tao.png

 

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.

GXijYrSd7qhDa1THuEsM5VnHj1puyXaQVYFF2uVH.png

 

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.

VG38jDoLeX3SlN3If9U6MecBBwbHE8G9VpmpZaZj.png

 

6. Visual code flow chart

oRkqS87J3JKr1KJXWTA6GMA8iQ0RCFlfRY0pWb1o.png

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.

CYFv69svGoMAVWuZlfegCU7qJwH8EkK3yo43Nbbw.pngGjNR35msf1wqF6iZAbCeP56SgGKgKiY00cjXtM4W.png

 

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.

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2024-11-14 23:47:49
  • Battery Management Chip BQ28Z610 Problem Collection
  • From simulation to realization
  • 【DFRobot motor driver】+ unboxing and testing
  • EEWORLD University ---- Analog Electronic Circuits
  • 【GD32450I-EVAL】+ 07 Camera full screen display test
  • Implementation of MSP430F5438A interrupt system

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号