Free Electronic Circuits & 8085 projects

Electronic projects with circuit diagram and 8085 microprocessor projects.

Data acquisition system circuit based on USBN9602

Published on Oct 28 2010 // Micrcontroller circuits

Data acquisition system circuit USBN9602

Abstract: Universal Serial Bus (USB) as a new computer bus interface standard, with a convenient, easy expansion, low cost, low interference characteristics, is very suitable for communication between host and peripheral interfaces. This paper introduces the USB-based Data Acquisition equipment development methods, including hardware design, Firmware (firmware) design, based on the Windows Driver Model (WDM) device driver design, and application software design, but also introduces USB-based remote data acquisition system.
Keywords: USB dongle crack anti-encryption technology
In industrial production and scientific and technical research process in all sectors, often on a variety of data acquisition, collection methods now commonly used in industrial PC, or install the data acquisition card inside the machine, such as A / D cards and 422 cards, 485 card, capture card installation trouble not only vulnerable to the environmental impact of the chassis, but due to the slot machine number and address, interrupt resource constraints, many devices can not be articulated; and Universal Serial Bus USB (Universal Serial Bus) can be made to resolve these conflicts.
89C51 design is based on USB bus using the data acquisition equipment, MAX485 can also be combined with remote data collection. The system has high reliability, cost-effective and multi-point collection and so on.
1 System hardware design
USB data acquisition hardware module is mainly composed of serial A / D converter, 89C51 chip, USB interface chip and multi-channel analog switches and other components. Overall hardware block diagram shown in Figure 1.
USB interface chip uses a National Semiconductor’s ASIC USBN9602. The chip integrated microprocessor interface, FIFO memory, clock generator, serial interface engine (SIE), transceiver and voltage converter, supports DMA and microwave interface.
Multi-channel analog input signal by the multi-channel analog switch control to access all the way in which the serial A / D converter, A / D converter by the optical isolation for serial output to shift register, shift register into this result 8-bit parallel data. 89C51 8-bit system through the parallel interface to send A / D converter data collected is stored in the FIFO memory; Once the FIFO is full, SIE immediately for data processing, and 89C51 system memory data read from the FIFO, the send and receive via data lines (D +, D-) sent to the host. USBN9602 and 89C51 specific interface circuit shown in Figure 2. The CLKOUT figure USBN9602 the XTAL1 is connected with the 89C51, the 89C51 USBN9602 clock output to provide the clock input. USBN9602 termination RC reset circuit, reset circuit to ensure reliable operation. As high frequency oscillator, with USBN9602 internal network, the XOUT and 470µF capacitor 100µF end of the inductor in series, a stabilizing role within the oscillation frequency.  2, system software design
System software, including device firmware, USB device drivers and applications.
2.1 device firmware (firmaware) Design
Here is the firmware to the 89C51 Flash in the curing process. Its main function is: control A / D converter sampling; ? control chip USBN9602 accept and process requests for USB driver and application program control instructions. Describes how the system is mainly controlled USB Controller 89C51 (USBN9602) communication with the host.
89C51 USB controller on the operation of the system is carried out in strict accordance with the USB 1.1 protocol. USB protocol in accordance with the provisions of 1.1, USB transmission is divided into four kinds: control transfer, block transfer, synchronous transmission and interrupt transmission. Used in the actual development of the control transfer and block transfer. Control the transmission main to complete the host of various control operations on the device, which is realized in the host’s USB bus driver (USBD.SYS) and the preparation of the function of the device driver for various control operations. Completion of block transfer mainly between host and device data transfers and the thumb data transmission error detection (if an error occurs, it supports "retransmission" function).
89C51 System Control USB controllers work projects can be simply summarized as follows: When the USB controller from the USB bus to the host to start testing a transfer request, USB controller 89C51 interrupt this request notification system; 89C51 system by visiting USB controller status register and data register, obtain the various parameters related to the transmission and the transmission of specific parameters of the control of USB controller registers and data registers appropriate action to complete the host’s transfer request. Understand the working process of the above can make the appropriate firmware design.
2.2 USB Device Driver
USB system driver design is based driver model WDM (Window Driver Model) in the. WDM layered driver model: the higher the USB device drivers and low-level USB Function layer. USB Function layer which consists of two parts: the more senior the Universal Serial Bus Module (USBD) and lower-level host controller driver module (HCD).
Currently, Windwos98 offers a variety of USB device driver, but not for data acquisition equipment, so need to use DDK (Device Driver Development Kit) development tools to design specific USB device drivers. At present, the write USB driver software is also a lot, and they are used to generate the USB drive to provide the code generator, the user can follow the prompts to configure the device and function definitions, and then you can make functional changes. Examples of using the software be modified to provide also a good shortcut. USB device drivers can be divided into four functional modules to achieve different: initialize the module, plug and play management module, power management module and I / O functions to implement the module.
Initialization module provides an entry point function DriverEntry (), the driver entry point for the DriverEntry routine. In DriverEntry, the need to provide a AddDevice routine, the driver added to the driver stack to go. In addition, all the various IRP (I / O request packet, such as: IRP_MJ_CREATE, IRP_MJ_WRITE, IRP_MJ_CLOSE, IRP_MJ_READ, IRP_MJ_DEVICE_CONTROL, etc.) handling routines are as defined in the entry function, such as:
DriverEntry (IN PDRIVER_OBJECT DriverObject, …) / / Driver entry
DriverObject-> DriverExtension-> AddDevice = USBAddDevice;
DriverObject-> DriverUnload = USBUnload;
DriverObject-> MajorFunction [IRP_MJ_READ] = USBRead;
DriverObject-> MajorFunction [IRP_MJ_WRITE] = USBWrite;


