Design of intelligent information recorder based on AVR microcontroller

Publisher:平安幸福Latest update time:2011-09-30 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Introduction
With the development of computer technology, the monitoring of the use of various instruments is becoming more and more intelligent. In view of the shortcomings of the time recorder on the market, such as high cost, poor scalability, small storage capacity, and complex programming, this paper designs an intelligent time recorder by using AVR microcontroller as the core controller, high-brightness LCD as the display, and USB mobile hard disk as the storage device.

1 System hardware design
1.1 Overall composition of the system
The intelligent information recorder consists of a single-chip microcomputer, power supply, LCD display, keyboard input and USB module. The system composition block diagram is shown in Figure 1. The power supply in the system includes an external
power supply and a lithium battery. After powering on, the system main power supply supplies power to the circuit while charging the lithium battery. After powering off, the lithium battery supplies power to the USB to save the data. The main task of the LCD display part is to complete the query and display of the power on and off time, and to display the current system time when idle. The clock module uses the DSl302 chip, which is a trickle charging clock chip launched by DALLAS. It contains a real-time clock/calendar and 31 bytes of static RAM. It can communicate with the single-chip microcomputer through a simple serial interface. The real-time clock/calendar circuit can provide information on seconds, minutes, hours, days, weeks, months and years. The number of days per month and the number of days in leap years can be automatically adjusted. The USB module uses the USB disk read-write chip PB375A, which is a relatively simple USB disk read-write solution. It is not necessary to understand the complicated USB HOST underlying protocol and FAT file system (supports FATl2, FATl6 and FAT32 file systems) to use it. Instead, you only need to communicate with the MCU and the module through the SPI interface or UART, and execute a few simple commands to complete the functions of creating, reading, writing, and deleting files. It is very simple and convenient to use. In addition, for the microcontroller, it basically does not occupy the storage space of the microcontroller system, and only requires a few bytes of RAM and a few hundred bytes of code. Its serial port supports three baud rate options of 9600, 4800 and 2400 bit/s. Since it has a built-in 5 V to 3.3 V circuit, it can greatly simplify the design of peripheral circuits.


1.2 Hardware Circuit Design
This information recording instrument uses a high-performance, low-power processor ATmega64 as the central controller. Its operating voltage is 3.3 V and it has rich internal resources: including 53 programmable I/O ports, 7 external interrupts, 2 16-bit timers, 2 8-bit timers, 4 KB on-chip SRAM and 64 KB system programmable Flash memory. It also has a long erase and write life and can meet system requirements. ATmega64 and its peripheral interface circuit are shown in Figure 2.

The interrupt interface circuit of the instrument includes the power-on interrupt when the machine is turned on and the power-off interrupt when the machine is turned off. They are both composed of the optocoupler chip 6N137 and the NOT gate 74LVT04. Figure 3 shows the interrupt circuit. The power supply VC is connected to the input of the optocoupler after passing through 7805, and the output is connected to the INT0 of the microcontroller and the 1st pin of the NOT gate. The 2nd pin of the NOT gate is connected to INT1. Therefore, when the machine is turned on, the input terminal Vin+ of the optocoupler is high level and the output terminal Vo is low level, so a power-on interrupt (INT0) is generated; while when the machine is turned off, the input of the optocoupler is low level and the output is high level. Therefore, after passing through the 2nd pin of the NOT gate, the output is low level to generate a power-off interrupt (INT1).



The main function of the power switching circuit is to switch to the lithium battery to power the USB and save the data when the system is shut down. The power switching is shown in Figure 4. In the figure, when the external power is turned on, V is high to turn on the transistor Q2, and at the same time pull the base of Q1 to a low level to turn it on. The external power V passes through the diode D1 (VC) to power the microcontroller circuit and USB. Since the program sets POWER high at the beginning, Q2 is also turned on at this time. When the system is shut down, V becomes low and the transistor Q2 is turned off. However, since Q3 is turned on at this time, Q1 is still turned on, but the data is saved by the lithium battery at this time. At this time, the timer l of the microcontroller starts working, and after a delay of 10 s, the output of POWER is low, so that Q3 is turned off, and finally the base of Q1 becomes high, and the entire recorder is turned off.

2 System software design
The main tasks of the system software are USB reading and writing, LCD display, clock and keyboard programming. Serial communication is used between PB375A and the microcontroller. Among them, the microcontroller first
sends the command code and parameter information to PB375A, and PB375A performs the corresponding operation according to the command information, and then returns the operation status code to the microcontroller in interrupt mode. The communication format includes the start code (0x3A), operation code, data length and data packet. Its main operation codes are as follows:
Ox71: Detect whether the U disk is connected, and return 0 when connected;
0x64: Open an existing file, if the file does not exist, return Ox42:
0x65: Create a new file;
Ox7A: Determine the address of the read and write bytes;
0x7B: Return the read data in bytes.
Figure 5 shows the program flow chart of this system.


2.1 File creation and data writing
The command CMD_FileCreat can be used to create a new file. The file name should be in the format of 8+3 and must be uppercase letters or numbers.
Data writing can be achieved through the command CMD_ByteWrite.
The file can be closed through the command CMD_FileClose. Closing the file will automatically update the file length. In addition, it should be noted that only when the file is closed; the file is generated by default, otherwise no file is generated, and the following operations cannot be performed (for example, after creating a new file, if you start reading data without closing the file, the operation is invalid).
2.2 Append data to an existing file
The general commands for appending data to an existing file are as follows:
CMD_FileOpen: open the file;
CMD_ByteLocate: move the file pointer to the end (0xFFFFFFFF);
CMD_ByteWrite: write data;
CMD_FileClose: close the file.
2.3 Write data operation
When writing data, first read the value of the real-time clock DSl302 to determine whether the current time is the 1st of each month. If so, create a new vv-mm. TXT file is used to save the number of times the computer is turned on every day of a month, and then a new yy—mm—dd.TXT file is created to save the specific time of each power on and off. If it is November 1, 2009, first create 09-11.TXT and write 31 zeros, then read out its first number, if it is 0, create 09-11-01.TXT, write the power on time, then add 1 to the flag of the number of power ons, and then write the file 09-11.TXT. When the computer is turned on for the second time, the time is directly appended to the file. When creating the
file 09-11-01.TXT, save the current date and time. In this way, when the computer is turned off, the shutdown time will be appended to the file.
2.4 Query and display of date and time
When displaying the date and time to be queried, first open the date file for input, then read the data and store it in the display cache. In order to be able to read clearly on the computer, special characters such as space, carriage return, and line feed should be used when writing the specific time. Therefore, the data read by the microcontroller must be specially processed before being sent for display.

3 Conclusion
The information recording system scheme introduced in this paper is reasonably designed, easy to use, has a friendly human-machine interface and large data storage capacity, and can well realize the intelligent recording of time information. The intelligent information recorder designed using this scheme can meet the use requirements of various industrial occasions and has good promotion value.

Reference address:Design of intelligent information recorder based on AVR microcontroller

Previous article:Microcontroller development solutions
Next article:Design and implementation of a vision-based intelligent tracking vehicle based on AVR 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号