The Application of Control Technology Based on Serial Port Communication
Junjie Zhang
Wuhan University of Science and Engineering
Wuhan, Hubei, China zhantgjunjie.hs@gmail.com
Abstract—connected by RS-232 serial port line, so mechanical arm and In this article date glove and mechanical arm are date glove are very critical in the date transmission among computers. Under windows serial port communication can be realized in the two methods below: making use of ActiveX control and API communication function. In this passage the advantages and shortcomings of the realization of the two methods will be compared, and the method which is the most suitable for this article will be chosen, and the mechanical arm control program will be developed.
Keywords-component; Robot control; Serial port communication I. INTRODUCTION
developed rapidly in recent years. The appearing and Robots are an important field of high technology development of robots has caused radical changes in the traditional industrial production, which makes people automatically step into the intelligent and new epoch from hand work, mechanization and robotization. Presently, robots are not only used more and more widely in industry, but also exploring new applications in ocean exploitation, astrospace, military operations and emergency rescue and disaster relief, which will extend people’s production and activity area, and boost the ability of people’s creative labor greatly.
mechanical arm, data glove and RS-232 serial port line, This passage researches the main contents: on the basis of using serial port communication technique and synchronization technology, operators can control mechanical arm by manipulating data glove directly. The traditional mechanical arm control software adopts mostly: operators control the movement of robots by sending orders to computers, but this kind of control manipulation is very complex and not direct [1], the operators need to be trained in advance, and it is of high demand to the operators; and this article adopts the form: operators control robots directly by wearing data glove, and there is a generative virtual scene to assist the operation, what’s more, the operation is simple and direct, and the operators don’t need any training beforehand, and it demands simple to the operators, so operators can easily control the robots instantaneously and exactly. At present [2], some new related research has been done in domestic institution and some implementation plan has been brought forward accordingly. But it has not been applied in to practice.
II. SYSTEM FRAMEWORK
and the purpose is: operators wear data glove to control This topic is a subsystem of the remote operating system, mechanical arm instantaneously through computer system, and there is a generative dummy scene to assist the operation, under the circumstances of not seeing the mechanical arm, operators can also adjust accordingly to mechanical arm via changing the pose of the dummy hand [3] [4].
978-0-7695-3728-3/09 $25.00 © 2009 Crown CopyrightDOI 10.1109/CASE.2009.129
Wei Wei
Wuhan Optics Valley Human Resources Service Center
of China
Wuhan, Hubei, China 112015927@qq.comi.com
control system, the computer software system and the The whole system divides into three major parts: The mechanical arm, the three parts are interactive, constitute a whole system, as the figure 1 shows. Figure 1. System framework
Zhongmin mechanical arm with 6 degree-of-freedom The main hardware equipment used in this topic: (Hereafter referred to ZMA6), 5DT data glove (Hereafter referred to data glove) and RS-232 serial port line, and they will be brief introduced in the following. 1)The standard of RS-232 serial port
lines and of low cost, especially avoiding the variance of Because serial commucation has the feature of using few several pieces of lines in teletransmission. The two sides of communication are required to adopt one standard interface in serial communication to make different pieces of equipment connected expediently to communicate. At present, RS-232 is a kind of serial interface that is most widely used in computer and communication industry. RS-232 is defined as a kind of single-terminal standard in serial communication of low velocity to increase the distance of communication. 2) ZMA6
applied automated mechanism in robot technology. It has At present, the mechanical arm is the most widespread been applied in manufacture, medical treatment, entertainment services, military as well as space exploration and so on. Although their forms are different respectively, they have a common feature: it can accept the instruction, locate precisely to three-dimensional (or two-dimensional) spatial spot and perform operation.
control. It is composed of 7 precise servomotors with 6 ZMA6 is a model on the method of mechanical arm degrees-of-freedom in all, corresponding separately to the base, the arm, the elbow, the forward wrist, the back wrist, the pliers’ six rotating revolution axes, and each revolution axis may move in the scope of ±80 degree, as the figure 2 left shows.
3) Data glove
without the position tracking device's which has seven In this paper, data glove is 5DT Corporation data glove sensors installed on each finger and a 2-axle tilt sensor on the wrist. It may detect glove's rotation (to circle the Z rotation of axis) and incline (circles X rotation of axis) angles in searching for swinging and revolving. The 5DT data glove uses the advanced sensing technology, can acquire seven groups of data quite precisely through the gain thumb, the index finger, the middle finger, the ring finger, the little
472
finger, rotation and incline. The function base can be carried on the re-development. Data glove and computer can be connecting through RS-232 serial port line, as the figure 2
comparatively complicated when used in practical programming, we need to know the usage of every function and some information on the bottom of the operating right shows.
Figure 2. ZMA6 and data glove
III. KEY TECHNOLOGY
1) The fundamental theory of serial port communication
computers or computers and computers is usually called data The communication between terminal equipment and communication. There are two kind modes of data communication: synchronous communication mode and asynchronous communication mode.
communication mode requires the two sides of Synchronous communication mode: Synchronous communication going along at the same velocity, and being coordinated exactly. It ensures the sender and the receiver to be synchronous exactly by sharing a single clock and cimmutator pulse. The characteristic is allowing sending sequences of characters. The character data in the USA have the same decimals, and they have no start bit and stop bit, and the efficiency is very high.Synchronous communication transports data blocks composed of many bytes(from dozens of bytes to thousands of bytes) as the units, and adds identifier constituting frame to data blocks.
communication mode doesn’t require the two sides to be Asynchronous communication mode: Asynchronous synchronous, the sender and receiver can make use of their clock sources separately, the two sides follow the asynchronous communication protocol, and regard character as data transfer unit, the interval that the sender transports character is uncertain. Each chatacter begins to transport with start bit, and ends with stop bit. The data bit of the character, the even-odd check method and the stop bit that have been appointed by the two sides of communication must be of homology. The advantage is that the cost is nethermore. Asychronous communication transports character as the units, and the length is five to eight bytes. 2) The application research of ActiveX control and Windows API communication functions
the application of ActiveX control and Windows API Analyze and compare the advantages and disadvantages of communication functions in VC++6.0, then select the most suitable method to develop mechanical arm serial communication program.
Windows API communication functions
Interface) is the basic of all the applications under Windows. Windows API (Windows Application Programming Simply speaking, API is a series of routines, the applications request the operating system to complete some low sevice through transfering these routines. In the graphical user interface like this under Windows, the windows ico, menus and dialog boxes, etc of application are managed and maintained by API.
programmings involved in Windows API functions, these There are more than twenty communication API functions are not necessary used in practical programming, so we should choose the functions that is to be used according to the need. Windows API functions is
system.It demands a little highly for the users, but Windows API also has more flexibility and can be modified on the basis of it. Applying API functions to serial programming, the gradual programming step are as following: 1) Open serial port: CreatFile function.
2) Set up the serial communication event: CreatEvent function.
3) Initialize the serial port, and setting the parameters of the serial port: SetCommState function.
4) Set up the threads for reading data: Setting up the threads is not necessary in simple programming, the functions needed is superior, for example ReadFile etc. 5) Write data: Using WriteFile.
6) Close the port when it is finished: If the programming has opened other threads, terminate the threads first. ActiveX control
operated based on COM server, and it can be tumbled in the ActiveX control is a dynamic link libraries, and it is application of the parasitifer of the package container.ActiveX control is OLE control at one time. ActiveX control has nothing to do with the development platform; consequently, what is developed in one programming language can be applied to another platform with no modification. Microsoft Communications Control (MSComm for short) is a kind of serial port communication programming ActiveX control under simplified Windows, which is provided by Microsoft Company. And it provides a simple method for the application through serial port receiving and sending data. MSComm control is very convenient in serial port programming, so it doesn’t take the programmers much time to understand the complex API function, and it can be used in both VB and VC. It provides a series of interfaces that the standard communication command uses. And we can use it to set up the connection with serial port and link with other communication apparatus via serial port, end demands, exchange data, and guard and respond the events and defaults that happened in the series connection. What’s more, MSComm control is provided by Microsoft Company, and its function is very perfect, and it can deal with Chinese. But the realization of the communication fuction of this control is the result of indirectly transferring Windows API programming.It just explains by Comm.drv, and then it is passed to the driver of the equipment.
communication command uses. And we can use it to set up It has gotten across a series of interfaces that the standard the connection with serial port and link with other communication apparatus via serial port, send demands, exchange data, and guard and respond the events and defaults that happened in the series connection. What is to be paid special attention to is that when using MSComm control, one MSComm control can only correspond to one serial port at the same time. If the application needs to visit and control several serial ports, more MSComm controls must be used.
The fundamental procedures of using MSComm control to serial port programming in different applications are the same, there are several main procedures included in the following:
1) Add Microsoft Communication Control to the built process engineering.
2) Add the controlled variable (or object) of MSComm control ID.
3) Initialize the serial port, and intercalate the attribute of MSComm control.
4) Add the message-handler function OnComm () function of serial port event.Write the codes of data processing according to the applied demand in the function. 5) Write serial port sending codes and other codes.
473
CString str1=IntToCString (m_madanumber);
CString str2=IntToCString (m_ref); //Add variable CString STR;
str.Format (\"FF%s%s\CByteArray hexdata;
String2Hex (STR, hexdata);
m_ctrlComm.SetOutput (COleVariant (hexdata)); //Send data
5) Data processing: The communication protocol of mechanical arm has been designed in the front, now we will use programs to achieve it. In order that the sending data could meet the demands, I have developed three functions: String2Hex() changes the variable of string kind into hexadecimal number, and ConverHexChar is a function that IV. THE REALIZATION OF THE SYSTEM
turns characters into the corresponding values of
The two methods for realizing serial port communication hexadecimal number, and IntToCString is to change the in VC++6.0 have been introduced in the above. The method integer into the variable of CString,and if the digit of the 6) Close the serial port.
The function of MSComm control is powerful and the attributes are also more, but the common communication program only needs several frequently-used attributes as follows:
CommPort intercalates and returns the communication port number.
Settings intercalate and return the baud rate, the even-odd check, the data bit and the stop bit by means of the character string.
PortOpen intercalates and returns the state of communication port, and it can open and close port as well.
used in this passage is the MSCOMM control in ActiveX control to dominate the mechanical arm. The process for realizing that the mainipulator controls software will be introduced concretely in the following. The detailed procedures of using MSCOMM control to write programs by mechanical arm: application based on dialog boxes, then add controls to the 1) Constitute the item: Open Visual C++6.0, set up a MFC main dialog box. the submenu of Add To Project under Project menu, then 2) Choose the Components and Controls options, which is double click the Registered ActiveX Controls in the popuped dialog box(wait for a moment, the course is a little slow), so all the ActiveX controls that have been registered will appear in the list box. Choose Microsoft Communications Control, version 6.0, click the Insert button to insert the Project, and accept the defaulted options. (If you don’t see Microsoft Communication Control version 6.0 in the list of controls, maybe you don’t choose the ActiveX option when you install VC6, just reinstall VC6, and choose the ActiveX option). Then you can see the telephone ico that doesn’t exist before in the control bar, just pull the telephone ico to the dialog box, so the kinds of MSCOMM are added, next add an object, and the ico telephone can’t be seen after running the program.
OnInitDialog () function, which is in the main dialog box, 3) Initialize the serial port: Now open the serial port in and adds the following codes:
//TODO:Add extra initialization here If (m_ctrlComm.GetPortOpen ()) m_ctrlComm.SetPortOpen (FALSE);
m_ctrlComm.SetCommPort (2); //Choose com2 if(!m_ctrlComm.GetPortOpen())
port
m_ctrlComm.SetPortOpen (TRUE); //Open the serial Else AfxMessageBox (\"cannot open serial port\");
9600, no verification, 8 data bits, 1 stop bit m_ctrlComm.SetSettings (\"9600, n, 8, 1\"); // Baud rate data by means of binary system m_ctrlComm.SetInputModel (1); //1 expresses verifying that it will lead to a received data OnComm event when there m_ctrlComm.SetRThreshold(1); //parameter 1 expresses are greater than or equal to one character in the serial port
receive buffer
length of the current receiving area to be 0
m_ctrlComm.SetInputLen (0); //Intercalate the data of the residual data first.
m_ctrlComm.GetInput (); //Preread the buffer to get rid BN_CLICKED manipulation function to the sending button 4)Add sending function:Add a click message, that is first, then open ClassWizard, choose Message Maps,and then
choose the kinds of CSCommTestDlg, next choose
IDC_BUTTON_MANUALSEND, then double click
BN_CLICKED to add OnButtonManualsend() fuction,and add the following codes in the function:
character is 1, add 0 in the first place,but if the digit of the character is 2, the digit is not changed, this is because the designed communication protocol thinks of 2 as the minimum units. interface of the program is very concise, and the The last impression is just as shown in the figure3, the manipulation is quite simple, too. Input any number from 0 to 6 in the Motor window, each number has its corresponding motor; and input any number from 0 to 254 in parameters; each number has its corresponding fixed position of the joint. Click sending after inputting the two numbers, then the mechanical arm can be controlled to the appointed position. If the assistant software of serial port debugging is opened, intercalate the serial port at COM1 (the mechanical arm controls the COM2 port used by the program, if the mechanical arm controls the program to use the COM1 port, and then intercalate the assistant software of serial port debugging at COM2). Pitch on the display of hex, other settings adopt Windows default, and then click sending again, and the mechanical arm can be seen removing as required. It illuminates that the mechanical arm control software has successfully simulated the designed mechanical arm communication protocol. Figure 3. Operation Interface V. THE FUTURE DEVELOPMENT dataglove has been realized, but it just realizes the operation
In this topic, the aim of controlling mechanical arms by on the same computer. Enter into 21st century, the robot technology is changing with each passing day, many high
and new technologies have been amalgamated with robot technology. Looking forward to the future development, there are three main trends.
1) Machine learning acquire knowledge: one is that the knowledge engineer There are two methods if we want the computers to concludes and arranges the concerned knowledge, and
indicates it as an acceptable and computerizable style to 474
computers to input the computers, the another is making the computers itself gain the ability of knowledge, and they can study the knowledge that the human have owned, and summarize and consummate constantly in practice, and this mode is called machine learning. 2) Pattern identification
Pattern identification is studying how to let the machines have perception, mainly studying the identifications of visual model and auditory model, such as identifying objects, topographies, images and fonts, etc. The method of applied fuzzy mathematics model and artificial neural nets model that has rapidly developed recently has gradually take the place of the traditional recognition methods that used statistical model and structural models. 3) Multicenter human-computer interaction
Multicenter human-computer interaction is a trend that is developing in the future. We can research how to accede to brought in, so the running of the whole system can be more consummate.
REFERENCES
[1] Robust scheme of global parallel force/position regulators for robot
manipulators under environment uncertainty Chunqing HUANG; Lisang LIU; Xinggui WANG; Songjiao SHI Journal of Control Theory and Applications, 2007 Vol.5.
[2] Rafael Valencia-Garciaa, Rodrigo Martinez-Bejar, Alessandro
Gasparetto, An intelligent framework for simulating robot-assisted surgical operations, Expert Systems with Applications 2005,28:425–433.
[3] Dexterous Robot Hand Control with Data Glove by Human Imitation
Kiyoshi HOSHINO IEICE Transactions on Information and Systems, 2006 Vol.E89-D No.6
other interaction path, such as eye tracking and voice recognition etc under the interaction path that this system is existing.And we may research for the integration problem of interaction path and make use of the data on each path sufficiently and reasonably. Then strengthening the real information and achieving locomotor calibration can be
[4] Adaptive path-constrained control of a robotic manipulator in a task
space Miroslaw Galicki Robotica, 2007 Vol.25.
475
因篇幅问题不能全部显示,请点此查看更多更全内容