Smart test
Realization of a Relay Test Data Query System
Abstract: This article discusses a method for querying relay test data. It is designed based on LabVIEW, which solves the needs of small and medium-sized apartments for database, with short development cycle, friendly interface and convenient operation.
1 Introduction
As a commonly used component of automatic control system, relays have a large number and types of test relays, and it is very laborious to use manual recording of these data to query. Therefore, this article introduces a relay test data made with LabVIEW software. The query system can quickly solve the problem of finding qualified relays from a large amount of test data, and it can also print out the query results.
2. The solution to access the database
Because LabVIEW itself does not have the database access function, the common solutions are as follows:
1) Use other languages such as VC++ to write DLL programs to access the database, and then use the DLL interface that LabVIEW brings-call library function node CLFN (CallLibraryFunction Node) to access the program.
2) Use NI's add-on toolkit LabVIEWSQLToolkit for database operations.
3) Use the ActiveX function of LabVIEW to call the Microsoft ADO control and use the SQL language to achieve database access.
4) LabVIEW database access toolkit LabSQL developed by LabVIEW.
Here we adopt the fourth method.
3. Introduction to LabsaL
LabSQL is a multi-functional, cross-platform LabVIEW database access toolkit developed by many users. It supports any ODBC-based database in the windows operating system, such as: Access, SQLSever, Oracle, Pervasive, Sybase, etc. According to their different functions, they are divided into three templates: Command, Conncetion and Recordset, and three sub-VIs that can directly call the top level of SQL. In each template, there are multiple different sub-VIs for users to call, as follows:
(1) The subVIs in the Command template complete a series of basic ADO operations, such as creating or deleting a Command, reading and writing a certain parameter in the database, etc. The subprogram modules ADO Command Create.vi, ADO CommandDestroy.vi, etc.
(2) The subVIs in the Connection template manage the link between LabVIW and the database. Each subroutine module is shown in Figure 19. In this paper, SubVIs such as Create Comn, Open Comn, Close Comn, etc. are mainly used.
(3) The subVI in the Recordset template is used to perform various operations on the records in the database, such as creating or deleting a record, reading and writing an entry in the record, etc.
(4) TOP Level VIs is the top-level LabSQL application, which encapsulates certain application functions of the first two LabSqL V Is, as shown in Figure 1, which exists in the form of 3 independent sub-VIs. For example, SQL Execute.VIs can be used to directly execute SQL commands, SQL FatchD ata (GetString). vi is a query for characters, and SQL FetchData.vi is used for querying data. The data here does not include the preceding characters.
4. Realization of function
A significant advantage of LabVIEW software is that it can be displayed, stored, printed, and microprocessor controlled and managed by a computer, that is, any instrument with any function can use or share these common resources of the computer without duplication. design. Considering that Access is suitable for the development of small and medium-sized management information systems, Microsoft Access provides many convenient and configurable operation tools for the end-user of the database: such as table builder, query designer, form designer, report designer, etc.) and wizards (such as table Wizards, form wizards, query wizards, report wizards, etc.), and use these tools and wizards to construct a simple and practical management information system without programming, and the corresponding development cycle is short. Therefore, Microsoft Access is used here to build a database for data storage and query.
4.1 Several important SQL query commands
In the development process of database management software, although the LahSqL toolkit is used, simple SQL query commands are not unavoidably used. In the process of development. The frequently used SQL statements are as follows.
1) Data query. Use SELECT in SQL statements to query data. The general format is as follows: SELECT<query content>FROM<table or view>WHERE<condition>ORDERBY<column name>. The SQL statement combined with the control on the front panel of the software during development is expressed as:
Query the table to be operated by the SElECT*FROM statement of all test results in a table (the table name is obtained from selecting the table control to be operated). The SQL statement for a single query is: SELECT* FROM the table to be operated WHERE operation field operation condition operation condition value The SQL statement of the combined query is: SELECT* FROM the table to be operated on WHERE operation field operation condition operation condition value and operation field 2 operation condition 2 operation condition value 22) delete record. The SQL statement format for deleting records is: DELETE FROM<table name>WHERE<condition>. The SQL statement for deleting query results in this article: DELETE FROM the table to be operated on WHERE primary key field name = the row pointed by the mouse condition value 4.2 Connect to the database Implementation of the module
(1) LabSQL configuration. First create in Access
The database named l.mdb. Create the various forms you need, and then create the data source name DSN of the database in the Windows ODBC data source, and then point the database path in the data source to 1.md b, and turn on the Acces user and group permissions. In this way, IabSQL can access 1.mdb.
(2) Establish a connection with the database. Use ADO ConnectionCreate.vi to create a Connection object in the Connection VI s module of LabSQL, and then use ADO Connection Open.vi to establish a specific connection with the database. Among them, enter the dynamic hyphen in the connection string Connectio.string of ADO Connection Open.vi: Provider=Microsoft.Jet.OLEDB.4.0:Data Sour.e=e:\1.mdb:Persist SecurityInfo=FalSE. The essence of this process It is to establish a pointer to the currently opened database, and use this pointer to perform various operations on the opened database. Figure 2 is a block diagram program for its realization.
4.3 The realization of database operation module
The content of database operations is very rich, such as query, add records, modify records, delete records and other data requirements. This article only discusses the basic operations of data storage, namely delete, query and query record deduction. The database has been established After a good connection, to realize the operation of the data house, generally go through the following steps:
(1) Establish a connection with the Rccordset object to implement specific operations on the database, and use the CommandText property to define the executable text of the command (such as SQL statement).
(2) Use the Execute method to execute the command and return the RecordSet object when appropriate.
(3) Pass the Command object to the Source property of the Recordset in order to obtain data. The key here is the writing of LabSQL query statements, and the relevant LabSQL query commands are written in the attribute node Commad Text.
(4) Display of query results. Select SQL Fentch Data (CetString) in the Top Level VIs module. The VI obtains the query result and sends the query result to the table display control in the front panel window for display.
The record printing system uses the controls that come with LabVIEW itself, through Initialize Report.vi (initiating the report), Append Table toReport.vi (adding query results to the report), and Print.vi (printing the report).
5 Conclusion
The relay test data query system based on LabVIEW has a friendly interface, simple operation, convenient maintenance, and has high practical application value. (Author: Guan Huayun, He Ping)