Design of automatic target spray control system based on AVR microcontroller

Publisher:cwk2003Latest update time:2013-10-09 Source: eefocusKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Introduction

As we all know, China's pesticide production technology is at the international advanced level, but the current situation of China's plant protection machinery and pesticide use technology is seriously
backward and is extremely disproportionate to China's rapidly developing pesticide level. It has seriously hindered the prevention and control of crop diseases and insect pests, and brought
negative
effects best pesticide utilization rate is less than 30%, and the amount of pesticide loss is as high as 60%~70%, which not only causes great economic losses, but also
causes serious "pesticide residue problems" and environmental pollution. The use of automatic target spraying technology can save 50%~80% of pesticides,
so the research on target spraying technology will become the next important research direction of China's plant protection machinery. To this end, this paper proposes
a control system that uses the ATmega16 microcontroller of the AVR series as the CPU, the PC as the host computer, and the signal collected by the camera
as the trigger signal, combined with the microcontroller control technology and digital image processing technology to realize automatic target spraying.

2. System Working Principle

The system structure diagram is shown in Figure 1. The experimental device uses a PC as the host computer, and the rotation of the turntable simulates the movement of
the tractor The turntable is placed with simulated weeds as targets. The PC
processes the signal collected by the CCD camera, and the collected color image is segmented using the green dominance method. When the green component is greater than a certain threshold, it is
determined that there is a target under the camera. After the target is identified, the control signal is sent to the microcontroller through the serial port. According to
the different , the corresponding delay time is set to delay the signal. When the weeds reach the bottom of the nozzle, the actuator is controlled
to perform spraying, thereby realizing automatic target spraying.
 

3. Hardware structure design

The hardware system is mainly used to achieve the following functions: (1) realize serial communication with the host computer; (2) provide a human-machine interface,
which can set different delay times according to different speeds; (3) output control signals to control the opening and closing of the solenoid valve. Based on the functional requirements, reliability, product cost, and ease of use
of ,
the hardware schematic diagram of the automatic target controller is designed as shown in Figure 2.
 

 

3.1 MCU Selection

The system uses the AVR series MCU ATmega16 as the system CPU. AVR is a
high-performance, low-power 8-bit new MCU produced by Atmel. It adopts advanced RISC instruction structure, has fast execution speed, can reach
1MIPS/MHZ, strong port drive capability (20~40mA), and all have online download function. ATmega16 belongs to
the AVR mega series high-end MCU, with 16K bytes of system programmable Flash, and a general synchronization and
 

The USART can provide clock synchronization for the host or slave, which can greatly simplify the serial port communication between
the microcontroller and the PC. In addition, the ATmega16 microcontroller also has a JTAG interface, through
which online program download and on-chip debugging can be performed. This system uses the JTAG interface for online program download and on-chip debugging
.

3.2 Data display and button settings

Considering the actual target delay time, a 2-bit common cathode super bright LED is used, the delay time range is 0.0~9.9 seconds, and
IN74HCX245 is used as the LED display driver. Among them, pin 1 is the direction selection bit, pin 19 is the output enable bit,
pin 1 is connected to a high level, and pin 19 is grounded, indicating that the data output direction is from A to B. The system has a total of 4 buttons,
including 2 plus buttons and 2 minus buttons. S2 and S3 are plus buttons, and each press adds 0.1s and 1.0s respectively. S4 and
S5 are minus buttons, and each press subtracts 0.1s and 1.0s respectively. The buttons adopt a scanning mode. During initialization, the PB0,
PB1, PD4, and PD5 bits are set to input, high level, and internal resistor pull-up enable. By scanning the above four bits to see if
they are low level, it is determined whether the button is pressed. After pressing, the corresponding plus and minus flag position is set to 1, and then the delay
time is changed accordingly, and sent to the digital tube for display.

3.3 Communication Design

The communication between the lower computer and the upper computer adopts the RS232 bus standard, and
the communication circuit with the upper computer is composed of MAX232 and the USART serial port of the ATmega16 microcontroller. TXD and RXD are the sending pin and receiving pin of the USART serial port of ATmega16
. [page]

3.4 Output Control

The control signal of the microcontroller is output through the PC0 pin. PC0 is connected to a solid-state relay (SSR), which
controls the opening and closing of the solenoid valve. When PC0 is at a high level, the relay closes the switch, turns on the power, and opens the solenoid valve for spraying;
when PC0 is at a low level, the switch is disconnected, the solenoid valve is closed, and no spraying is performed.

4. Software structure design

The automatic target control system running program is written in C language, with modular design, and the whole program is
composed of functional module subroutines. The host computer software is developed based on Visual C++6.0.

4.1 Lower computer software structure

The main software modules of the lower computer software include initialization, delay, display, keyboard scanning, interrupt processing and other functional modules.
The delay function uses the loop counting method. The crystal frequency of the microcontroller is 7.3728MHZ, and the number of counting cycles is 1832.
Under the simulation of AVR Studio, the error of 1ms is 0.44us, so it can fully meet the actual requirements. The delay
time , the serial port is in asynchronous communication mode, 8 data bits, 2 stop bits, and the baud rate is set to 9600. The main program
flow chart is shown in Figure 3.
 

4.2 Host computer software structure

