Current location - Education and Training Encyclopedia - Resume - Design and research of data acquisition system based on MATLAB: How to write the opening report?
Design and research of data acquisition system based on MATLAB: How to write the opening report?
Abstract: Because Ma7 Ⅱ AB can't read and write the hardware terminal 12 directly, it lacks real-time performance, which affects the engineering application.

Very limited. Calling C++ language through horse body. AB application program interface Mex, hardware terminal can be realized in MATI. AB environment.

Reading and writing of 12 signal. Therefore, the author introduces Mex interface file in detail, including various special functions and detailed compilation of Mex interface.

Writing rules and specific compilation requirements, and specifically expounds the call and use of Mex interface in MA AB environment. According to Mex interface

Related functions. In order to further develop the function of MATLAB, the design of MATLAB data acquisition system is discussed theoretically.

An extension of.

Keywords: MATLAB: interface; Research on data acquisition of data acquisition system based on TLAB of ⅳ team.

, Chen Shanjie,,,, Tao, Xu Dahua

(Engineering College of Nanjing Agricultural University, Nanjing 2 1003 1)

Absrtact: Because MATLAB can't directly write operable hardware, and it lacks reusability.

For a long time, its work in the application has been greatly hindered. Through the MATLAB application of rede—

Deploy c++ language interface. The AB environment of specific hardware can be realized in MATI.

Interface signal. Therefore, the author of a paper introduces Mex interface in detail, including the interfaces of various spe.

Cial function and specific translation rules are written in detail, and calling and.

Use Mex interface in MA'nAB environment. And according to the relevant functional interfaces

Mexico. This paper explores the design of MATIAB data acquisition system in theory in order to further expand it.

The function of MA7n. AB.

Keywords: ma, 1 1AB, interface, data acquisition MATLAB product series is widely used in signal and data acquisition.

Image processing, control system design, communication, system simulation and many other fields.

One of its major features is that there are many application-oriented toolboxes and imitations.

Real block, including a set of signal image processing and control functions.

The system design, neural network and other special applications are analyzed and designed. other

Our products expand the functions of MATLAB, including data acquisition and reporting.

Generation, and rely on MATLAB language programming to generate independent C/c++ generation.

Code and so on.

Because of its powerful scientific calculation and visualization function, it is simple and easy to operate.

The open and extensible environment used and the collars with different orientations.

Toolbox) t 1 1+0, expanded by the definition domain, makes MATLAB in many fields.

Become a computer-aided design and analysis, algorithm research and

Basic tools and preferred platforms for application development.

However, MATLAB also has limitations, that is, it cannot be used directly.

The reading and writing of hardware port affects its opening in measurement and control system.

The application range of hair. However, it provides an application program interface API, which is implemented through.

With this interface, users can easily complete MATLAB and external environment.

As shown in figure 1. To do this, how to call through the interface file?

A program written in other languages (such as C_ B}), and then the hardware end is realized through it.

Finally, the read-write operation of the port is realized in a single MAR Ⅱ AB environment.

The development of line measurement and control system has become a problem worthy of discussion and research.

Title. 1 MATLAB application program interface file Mex

MATLAB application programming interface (APD) mainly includes three parts:

Mex file (external program call followed by 13), Mat file (data input and output)

Interface) and MATLAB computing engine function library. They realized that a man

General functions are: (1) calling C/c++ in MATLAB environment.

C or FORTRAN language to improve data processing.

Efficiency; (2) Data transmission in MATLAB environment.

The environment receives data, that is, the realization of MATLAB system and external environment.

Data exchange; (3) Establish the client between MATLAB and other applications.

Client/server relationship, using MATLAB as calculation engine,

Call in other applications to reduce the workload of programming.

The following focuses on the application of Mex file.

1. 1 X is a dynamically linked subroutine with the following specific functions.

(1) For some existing C programs, Mex can be used.

Call directly in MATLAB environment;

(2) For __I, OOP affects the execution speed of MATLAB.

Such as loop body, you can write the corresponding C program to complete the same function, and

Compile into Mex file to improve the running speed; (3) For A/D or D/A cards or other PC hardware, it can be straight.

Using Mex file to access and expand the functions of MATLAB;

(4) using MEX files, you can also use some software, such as

Windows user interface resources and so on.

Programming rules of 1.2 Mex file

(1) Compile the C++ algorithm program by yourself;

(2) compiling MEX source file code;

The source file of MEX file mainly consists of two parts:

(1) calculation subroutine (calculation program). it is

Link external subprograms, including all the source programs that complete the calculation function.

Code, used to complete the actual calculation.

(2) Entry subroutine (gateway program). It is the interface between calculation subroutine and MATLAB environment, which is used to complete

Data interaction between them. The entrance subroutine is a necessary part of MATLAB calling c-jitter program, and the calculation subroutine can be accessed from the entrance subroutine.

Call a subroutine to complete its specific functional requirements. Children tickets

The specific usage format of this routine is as follows:

# contains "mex.h" void mexfunction (int nlhs,

