论文部分内容阅读
[Abstract]STM32F407 is a very popular chip as a microprocessor. It allows faster responses than ARM mbed LPC1768, and it has more pins for connections. In this design, a smart robot is designated. It has abilities such as color recognition based on OV7670. The motors will be driven by a H-bridge circuit configuration, and the power will be supplied by a 12V DC battery. This article will briefly introduce the considerations of the design.
[Key words]STM32F407, Smart robot vehicle, color recognition
中圖分类号:TU334 文献标识码:A 文章编号:1009-914X(2017)42-0287-01
Motor drive circuit and power system design
The best way to control a motor with differential inputs is through a simple H-bridge circuit, an electronic circuit that enables a voltage to be applied across a load in either direction.[1]
Figure 2.1:A diagram of H-bridge
BJTs are used in the circuit which can be controlled by gate voltage and allow a sufficiently large current flowing through. To avoid short circuit, transistors on one side cannot be on at the same time. To prevent such hazard caused by turn-on and turn-off time overlap, a time gap is set before changing the turning direction of the motor.
As a precaution against negative voltages on the chip, fuses are used between the inputs of each motors and supply voltage and ground to avoid reverse voltage. These fuses are often Schottky diodes that have a low forward voltage drop and a high reverse breakdown point. Side capacitors are also used to get rid of AC interference.
Power supplies to the microprocessors are 5V regulated voltage.
Camera design: colour recognition
The recognition of colour block is realizedby a camera which will be demonstrated.
OV7670 is chosen because it is cheaper. For OV7670, there are two different kinds. One is with FIFO(First In and First Out) and the other is without FIFO. The application of FIFO is working as a 3MB memory. It is designed for the MCUs which do not have enough processing capability for image. It can temporarily save the data transferred from camera.
Table 1: Typical specifications of different cameras
STM32F407 is especially appropriate when designing the camera. As there are 18 pins on the camera, a single microcontroller should be used to save the pins on the main MCU. This microcontroller is produced by ST microelectronic corporation. It has up to 140 I/O pins, 136 of which are fast with 84MHz so it has fast response. The programming of STM32 has two different editions. One is register edition and the other one is library function edition. Considering that image processing requires large memory occupation and fast processing speed, register edition is the better choice because the codes will directly initialize registers in the chip. In the register edition, targeted registers should be known by referring to the handbook. But in the function edition, the only job to do is to write corresponding pins’ name in the bracket. To eliminate random error as much as possible, calculating the mean value of RGB is a way to achieve this purpose. First, sample 5000 pixels in one frame and average r, g, b values, and the next step is to average the mean values from 10 frames. The code of this method is indicated in Figure 5.9.
Figure 5.9
The recognition of colors cannot be simply achieved by setting a fixed threshold. Under different intensities of illumination, RGB values would vary a lot. Subsequently, another method is used: to make mutual comparison between RGB values. The color with the highest value will be the result. However, when detecting the blue block, the gap between B and R, G is not large enough, so the way to solve this problem is to add anoffset number to B value for compensation when comparing. The number is different under different illumination conditions so samples are collected under different sunlight.
Conclusion
After testing, this robot works properly except for some extreme sunlight conditions in which external infrared sources significantly biased the results obtained by the camera. This requires further investigation. For example, some other new approaches could be used to recognize the color correctly based on the RGB values and current weather conditions.
Reference
[1] Al Williams (2002). Microcontroller projects using the Basic Stamp. Focal Press.
[2] Data sheet of L298N. SGS-THOMSON MICROELECTRONICS.
[3] Data sheet of lm2596. TEXAS INSTRUMENTS.
[4] An embedded real-time red peach detection system based on an OV7670 camera, ARM cortex-M4 processor and 3D look-up tables,Teixidó, Mercè. Published in: Sensors (Basel, Switzerland), v. 12 no. 10, pp. 14129 Date: 2012.
[Key words]STM32F407, Smart robot vehicle, color recognition
中圖分类号:TU334 文献标识码:A 文章编号:1009-914X(2017)42-0287-01
Motor drive circuit and power system design
The best way to control a motor with differential inputs is through a simple H-bridge circuit, an electronic circuit that enables a voltage to be applied across a load in either direction.[1]
Figure 2.1:A diagram of H-bridge
BJTs are used in the circuit which can be controlled by gate voltage and allow a sufficiently large current flowing through. To avoid short circuit, transistors on one side cannot be on at the same time. To prevent such hazard caused by turn-on and turn-off time overlap, a time gap is set before changing the turning direction of the motor.
As a precaution against negative voltages on the chip, fuses are used between the inputs of each motors and supply voltage and ground to avoid reverse voltage. These fuses are often Schottky diodes that have a low forward voltage drop and a high reverse breakdown point. Side capacitors are also used to get rid of AC interference.
Power supplies to the microprocessors are 5V regulated voltage.
Camera design: colour recognition
The recognition of colour block is realizedby a camera which will be demonstrated.
OV7670 is chosen because it is cheaper. For OV7670, there are two different kinds. One is with FIFO(First In and First Out) and the other is without FIFO. The application of FIFO is working as a 3MB memory. It is designed for the MCUs which do not have enough processing capability for image. It can temporarily save the data transferred from camera.
Table 1: Typical specifications of different cameras
STM32F407 is especially appropriate when designing the camera. As there are 18 pins on the camera, a single microcontroller should be used to save the pins on the main MCU. This microcontroller is produced by ST microelectronic corporation. It has up to 140 I/O pins, 136 of which are fast with 84MHz so it has fast response. The programming of STM32 has two different editions. One is register edition and the other one is library function edition. Considering that image processing requires large memory occupation and fast processing speed, register edition is the better choice because the codes will directly initialize registers in the chip. In the register edition, targeted registers should be known by referring to the handbook. But in the function edition, the only job to do is to write corresponding pins’ name in the bracket. To eliminate random error as much as possible, calculating the mean value of RGB is a way to achieve this purpose. First, sample 5000 pixels in one frame and average r, g, b values, and the next step is to average the mean values from 10 frames. The code of this method is indicated in Figure 5.9.
Figure 5.9
The recognition of colors cannot be simply achieved by setting a fixed threshold. Under different intensities of illumination, RGB values would vary a lot. Subsequently, another method is used: to make mutual comparison between RGB values. The color with the highest value will be the result. However, when detecting the blue block, the gap between B and R, G is not large enough, so the way to solve this problem is to add anoffset number to B value for compensation when comparing. The number is different under different illumination conditions so samples are collected under different sunlight.
Conclusion
After testing, this robot works properly except for some extreme sunlight conditions in which external infrared sources significantly biased the results obtained by the camera. This requires further investigation. For example, some other new approaches could be used to recognize the color correctly based on the RGB values and current weather conditions.
Reference
[1] Al Williams (2002). Microcontroller projects using the Basic Stamp. Focal Press.
[2] Data sheet of L298N. SGS-THOMSON MICROELECTRONICS.
[3] Data sheet of lm2596. TEXAS INSTRUMENTS.
[4] An embedded real-time red peach detection system based on an OV7670 camera, ARM cortex-M4 processor and 3D look-up tables,Teixidó, Mercè. Published in: Sensors (Basel, Switzerland), v. 12 no. 10, pp. 14129 Date: 2012.