Figure USBN9602 and 89C51 interface circuit Click to enlarge
Plug and play USB device management module used to implement the hot swap and dynamic configuration. When the hardware detects when the USB device is connected, Windows98 drivers find the response, and call it DriverEntry routine. PnP (Plug and Play) Manager calls the driver’s AddDevice routine, telling it to add a device. In the process, the device driver receives a start request (IRP_MN_START_DEVICE) of the IRP. Similarly, the time when you want to remove, PnP Manager will issue a request to delete a device (IRP_MN_REMOVE_DEVICE) of the IRP, the driver for processing. Through the processing of requests for these PnP, supports hot swap and Plug and Play devices.
Power management module is responsible for suspend and wake-up device.
I / O functions to implement the module to complete I / O requests of most of the work. If the application wants the device I / O operation, it will use the Windows API function calls to the WIN32 WIN32 subsystem. This call by the I / O system services to receive and notify the I / O Manager, I / O management structure this request into a suitable I / O request packet (IRP) and pass it to the USB device driver. USB device driver receives this IRP after the IRP is included under the specific operation code, the corresponding USB Request Block structure and put this URB (USB Request Block) placed in a new IRP. Then, the IRP is passed to the USB bus driver, USB bus driver URB contained under the IRP the appropriate action (such as read data from USB devices, etc.), and the operating structure through the IRP return to the USB device driver . USB device driver receives this IRP, it will be returned to the operating results through the IRP I / O Manager. Finally, I / O manager in the operating results of this IRP return to the application, bringing the application on a USB device I / O operation is complete.
2.3 Application Design
User mode application is the center of the data acquisition system, and its main functions are: to open or close the USB equipment, testing USB devices, set the USB data transmission channels, set the A / D port status and data acquisition, real-time from the USB interface, data collection, display and analyze data.
As USBN9602 provided no more than 64-byte FIFO, when it is full after, USBN9602 automatically pack the data and immediately request the data read by the SIE automatically send data packets. In addition, when the system starts A / D module, it will create two threads: the thread and display sample save threads. Thread is responsible for sampling data collection to submit written application memory; and displayed to the application thread is responsible for archiving display and save to send the message. When the application receives this message, begins with it by the memory read data and display and archiving. Note that here, sampling and display save thread in the thread to read and write the memory of the application submitted to keep pace.
Remote Data Acquisition System 3
USB transmission distance is limited in the industrial field application of a barrierincrease in the relay or the Hub, USB transmission distance is usually not more than tens of m, which is clearly too short in terms of industrial field. Now, a large number of industrial field transmitted by RS-485 data acquisition devices for the transmission of its main advantages over distances up to 1200m, and can mount multiple devices; but the transmission is slow and requires board support, installation trouble. USB to RS-485 and combined to complement each other, resulting in a fast, reliable, low-cost remote data acquisition system.
Design such a system is the key equipment RS-485 ~ USB converter, you can use USBN9602 +89 C51 + MAX485 achieve this function. The basic idea is that the whole system: the sensor to the analog digital future, the use of RS-485 protocol data upload. RS-485 ~ USB converter 485 receives data from the host side. And through the USB interface to transfer to the host processing; the host sends data to the USB data through the RS-485 ~ USB port is converted to 485 protocol conversion to the remote transmission, in order to achieve long-range two-way transmission of data shown in Figure 3. Software design and similar to those described above.
At present, based on the application of USB peripherals stage of rapid development in foreign countries, in the country has become increasingly expanded the application; use of USB for data acquisition and industrial control has been successfully applied, especially with the introduction of USB 2.0 protocol, data transmission This high rate of 480Mbps. Such a high transfer rate will make the USB in the data acquisition more fully reflected advantage, and it will make it in a wider application areas to be deeper.