loading

KEYCEO-Design, Manufacturing And Development Services Of OEM Keyboard And Mouse Brands.


See How AVR Soft USB Interface Solves Many Problems of Traditional RS232 Interface Data Acquisition

1. IntroductionIn power production and electrical testing, it is often necessary to use portable PC to collect and process data through the interface.

See How AVR Soft USB Interface Solves Many Problems of Traditional RS232 Interface Data Acquisition 1

The commonly used data collector with RS232 serial port does not allow live (hot) plug-in, which is very inconvenient to use. And now most PCs do not have RS232 interface, especially portable computers. Instead, the USB interface. At present, the application of USB soft interface technology of AVR single chip microcomputer is very common. ATMEL company introduces in detail the use of ordinary IO port of AVR single chip microcomputer to realize USB interface function in avr309 software universal serial bus; At the same time, the programming method of ATmega8 program (Firmware) is introduced, and all assembler source codes are provided. Based on the source code, the author optimizes and combines various versions of USB soft interface firmware (original program) by referring to and analyzing different authors. After changing and deleting some programs, the performance is greatly improved. The CPU utilization is much lower than that of the source program. AVR single chip microcomputer ATmega8 has the performance and characteristics of AVR high-grade single chip microcomputer, and the price is only equivalent to that of low-grade single chip microcomputer. Its built-in multi-channel A / D converter meets the needs of analog data acquisition.

2. ATmega8 single chip microcomputerATmega8 is an AVR series single chip microcomputer of ATMEL company. It is an 8-bit single chip microcomputer based on AVR RISC structure produced by low-power CMOS process. Most instructions are executed in a single cycle. Successive approximation ADC with 10 bit accuracyThe ADC is connected with an 8-channel analog multiplexer and can sample 8-channel single ended input voltages from port C.

The single ended voltage input is based on 0V (GND). The ADC includes a sample and hold circuit to ensure that the voltage input to the ADC remains constant during conversion. The ADC is powered separately by the avcc pin. The deviation between avcc and VCC shall not exceed 0.3V. There is a nominal value of 2.56v and avcc reference voltage in the device. The reference voltage can be decoupled by adding a capacitor to the aref pin to better suppress noise.Because of the programmable characteristics of AVR single chip microcomputer in the system, the embedded system of single chip microcomputer can be designed and developed without buying expensive simulators and programmers; At the same time, it also provides a very convenient and simple learning and development environment for beginners of single chip microcomputer. Moreover, it is more comprehensive and perfect in terms of power saving performance, stability, anti-interference and flexibility.Compared with other microcontrollers, ATmega8 single chip microcomputer is simple and easy to use, low cost, low threshold for entering AVR series single chip microcomputer development, rich software resources and easy program development. As ATmega8 single chip microcomputer is a common chip, its characteristics, internal structure and pin description are not introduced in this paper.

3. Hardware circuitThe USB software interface data acquisition hardware circuit based on ATmega8 is very simple. ATmega8 microcontroller as the core, plus a small number of external components (as shown in Figure 1).The pull-up resistor R3 on the USB data line D - in Figure 1 is used for the host to identify the low-speed USB device (defined in the USB specification).

See How AVR Soft USB Interface Solves Many Problems of Traditional RS232 Interface Data Acquisition 2

12Mhz crystal and two 20p capacitors form the clock necessary for the operation of MCU (one data bit of USB has 8 clock cycles).