MxArray Niuwan [],

int nrhs,const mxArray prhs[])

{

//c language code

)

Among them, the function name of the entry subroutine must be MexFunction.

Prhs is an array of pointers of structural type, and the elements of the array are arranged in order.

The command points to all input parameters; Nrhs is the number of input parameters; plhs

Consistent with the type of prhs, it points to all output parameters; Nlhs table

Indicates the number of output parameters. This function obtains the input data through prhs, and after processing these input data, obtains the result through plhs, plhs.

Interact with other programs as output data.

Compilation and Call of 1.3 Mex File

Before compiling Mex file, it must be installed in MATLAB.

Install Mex compiler as follows: In the MATLAB command window.

Enter mex.setup in your mouth and follow the prompt wizard to install it step by step.

Yes

Mex files are compiled directly in the MATLAB command window.

The formula is as follows: > > Mex file name, and then press enter (if compiled).

After that, the system will generate a DLL file with the same name in future programs.

You can call this directly just like calling the built-in function of MATLAB.

Function. The principle is shown in Figure 2.

As can be seen from the above, Mex file can be used as MATLAB.

Built-in function, but this function has a powerful interface function.

Can complete the hardware port signal reading and writing operations. This is very important for hardware ports.

The general process of reading and writing operation is shown in Figure 3.2 Conceptual design of data acquisition system based on MATLAB.

A method of data acquisition using interactive programming of MATLAB and C language is proposed.

Setting problems make the system not only have the traditional computer data acquisition system.

All the functions of, but also has strong data processing ability, in fact.

It constitutes an intelligent virtual instrument t3].

The preliminary design system consists of three modules, MATLAB module.

Functions include graphic display and access, data analysis and processing, etc. C programming language

The module mainly realizes serial communication function, while the hardware device completes object-to-object communication.

Transformation of rational numbers [4,5/. As shown in figure 4.

When the sampling object is determined, the hardware equipment will follow, C.

The communication function realized by the language part is also fixed, so all data bits

The function settings are all realized in the man-machine interface in MATLAB environment.

Now The functions of the three interfaces of the system are as follows.

The main interface is mainly composed of a graphic box and four buttons. With the help of the graphics processing function of MATLAB, the graphics frame is matched with the best module.

Dynamic display of real-time sampling data to realize the function of automatic oscilloscope. four

The button names are "Set Serial Port", "Start Acquisition" and "Data Processing" respectively.

Click the mouse to realize the corresponding function.

After selecting "serial port settings" in the main interface, enter the communication protocol.

Set the interface. This interface is mainly composed of five pop-up menus and two buttons.

Button, the name and options of the pop-up menu are: port selection.

(COMI-COM4), baud rate (300- 19200), data bit m8), stop.

Stop (o~2) and check (none, odd, even), and the two buttons are aligned respectively.

Confirm or correct the set parameters.

Select "Data Processing" in the main interface, and then enter data processing.

Interface. The function of this interface is related to the sampling object and is decided by the user.

Programming for task requirements. 3 Conclusion

MATLAB has various numerical operations and graphic processing.

Function, the existence of a large number of practical control toolboxes is more important for its control application.

Lay a solid foundation; C language is very powerful for hardware system.

The processing ability of, can easily realize data acquisition, serial communication and other functions.

Can laugh. Mex file is written by MATLAB in C++ and other languages (such as

Visual Fortran, etc. ), which greatly expanded.

The application scope of MATLAB makes the MATLAB system truly open, fully functional and self-contained in programs and data.

Dealing with integrated environment. refer to

Wang, Wang Shengkai, Chen Guoshun. . MATLAB/Simulink and control system simulation.

Beijing: Electronic Industry Press, 2005:11-13.

Andy. . MATLAB external connection 12 1 programming. Xi 'an: xidian university Publishing House.

Society, 2004: 50-85.

Liao, Yu. Research on image acquisition system based on DSP and USB. Wuhan

Journal of University of Technology (Communication Science and Engineering Edition), 2006,30 (1):120.123.

[4] Shen Dingcai, Guo Qingping. Distributed data acquisition and analysis based on interaction in geotechnical engineering

Application research in the process. Journal of Wuhan University of Technology (Communication Science and Engineering Edition),

2005,29(6):974-976,992.

5 Li. Design and implementation of data acquisition system based on USB bus.

Journal of Wuhan University of Technology (Communication Science and Engineering Edition), 2005,29 (5): 758+0.

[6] Yang Yiwei, Jiang Daming, Dai Shenghua. Data acquisition of microcomputer monitoring system for hump signal.

Journal of China University of Technology (Communication Science and Engineering Edition), 2005,29 (1):154-156.

[7] Emperor Wen of Sui, Zhang Huihui. Network data acquisition and signal analysis based on DSP and ARM.

Duantian Computer Engineering, 2006,32 (8): 269-271.

8 Li Yaokun, Shi Zhongke, graduation, etc. . Matlab in decision support system based on B/S mode

The application of. Computer Engineering, 2006, 32(5):255-256282.