2008 International Conference on Computer and Electrical Engineering
Research and application of Display&Control System based on Embedded Linux Yan-tao Xu1, Ling-jiang Kong1, Jian-yu Yang1, Xi-Juan Zhang2, Liang Yuan3 1 School of Electronic Engineering, University of Electronic Science and Technology of China, Chengdu, SiChuan, 610054, China 2 Technical Center, ChengDu Aircraft Industrial (Group) Co.Ltd, Chengdu, SiChuan, 610092, China 3 Logistic Group, University of Electronic Science and Technology of China, Chengdu,SiChuan, 610054, China
[email protected],
[email protected],
[email protected],
[email protected] multifunctional widget also weakens interactive function and disturbs the user for its miscellaneous information. Therefore, we developed a software which holds 4-depth interface for display&control system of through-the wall radar (hereinafter referred as "system") to make display, control and radar configuration function separated. The software is designed by Qt in embedded Linux OS.
Abstract As terminal of through-the wall radar, the main function of display&control system is accomplishing information transfer between the user and the radar: Configure the radar system according to the user, and return detected result in a laconic and effective way finally. Based on all above, the article introduced a new way to construct display&control system, and then relevant software structure diagram had been given followed. Further more, worked with Qt in Linux, the article discussed some key technology which could accomplish function of the display&control system based on s3c2440 platform. Now these technologies have been used by through-the wall radar and get a better result.
2. Design of system structure 2.1. System function (1) Configure sub-systems of the radar according to the user; (2) Receive detected data which processed by FPGA, then show it to the user in the form of image or graphics; (3) Control radar detecting schedule and display mode expediently; (4) Save user settings for the next time.
1. Introduction With the development of computer technology, display&control system has gone through the way from dedicated computer to Personal Computer(PC), and then from PC to common embedded platform. At present most radar display&control system in China is developed in Windows or Vxworks Operating System (OS), and the final system is designed as a widget which accomplishes all function include display, control and radar configuration. There are obvious limitations here: First, Windows and Vxworks are all not open source OS, they prefer to provide Application Programming Interface (API) to designer than source code. So these OS are difficult to custom, and the user has to pay high fees for their copyright. Second, a
978-0-7695-3504-3/08 $25.00 © 2008 IEEE DOI 10.1109/ICCEE.2008.68
2.2. Design approach When design software of display&control system, Object-Oriented Analysis (OOA)/ Object-Oriented Design (OOD) technology was used for reference. We decomposed the system into a lot of realizable littler modules first, and then organized these modules in an orderly manner. OOA/OOD is an object-oriented modeling method, OOA is used for system analyze and OOD is used for system design. OOA follows basic principles of 802
communication module and feedback data processing module; The second stage: sub-interface guide, which include guide of detection data display interface, radar configuration interface, detection-mode choice interface and system shutdown interface. According to the user, control or configuration data will be send to FPGA through sub-interface guide interface, too. Modules in this stage include sub-interface choice module, parameter proceeding module and serial port communication module. In fact, the last module is the same one with which used in the first stage. The third stage: Turn into corresponding sub-interface according to the user. Modules used in this stage include detected data receive and proceed module, detected data display module, USB port communication module, parameter setting module, simulation keyboard module, detection-mode choice module and system shutdown module. Based on above analysis, we can get function structure figure in the function level and module structure figure in the module level. Then we showed function structure figure in Figure 1.
Structural Design, and combines them with object-oriented standpoints. It includes five steps: Get classes and objects, analyze structure of these classes, define theme, mark attribute and define servings of these classes. The final result of OOA is a structural document. OOD is the way to actualize the analyzed result by OOA. It includes four steps: Subdivide analyzed result, design User Interface (UI), allot system resource and design data management. OOA vertically divides the system into five parts, OOD horizontally divides the system into four parts, and then a clear system model formed finally[1].
2.3. System software structure The software was eventually divided into 3 stages in running and 12 modules in structure: The first stage: When the radar system start, self-inspection program will be executed first, finally show inspection result to the user. Modules used in this stage include system self-inspection module, serial port
S tart
Shut D ow n
D etected data D isplay Interface Detected data
R ad ar C on fig u ration In terface
S e lf-c h ec k R esu lt
P aram e te rs Shut D ow n
Shut Down
Sub -interface G uide Interface
S elf-c hec k Instru ction
D etectionM ode Choice Interface
S elf-che ck Instruction
F P G A
Pa ram e ters Shut D ow n
S elf-c h ec k R esu lt D e tec te d d a ta
Fore-sub-system
P ara m ete rs
Parameters
Success
Se lf-c h ec k R esu lt
Serial Port Communication Module
S e lf-c h ec k In stru ctio n
R adar Self-check Interface
Sh ut d ow n S ystem Interface
M o d e In fo rm a tio n
D e tec te d d a ta
U S B C om m un icatio n M odule
Figure 1. System software function structure
3. Realization of the system
Table 1. Main classes related to the system Function Frame Buttons Drawing related
Display&control system is an embedded system which is based on s3c2440 platform. It has such functions include communication, data processing and graphics display. In last section we have divided the system into some modules, then realization of the system had been changed to realization of modules. In Qt, main classes related to the system have showed in table 1.
Multithreading Timer Text related Configuration file
803
Related classes in Qt QWidget QDialog QFrame QButton QPushButton QButtonGroup QPainter QCanvasEllipse QCanvas QCanvasView QCanvasLine QCanvasPixmap CanvasText QCanvasPolygon QCanvasPixmapArray QThread QTimer QLabel QLineEdit QTextView QFile QDataStream
When the serial port is set correctly, we can use read () and write () function to transfer data between FPGA and display&control system. (2) Realization of USB communication USB (Universal Serial Bus) port communication is a little complex. In fact, USB device (FPGA) which will communicate with display&control system is such a equipment configured by FPGA itself, in other words, it is special USB equipment, so Linux can not prepare such a device driver for us. Then there are two ways to accomplish USB communication: Use libusb library to program with no driver, or develop special driver for it. (a) Program with libusb Libusb is an open source project; it includes a series of external API which could be used by other programs. These API call low level interface in kernel; this is very similar with using functions in kernel driver. When programming with libusb, there is a very nice feature that the program is independent of kernel version. So libusb based application can be very conveniently transplanted from one Linux platform to another. But except this merit, libusb based program may be a little weaker than the same one based on USB driver in function, flexibility and stability. After install libusb in Linux, USB device can be expediently handled by libusb API. Detail techniques of libusb please refer to the literature [3]. (b) Program with USB driver USB drivers live between the different kernel subsystems and the USB hardware controllers,The USB core provides an interface for USB drivers to use to access and control the USB hardware, without having to worry about the different types of USB hardware controllers that are present on the system[4]. Generally, there are four basic things USB driver need to do: Claim devices which are droved by the driver, register itself to USB core, define probe and disconnect functions, and define read and write functions. But it should be noted that when developing a USB driver, the kernel version in Host should be seriously checked because both Host and object machine’s kernel version should be the same. Drivers compiled in different kernel version are not compatible. After succeed in compiling and loading the USB device driver, communication between FPGA and the system can be accomplished though open, read and write functions.
Qt is a cross-platform Widget-Library, produced by TrollTech in Norway. Support all UNIX systems and WinNT/Win2k, Win95/98 platform. We can use both Qt library, standard C library and system library to achieve prolific software function. In following sections we will expound some key technology of display&control system which used these three libraries.
3.1. Data transmission In display&control system there are two kinds of data needed to transfer: one is radar configuration data and subsystem feedback data, the other is radar detected data. The former one is characterized by a small data amount and a low data rate. The amount of the data is only a few bytes; but the last kind is characterized by a big data amount and a high data rate by contrast. And the highest data rate may reach 3.24Mbps. Therefore, we need different ports in the system for different kinds of data. Serial port is used for low data rate and USB for the other. And we should also design different communication program for them. (1) Realization of serial port communication Serial port is a very common port in computer, Linux have already provided driver for it. So we can accomplish serial port communication just by setting some relevant parameters, which include baud rate, data bits, parity bit, stop bit and data flow control. These parameters are set through members of struct termios, the struct is defined in [2]: struct termio { unsigned short c_iflag; /* input mode flags */ unsigned short c_oflag; /* output mode flags */ unsigned short c_cflag; /* control mode flags */ unsigned short c_lflag; /* local mode flags */ unsigned char c_line; /* line discipline */ unsigned char c_cc[NCC]; /* control characters */ }; After get serial port’s equipment descriptor fd, termio can be set conveniently. A typical configuration is as follows: struct termios newtio; newtio.c_cflag |= CS8; /* Change data bit to 8bit*/ …… …… /* Set inout baud rate, 9600bps */ cfsetispeed(&newtio,B9600); /* Set outout baud rate, 9600bps */ cfsetospeed(&newtio, B9600); …… …… /* Configure serial port with termios */ tcsetattr(fd,TCSANOW,&newtio);
3.2. Show the detected target When receiving the detected data, we need to show it to the user in a proper way. If the data from FPGA is a series of coordinates such as D0(x0,y0),D1(x1,y1)
804
,……,and Dn(xn,yn), it means that it shows us the target’s track. In display&control system, a solid circle with small radius is used to indicate the target; a Cartesian coordinates is used to reflect the relative position of the target and update the position of the circle in reference frame to show the movement of the target. In Qt, QCanvas family can be applied to actualize such functions. QCanvas family is an aggregate of QCanvas and relative canvas item classes which include QCanvas, QCanvasPolygon, QCanvasLine, QCanvasPixmap, QCanvasEllipse, QCanvasView, QCanvasText, QCanvasPixmapArray, and so on. QCanvas class provides a 2D area which can contain QCanvasItem objects, it is optimized for large numbers of items. QCanvas divide canvas into rectangular chunks, and use a chunk size which is about the average size of the canvas items. Internally, a canvas uses a low-resolution "chunk matrix" to keep track of all the items in the canvas. A 64x64 chunk matrix is the default for a 1024x1024 pixel canvas, where each chunk collects canvas items in a 16x16 pixel square. Only changed parts of the canvas are redrawn (if they are visible in a canvas view) whenever canvas update.[5] QCanvas use double-buffering inside to avoid flicker, use collision detection to manage overlapping items, these characteristics will greatly improve repaint speed when the canvas update. After claim QCanvas and QCanvasView, our own items can be then defined on the canvas. Typical codes are like follows: /* Construct the canvas and display widget */ QCanvasView* imigeDisplay = new QCanvasView( 0, this, "imigeDisplay" ); QCanvas* canvas = new QCanvas( imigeDisplay->width(),imigeDisplay->height()); /* Draw a circle at (0, 0), which diameter is 12 pixels */ QCanvasEllipse* ellipse = new QCanvasEllipse(12, 12, canvas); /* Fill the circle with red color */ ellipse -> setBrush(red); Whenever receive a coordinate Dk(xk,yk) from FPGA, move the ellipse to Dk. ellipse -> move(x, y); /*Move the circle to (x, y)*/ canvas -> update(); /* Update canvas */ In above code, it’s worthy to note that in function move(x, y), x and y are absolute coordinates of imigeDisplay. But unfortunately, this widget’s coordinate origin locates at its top left corner, and direction of x-axis is right from the origin, y-axis is down from the origin. It looks like Figure 2 followed.
X- axi s
Y- axi s
O
imageDisplay
Figure 2. Reference frame of imigeDisplay Therefore, before item drawing there should be a conversion between real coordinates and Cartesian coordinates. In display&control system we design transXToCartesian (int x) and transYToCartesian (int y) to actualize this function. Then We call move(x, y) using transformed Dk(xk,yk), the graphics is draw in rectangular coordinates looks like Figure 3 followed.
Figure 3. Final graphics in rectangular coordinates
3.3. Software transplant Display&control system is an embedded system which runs on s3c2440 platform. So the software is developed according to the mode which is designed in Host first, cross-debugged between Host and object machine second, run in object machine last. Thanks to OS, it has handled most complexity of the transplant between different platforms. What we should do is just build a cross-compiler environment in Host, and compile the software with cross-compiler, and then solidify the compiled software into object machine.
4. Conclusions Research of through-the wall radar is a hotspot in recent years because of urban warfare, counter terrorism and post-disaster succor. This article
805
introduced a feasible way to designer Display&control system, which is a very significant sub-system of the radar. And expound some key technology used in the system; these technologies are not only useful for this system, but also useful for Display&control system of handheld devices, even other radar in a sense.
[1] Ding Xiao, Jian-lin Wu, Chun-yanZhou, Jia-peng. Xiu Module and method of software design. Beijing University of Posts and Telecommunications Publishing House, Beijing, 2008 (in Chinese). [2] Hua. Du Explanation of Linux Program Technology. Posts& Telecom Press, Beijing, 2007 (in Chinese). [3] Min Fu (2008). Libusb introduction. http://blog.csdn.net/abc19842008/archive/2008/03/13/21 77078.aspx. [4] Jonathan Corbet,Alessandro Rubini, Greg Kroah-Hartman. Linux Device Drivers (Third edition). China Electric Power Publishing House, Beijing, 2006 (in Chinese). [5] Trolltech(2008).Qt Classes. http://www.qiliang.net/qt/classes.html.
5. Acknowledgement It is an article supported by the 11th Five-Year Plan project.
6. References
806