D is connected to PD2 and is also INT0 pin. D - connected to PD3. Resistors R1 and R2 play the role of current limiting and protection to prevent accidental damage to the USB port of the computer or the port of the single chip microcomputer. The power VCC required by the single chip microcomputer is directly supplied by the 5V power output from the USB port. Because the USB specification specifies that the level range on the data lines D and D - is 3.0V to 3.6V, and D1 and D2 are 3.6V zener diodes to limit the level on the data line. LED1 and R4 in the figure are power indication circuits. Leda1-leda6 and ra1-ra6 are a / D conversion channel indication circuits. L1, C3 and C4 are set according to the A / D conversion accuracy requirements in ATmega8 product instruction manual. Ri1-ri6 and ci1-ci6 are analog signal sampling input settings, and their circuits and parameters change according to different input requirements. J2 in the figure is the analog signal sampling input terminal, which can be connected to single terminal 0-2.56v and 0-5V input analog signals. Measuring AC parameters requires AC signal processing and input; To measure the differential analog signal, the input sampling circuit needs to be changed. The A / D conversion of ATmega16 can be either single ended input or differential input; There are also 2 differential input channels with optional gain of 10 times and 200 times; Just a few more pins, the circuit diagram has changed; The single chip microcomputer software can be compatible and transplanted, and several instructions about a / D conversion differential input and data processing are added. If necessary, please refer to ATmega16 product instruction manual (which can be downloaded from ATMEL's website).

4. ATmega8 single chip microcomputer program (Firmware)This program is based on single chip microcomputer ATmega8, and uses pure software to complete the receiving, sending and decoding of USB protocol, so as to realize the data communication function of USB interface; The analog data acquisition function is realized through the built-in A / D conversion of single chip microcomputer. The USB protocol defines that the communication rate of low-speed USB devices is 1.5m bits / s.If the single chip microcomputer uses the clock frequency of 12 MHz, the main frequency is 8 times that of 1.5MHz. In other words, the single chip microcomputer should accurately complete the acquisition or transmission of one (ordinary IO port) data bit every 8 cycles.

This situation has strict requirements on the timing of single chip microcomputer. Therefore, the core code of single chip microcomputer software must be written in assembly language. ATmega8 chip is AVR Series MCU of ATMEL company. ATMEL website provides AVR studio integrated environment (IDE) development software for free download.Assembly language is directly supported after installation. The firmware program is compiled, compiled and burned with this development software (burning with USB ISP download cable).The program is written in a modular structure. For the coordination and efficiency of each module, the USB interface is set as follows.

Status code = 1: indicates that the control port setup token packet is received (set after receiving the token packet in the interrupt)Status code = 2: indicates that the control port in packet is received (set after the token packet is received in the interrupt)Status code = 3: indicates that the out packet of the control port is received (set after the token packet is received in the interrupt)

Status code = 5: indicates that the data port out packet is received (set after receiving the token packet in the interrupt)Status code = 6: indicates the change of receiving address (set in the main cycle)Operation flag = 2: indicates that the control port setup packet data is received (set after receiving the packet in the interrupt)

Operation flag = 3: indicates that the in packet of the control port is sent (set after the in packet is sent in the interrupt)Operation flag = 4: indicates that the control port in packet is ready (set in the main cycle)Port number = 0: control port

Port number = 1: data in portPort number = 2: data out portPort number = 3: serial port status in port (USB virtual RS232 interface, CDC class specification requirements)

5. Conclusion

The program starts from the system reset, initializes the system (sets the stack address, memory and register initialization, a / D converter initialization) and sets the initial value of the soft USB interface, and then enters the main program to continuously detect the USB reset signal (the two data lines remain at the low level of 10-20ms). In case of reset, when multiple items share a total transmitter, once the total transmitter cannot be found immediately, it will become difficult to retrieve the required items. Therefore, a small transmitter can be installed on one or several items and an alarm can be attached to the total transmitter, so that the transmitter on the item can be used to sense and retrieve the total transmitter, Then use the total transmitter to retrieve the required items. In addition, it has a wide range of applications, such as museums and banks, and the market demand will be relatively large. It is one of the necessary products in modern society. Therefore, it has high promotion value and good application prospects.

GET IN TOUCH WITH Us
recommended articles
Capability Mold making Silicone molding
Innovative chocolate ultra-quiet structure design, more quiet to use, the touch area of the button cap is enlarged, more comfortable and will not be disturbed;
Step 1: HardwareArduinoI want to use a small Arduino board to keep this version as compact as possible. I have some pro trinkets, but they can't be used well for key...
Some of the keys on my USB keyboard aren't working?Well it is either the computer's USB port or the keyboard. Try using another USB port to plug your keyboard into. ...
The days of being tied down to your computer or having someone else move the slides for you are long gone. The modern Wireless Presenter is your ticket to an engaging presentation with the freedom to move around at will.
Today, every office uses 100s of computer systems to get work done. These systems come with multiple I/O devices that are aimed at providing comfort and efficiency for the user.
Intoday's fast-paced work environment, having the right office wireless combo can make all the difference.
The humble mouse is ubiquitous, whether you use a Mac or a PC, this peripheral is indispensable. But not all mice are created equal; today’s professional knows that.
Wireless mice have become more than a convenience over the years. For many professionals, they are a go-to option over wired mice because of the convenience of use, reliability, and ease of transportation that modern wireless mice provide.
What is the one peripheral you interact with the most on your office computer? That’s right! The Office Keyboard is your primary avenue of interaction with your machine and can make or break your productivity.
Keyboards are essential computer peripherals for ensuring smooth and efficient typing experiences. A reliable keyboard is essential whether you are a student or a professional gamer.
no data
CONTACT US
DONGGUAN KEYCEO TECH CO.,LTD 
Cell Phone/QQ/Wechat: 
+86-137-147-55740
Skype: rachel-comptuer
No.1,factory building, Tangkou, Miaoyi, Miaobianwang Village, Shipai Town Dongguan
STAY CONNECTED
              
Copyright © 2024 keyceo.com  |   Sitemap
detect