The host computer software was developed based on Visual C++6.0. The host computer software mainly consists of two parts: (1) serial port communication
part, (2) image processing part.
The serial port communication is implemented through the serial port class CSerialPort [3]. The image processing part uses a capture card to capture images in real time.
The image capture card of this system is the OK_C30A capture card of Jiaheng Zhongzi Company. This card is based on the PCI bus and can capture both
color and black and white images. It is suitable for research
and development and engineering application fields such as image processing, industrial monitoring and multimedia compression and processing [8]. Image acquisition and display are realized through the API provided by the company. Real-time image acquisition
is realized by responding to the WM_TIMER message in VC, that is, the image is captured and displayed by calling the capture card
API in the OnTimer function at regular intervals. Since weeds are green, the 2g-rb component is used to segment the image [4]. When
its value is greater than a certain threshold, the pixel is considered green. When the green pixel occupies more than a certain proportion of the entire image, it is determined that
there are weeds under the camera, and then the signal is sent to the lower computer through the serial port.

5. Experimental Results

This experiment was conducted on a turntable with a diameter of 67 cm, and the rotation of the turntable simulated the movement of a tractor. This experiment measured the actual target delay time at
different speeds, and a stopwatch was used to measure 20 times at each speed. The experimental data are shown in Table 1.

The set delay time is the delay time T in the software, and the actual delay time is the actual time from the camera collecting the target image to the
actuator spraying. The maximum speed that can achieve automatic target alignment is 38r/min, that is, 1.33m/s.
And from the data in Table 1, it can be seen that the delay time error is less than 0.2s, which can meet the requirements of automatic target alignment.

6. Conclusion

This system realizes automatic targeting of pesticide spraying by controlling the solenoid valve, and has been successfully debugged under laboratory conditions.
The system runs stably, has accurate delay, and can achieve precise targeting within a certain speed range, which greatly improves
the utilization rate The hardware implementation is simple, laying a good foundation for further promotion in the field. If the image
processing algorithm can be further optimized, the image processing time can be reduced, and the response speed of the hardware can be improved, the walking
speed , and the ability of the image processing algorithm to handle weed recognition under complex backgrounds can be improved,
automatic targeting spraying can be realized in complex field environments.

Keywords:AVR Reference address:Design of automatic target spray control system based on AVR microcontroller

Previous article:Remote keyless entry solution
Next article:Design of wireless sound amplification system based on ATmega8

Recommended ReadingLatest update time:2024-11-16 16:32

avr利用pwm控制led光暗及峰鳴器音量大小
//ICC-AVR application builder // Target : M16   // Crystal: 4.0000Mhz   #include iom16v.h    #include macros.h    #define uchar unsigned char #define uint unsigned int void port_init(void); void timer0_init(void); void init_devices(void); void delay_short(uint t); uchar scan_key(void); void port_in
[Microcontroller]
AVR MCU Learning (V) Key and Digital Tube Programming
Programming of buttons and digital tubes AVR  IO port input mode and pull-up resistor Programming of Selecting Structure Statements and Key Query Methods Basic principles of digital tubes Scanning mode displays multiple digital tubes 1. Input status IO register setting     1. When a certa
[Microcontroller]
AVR MCU Learning (V) Key and Digital Tube Programming
AVR IO output buzzer control program
System functions Use AVR to control a buzzer. You can control the buzzer as you like and prevent it from making random sounds! hardware design For details about the I/O structure and related introduction of AVR, please refer to the Datasheet. Here we only briefly introduce some of them. The following is the I/O pin
[Microcontroller]
AVR IO output buzzer control program
AVR high voltage parallel programmer manufacturing method
I just happened to have a few locked M8s, and I guess even RESET was disabled, so these chips can no longer be restored through the download line. In order to reduce losses (the current online price of atmega8 is more than 20, and I am not sure it is a brand new original product), I searched on the Internet for a whil
[Microcontroller]
AVR high voltage parallel programmer manufacturing method
Using AVR microcontroller to simulate comparator
  The analog comparator compares the input voltage of the positive PB2 (AINO) and the negative PB3 (AINI) . When the voltage of PB2 is higher than the voltage of PB3, the analog comparator output pin ACO is set to 1. The      analog comparator control and status register ACSR address is $018 ($28), and the reset value
[Microcontroller]
Using AVR microcontroller to simulate comparator
Analysis of EEPROM Reading and Writing of AVR Microcontroller
Introduction: This article introduces the time problem of reading and writing data in EEPROM of AVR microcontroller, and analyzes the advantages and disadvantages of three methods. Since the AVR EEPROM write cycle is relatively long (usually in milliseconds), special attention should be paid during programming. Ther
[Microcontroller]
AVR power-off protection circuit design analysis - circuit diagram reading every day (221)
  The BOD circuit of AVR generates a reset signal when the voltage is too low (lower than the set value) to prevent the CPU from accidentally operating. The protection function for EEPROM is to keep the RESET signal low when the voltage is too low to prevent the CPU from accidentally operating and modifying the conten
[Microcontroller]
AVR power-off protection circuit design analysis - circuit diagram reading every day (221)
Learning experience of AVR and PIC microcontrollers
      The key to successfully compiling two types of MCU project files is that the project file name and storage directory must be in English letters and must not be Chinese character directory! Otherwise, there will be compilation errors. I used the Chinese character directory "My Documents" to compile the project fi
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

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号