Home > Microcontroller >Interface Circuits > Simple USB interface data acquisition system

Simple USB interface data acquisition system

Source: InternetPublisher:张三叔 Keywords: Data acquisition circuit MAX197 CH371 Updated: 2024/08/21

The data acquisition system with USB interface is easy to use, does not require external power supply, and can also use the powerful computing power of PC to process data. This kind of system generally uses single-chip microcomputer for interface control, which is a problem for people who do not know how to use single-chip microcomputer. Here is a USB data acquisition system without single-chip microcomputer, which can be realized as long as you know how to use VB programming.

简单的USB接口数据采集系统

1. Hardware composition of the system

The electrical principle of this system is shown in the figure above. CH371 is the USB interface chip, MAX197 multi-channel AD converter is used for data acquisition, and the computer processes the collected data.

CH371 is a simple and easy-to-use USB interface chip produced by Nanjing Qinheng Electronics. It includes the chip itself and the universal driver on the computer side. CH371 implements the entire process of USB communication protocol transmission control with hardware logic. The universal driver provides a device-level interface to the computer application layer through software. Therefore, users do not need to consider USB communication protocols, firmware programs, drivers, and underlying data transmission processes, and can design various USB interface devices.

CH371 has multiple working modes. In addition to the data transmission mode, it can also work in a master control mode. Even if it is not connected to a single-chip microcomputer, DSP or other controller, it can also output control signals and input data. CH371's D7~D0 and A3~A0 are bidirectional pins. They can be divided into two groups, which are set for input or output. Connect A3~A0 of CH371 to the four input control lines CS, WR, RD, and HBEN of MAX197, and connect D7~D0 to the parallel data port of MAX197, so that the operation of MAX197 can be directly controlled by software.

MAX197 is a 12-bit AD converter launched by MAXIM. It has a single 5V power supply, a built-in 4.096V voltage reference, and a very simple peripheral circuit. It can work with only a few external capacitors. MAX197 has two internal and external clock and sampling modes. The analog input range and polarity are optional. There are four types: 0~5V, 0~10V, ±5V, and ±10V. There are 8 analog input channels. All of these can be selected through software, that is, writing a byte of control word to MAX197. The functions of each bit of the control word are shown in the table below:

Bit

PD1

PD0

ACQMOD

RNG

BIP

A2

A1

A0

Function

Internal and external clock and power management modes

Internal and external control sampling mode

Analog signal range

Analog signal polarity

Analog input channel selection

2. System software design

1. CH371 computer software interface

CH371 provides three levels of software interfaces on the computer side, the highest level is the application layer interface. The application layer interface is an API function for functional applications provided by the CH371 dynamic link library DLL. Each function implements a specific function and replaces the data format required in the device-level interface with easy-to-use API parameters. All APIs have an operation status return after calling. Users can achieve the required function by simply selecting a specific API function.

The API functions provided by the CH371 dynamic link library DLL include device management, data transmission, interrupt query, I2C operation and direct control. Here we will use two direct control functions.

CH371GetStatus(ByVal iIndex As Long, ByVal iStatus As Long, ByRef iDataReg As Long)As Boolean

Its function is to directly input data and status through CH371, where iIndex specifies the CH37 device serial number, iStatus points to a double word unit for saving status data. Bit7~Bit0 corresponds to the D7~D0 pins of CH371. IDataReg points to a double word unit for saving the data of the data register.

CH371SetControl(ByVal iIndex As Long, ByVal iCtrData As Byte, ByVal iCtrlAddr As Byte, ByVal iData0e As Boolean, ByVal iAddr0e As Boolean)As Boolean

Its function is to directly output control signals through CH371. ICtrData is the data to be written into the D7~D0 data register, iCtrlAddr is the data to be written into the A3~A0 data register, and they must output data when the output is enabled. iData0e controls the D7~D0 output enable, 1 output, 0 input. iAddr0e controls the A3~A0 output enable, 1 output, 0 input.

2. VB Application

The application is written in VB. Its core is to call the above two API functions, write control words to MAX197 through D7~D0 and A3~A0 of CH371, start analog-to-digital conversion, and finally read out the conversion results. To use the API functions in the CH371 dynamic link library, VB must first use the Declare statement to declare these functions in the code segment of the global module. The CH371 chip manufacturer has two MODULEs in the VB DEMO provided by it, which already contain all the API functions of CH371. Users only need to add them to their own projects. Through these two function calls, write control words to MAX197, set the working mode of the analog-to-digital converter, select the input channel, start the analog-to-digital conversion, and finally read the conversion results, store them in the computer, and then do further processing.

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号