Development of an industrial computer data acquisition system based on VB6.0
2026-04-06 03:12:07··#1
Abstract: This paper introduces the development technology of the data acquisition system of the tank gun control system test platform based on VB6.0 and industrial computer, details the design method and key links of the system, and gives the characteristics and application methods of PCL818H and PCL813B data acquisition cards as well as the technology of VB6.0 accessing the database. Keywords: VisualBasic6.0; industrial computer; tank gun control system; data acquisition; PCL-818H Introduction: With the continuous upgrading and replacement of weapons and equipment and the continuous improvement of performance, the requirements for post-maintenance test technology are also increasing. In recent years, the fire control system of the main battle tank equipped by the troops has very strict requirements for post-maintenance test. The current test methods are mostly manual operations with low automation and poor accuracy. The development of the new tank gun control system test platform is based on this background. This paper introduces the development technology of the data acquisition system of the platform. 1. Hardware system design 1-1. Analysis of the measured parameters According to relevant regulations, the static parameters and dynamic parameters of the tank gun control system after maintenance need to be detected [1]. The static parameters to be detected include 94 voltage signals within the ±15V range, and the dynamic parameters include 12 signals such as displacement, tension, pressure, speed, and drift. The displacement and tension signals are standard sensor output signals with ranges of ±5V and 0-5V, respectively. The speed and drift signals are check signals output by the gyroscope group, which are ±15V voltage signals. In addition, hydraulic components and electromagnets are needed as actuators to measure displacement and tension, so corresponding control is required. 1-2. Data Acquisition Card The selection of the data acquisition card is the key to the construction of the hardware system. Based on the stability of performance and cost-effectiveness, Advantech's ISA bus products were selected. As required, three PCL813B and one PCL818H were used. Both of these cards support a bipolar ±5V input range. We also made an external terminal board to convert the ±15V voltage to ±5V [2-3]. The PCL813B has 32 single-ended isolated analog inputs, which were used in this application to acquire 94 static voltage signals. It employs a 12-bit resolution A/D converter, AD574, with a conversion time of 25μs and a data transfer rate of 25Kbps. The input range is bipolar ±5V, ±2.5V, ±1.25V, and ±0.625V, and unipolar 0~10V, 0~5V, 0~2.5V, and 0~1.25V. The A/D conversion is software-triggered. The PCL-818H is a multi-functional data acquisition card used in this application to acquire dynamic signals and control hydraulic valves and electromagnets. It provides five of the most commonly used measurement and control functions: 12-bit A/D conversion, D/A conversion, digital input, digital output, and a timer/counter. Its features are: (1) 16-channel (single) or 8-channel (dual) differential analog input; (2) 12-bit analog-to-digital conversion, 100kHz sampling frequency; (3) 16-channel digital input and output; (4) The gain value can be changed by software; (5) The logic input range (bipolar) can be selected by software. The two boards are used in basically the same way. Due to space limitations, the following only introduces the use of the acquisition card by taking the 818H for analog input acquisition as an example. The key to writing the PCL-818H program is to use the 16 registers on the board. It requires 16 consecutive PC I/O space addresses, and each port address corresponds to a register in the acquisition board. The address of each register is specified by the offset to the board's base address. For example, BASE+0 is the base address of this board, and BASE+7 means base address + 7 bytes. If the base address of the board is 300h, then the address of the BASE+7 register is 307h, as shown in Table 1. Table 1. Register Functions and Corresponding I/O Port Addresses. The PCL-818H's 16 analog input ports can form 16 single-ended inputs or 8 pairs of differential inputs. The operating mode of the input channels is set using jumpers, and software controls the operation of one or more channels. After the input signal is amplified, it is converted into a 12-bit digital signal by a successive approximation A/D converter. The PCL-818H provides three triggering modes: software, clock step, and external signal. Software-triggered triggers are controlled by software; when a value is written to the software register, the A/D conversion is initiated. This mode is suitable for low-speed A/D conversion. Clock step triggering is suitable for systems requiring high conversion speeds. The PCL-818H provides an 8254 timer/counter to provide a fixed trigger source for the A/D converter. Counter 1 and Counter 2 are cascaded together to provide a precisely periodic trigger pulse, ideal for systems requiring a fixed and accurate sampling frequency. Connecting an external trigger signal to pin 35 of CN3 enables external triggering, suitable for systems that do not require periodic sampling. The rising edge of the external signal initiates the A/D conversion. According to the needs of the system, we chose the software triggering method. 1-3. Selection of Industrial PC An industrial PC (IPC) is a computer with special performance. It can ensure the continuous and stable operation of the system in harsh industrial production environments and can withstand adverse factors such as high (low) temperature, impact, vibration, electromagnetic interference, humidity, and dust in the environment [4]. Considering the special nature of military use, we chose a vehicle-mounted portable industrial PC, model REPC-815 from North China Industrial Control. This machine has 8 slots of PCI/ISA expansion capability, the LCD screen can rotate 360°, and has an anti-explosion function. [align=center] System structure diagram[/align] 2. Design of software system The software design of the system adopts VB6.0. VB6.0 is welcomed by many users for its ease of learning, high efficiency, powerful functions, and user-friendly system interface. It has been widely used in the fields of data acquisition and industrial control. The software part of this system mainly consists of two parts: data acquisition and processing and data management. The functions implemented include data acquisition control, data processing, data management, and test report output. The code for the two key links of data acquisition and storage is given below. 2-1. Reading analog voltage. Although VB is easy to learn and powerful, it also has its own weaknesses. For example, direct access to hardware cannot be solved by VB itself. However, it can access and control I/O by calling the driver function provided by the board, and it supports event-driven, so VB can easily compile data acquisition software [5]. To call the driver in the Windows environment, a module Driver.bas needs to be added to the project. The module defines all the constants, global variables, functions, data structures, status codes and messages of PCL-818H. Data can be read directly by calling the quantities defined in the file in the program. Many API functions are defined at the end of the Driver.bas file, but none of them are private. All forms in the project can call these functions. Reading the analog value is divided into the following 5 steps: (1) Open the device ErrCde=DRV_DeviceOpen(0,DeviceHandle) If ErrCde is 0, it means success. Otherwise, an error message is returned. (2) Configure the input channel range lpAIConfig.DasChan=int Channel 'Set the channel lpAIConfig.DasGain=0 'Set the gain to 0 ErrCde=DRV_AIConfig(DeviceHandle,lpAIConfig) (3) Read the voltage value IConfig) AiVolIn.chan=lpAIConfig.DasChan 'Voltage input channel AiVolIn.Gain=lpAIConfig.DasGain 'Voltage input gain AiVolIn.TrigMode=AiCtrMode 'Trigger mode AiVolIn.voltage=DRV_GetAddress(voltage) 'Read the voltage value ErrCde=DRV_AIVotageIn(DeviceHandle,AivolIn) (4) Return value fnGetValue=voltage (5) Close the device ErrCde=DRV_DeviceClose(DeviceHandle) 2-2. Database Access VB6.0 provides strong database storage capabilities and can directly support Microsoft Access databases [6]. VB has DAO and ADO as technologies for accessing databases in a stand-alone environment, which can be implemented using controls or code programming. In this application, using controls is not suitable, so the more flexible ADO code programming method is adopted. Assuming a table named "pkxt" exists in the database C:\mydatabase\mydata.mdb, with field names name, testdata, givendata, and conclusion, and several text boxes in the interface displaying test data, the code for writing the data to the database is as follows: Private Sub Form_Load() ' Form load event Dim strSQL As String Set cn = New ADODB.Connection ' Establish a new connection cn.Provider = "microsoft.jet.oledb.3.51" ' Database engine cn.ConnectionString = "C:\mydatabase\mydata.mdb" ' Database path cn.Open ' Open the connection Set adors = New ADODB.Recordset ' Open a recordset of the "pkxt" table adors.LockType = adLockOptimistic strSQL = "select *" & "from pkxt" adors.Source = strSQL Set adors.ActiveConnection = cn adors.Open adors.AddNew End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload form event cn.Close 'Close connection End Sub 'Write the data in the interface to the recordset in the click event of the "Save" button Private Sub Command1_Click() adors.Fields("name") = Text1.Text 'Detection item name adors.Fields("testdata") = Val(Text2.Text) 'Detection value adors.Fields("giveddata") = Val(Text3.Text) 'Given indicator value adors.Fields("conclusion") = Text4.Text 'Detection conclusion adors.Update adors.Close End Sub 2-3. Report Output For report output, VB6.0 provides many methods, among which the DataReport designer and Printer object methods have distinct characteristics. Using the Printer object methods requires writing more code, but is extremely flexible; the DataReport designer is a new feature in VB6.0, which only provides the most basic functions, but is very easy to use. Because the data in this system is relatively simple, the DataReport designer was used to output the test report. 3. Conclusion After repeated debugging, the VB-based industrial computer data acquisition system we developed achieved all the expected functions and met all technical requirements. This system has been used for nearly half a year in a tank repair unit of our army. It has a user-friendly interface, rich functions, and reliable operation, making it highly valuable for widespread application and providing a reference for multi-parameter data acquisition systems in other industries. References [1] ZTZ96 Tank Repair Guide [M]. Beijing: General Armaments Department of the Chinese People's Liberation Army, 2000. [2] Zhang Jinsong, Zhang Tao. Computer Industrial Control [M]. Beijing: China Electric Power Press, 2003. [3] Ling Cheng, The Essence of PC Industrial Control Systems [M]. Beijing: Tsinghua University Press, 1998. [4] Sun Yancai, Wang Jie. Principles of Industrial Control Computer Organization [M]. Beijing: Tsinghua University Press, 2003. [5] (US) Steven Holzner, translated by the Detailed Translation Group. Visual Basic 6 Technical Insights [M]. Beijing: Machinery Industry Press, 1999. [6] effrey P. McManus. Visual Basic Database Access Technology [M]. Beijing: Machinery Industry Press, 1999.