Abstract: The frequency changer is in industrial automation system’s basic dragging equipment. When using the environment very severe, does not suit in the human carries on the control directly to the frequency changer needs to carry on the remote control when the scene to the frequency changer. Mainly introduced how to use VC to compile the control software to carry on the networking control to the frequency changer.
Key word: Frequency changer; Control software; Networking control
Introduction
The frequency changer is in industrial automation system’s basic dragging equipment, usually uses in controlling alternating current machine’s rotational speed and changing. If frequency changer’s job site environment is quite bad, does not suit in the human carries on the control in the scene to the frequency changer, then needs to carry on the long-distance networking control to the frequency changer.
1 basic composition
Connects computer’s serial port composition network frequency changer’s RS485 serial port through the RS232/485 switch, this network system is mainly composed of three parts.
The first part is frequency changer’s network function part, including hardware and software two parts. The hardware part is on the frequency changer control panel the CPU serial port a RS485 connection which (for example MAX485) forms outward after the RS485 transformation chip, may meet through this connection the frequency changer the directed net. The software part is frequency changer’s signal procedure. May cause the frequency changer through this signal procedure after receiving computer’s issuing instruction, according to the instruction makes the corresponding reply and the movement. On frequency changer’s signal procedure mainly includes the serial port initialization routine, the order read and the calling order, the order judgment procedure and the order collection.
The second part is the computer control procedure. This procedure has the man-machine conversation function, may carry on the long-distance surveillance and the control to frequency changer’s condition, can make the revision to frequency changer’s parameter. In brief, the human may the operation which carries on to the frequency changer be supposed to be possible to realize in the scene on this control software.
The third part is the communication protocol. This is between the computer and the frequency changer carries on the correspondence the basis. Frequency changer’s correspondence software and computer’s control software defers to the information format which this communication protocol stipulated to carry on the compilation.
May complete the frequency changer remote control function which by these three part of constitution’s frequency changer remote control network hoped. Frequency changer remote control network configuration chart as shown in Figure 1.
2 compile the computer control software under the VC environment
The computer control software’s main contact surface which compiles with VC selects the single text contact surface, and brings the Windows browsing window, the contact surface base class selects the CFormView kind. The main contact surface had demonstrated controls in network frequency changer’s constitution and address. Each frequency changer’s detailed information demonstrated that selected the CpropertyPage kind to make the dialog box. The CpropertyPage kind is inherits the development from a Cobjec kind of group to come, may regard as is the label dialog box. The control software has demonstrated two aspect detailed information for each frequency changer: One is frequency changer’s functional code information, another is frequency changer’s remote control and the current condition. These two aspect information’s demonstration each is with a CpropertyPage kind of dialog box. Demonstrated regarding frequency changer’s functional code, because frequency changer’s functional code constitutes by many groups, moreover the demonstration request grouping carries on, therefore controls using Tab to carry on the grouping choice cut. We transferred some Text, Edit and Button regarding frequency changer’s remote control and the current condition contact surface control. These control through the news (for example BN_CLICKED, UpdateData(TRUE) and so on information) to be connected with the corresponding subroutine. Once we carry on the control action or the procedure to the frequency changer receive frequency changer’s feedback information, the contact surface will have the corresponding change. Entire control software’s procedure flow as shown in Figure 2.
May see the control software request from the flow chart to be able to obtain the networking frequency changer’s condition unceasingly, this request control software does not stop after-crops frequency changer’s condition inquiry instruction. This function through established a timer in the procedure SetTimer(1,10000, NULL) to complete. The timer causes control software each 10s to carry on a next state to the frequency changer to inquire, inspects the frequency changer whether online. If online will reflect this frequency changer current each condition, if not online will have the corresponding prompting message demonstration. Computer and when frequency changer network software’s main contact surface chart as shown in Figure 3.
On the control software contact surface demonstrated the network information and each frequency changer’s parameter information needs to coordinate the corresponding database to be able to complete. But regarding the network in each frequency changer status messages obtains, then must realize through the computer serial port upload to the scene frequency changer performance data. Below separately introduced how the control software is carries on the operation to the database and the computer serial port.
3 using DAO technical operation database
The database is a modern computer application important component, is the people carries on the data storage, sharing and the processing tool effectively. Two kind of main database type, namely plane database and relational database. In brief, the plane database is a group of record set, in database each record is by the field constitution, the first field has contained the specific information which closes with this oblong seal video recording. The relational database likely is connects by certain plane database is forming together. Uses the relational database to be able to establish between a record set and another record set relations. In the relational database, each record set is called a table, between the table connection is realizes through the key words, the key words use for to determine a record the value.
What this control software’s database use is the plane database. In the database saved in the frequency changer network information and the network each frequency changer’s parameter. The database establishes with Access, takes the database using DAO the visit connection. MicrosoftJet was looks like Access and VisualBasic such product has provided the data engine. DAO uses the MicrosoftJet database engine to visit the database. VisualC 6.0 provided to the DAO seal, the MFCDAO kind has sealed the DAO majority of functions, thus enabled the VC procedure to be possible to use the MFCDAO kind to carry on the database visit conveniently.
How does the below concrete narration complete software’s network control function using the database. First uses Access to establish the frequency changer network the information table, then in the procedure establishes a base class is (a kind which CdaoRecordset in DAO seals) kind of Cdata, this kind commends contacting with the database in frequency changer network information. When must increase a frequency changer when the network, not only need carry on the increase data manipulation in the frequency changer network information table, but must increase one in the database about this frequency changer functional code new table. Has used CdaoRecordset to the frequency changer network information table’s increase operation kind of database indicator m_leftptr. The CdaoRecordset kind is to the DAO record compendium object seal, represents one kind of record which chooses from the data pool, manages in the database the outside and inside record operation. But must increase an additional frequency changer functional code in the database the new table, needs to establish a CdaoDatabase kind of variable. The CdaoDatabase kind is to the DAO database object seal, it has represented a database connection, manages the database in the operation and the database the table operation. Below is in the network increases when a frequency changer to the database operation sequence.
CComzDoc*pDoc=(CComzDoc*)GetDocument();
m_leftptr=&pDoc->m_Docptr;
CAddNodeDlgm_addnode;
if (m_addnode.DoModal()==IDOK)
{
m_leftptr->Open();
m_leftptr->AddNew();
m_leftptr->m_NodeAddress=
m_addnode.m_adddress;
m_leftptr->m_NodeName=
m_addnode.m_addnodename;
m_leftptr->m_NodeOrderCalled=
m_addnode.m_comturn;
m_leftptr->Update();
m_leftptr->Close();
CDaoDatabasem_pDatabase;
m_pDatabase.Open (”ConverterPc
97.mdb “);
CDaoTableDeftable(&m_pDatabase);
table. Create (m_addnode.m_addnodename);
table.CreateField (”AutoIndex”, dbInteger,2);
table.CreateField (”ParaGroup”, dbText,10);
table.CreateField (”ParaNo”, dbInteger,2);
table.CreateField (”ParaName”, dbText,100);
table.CreateField (”ParaDefaultVal”, dbInteger,2);
table.CreateField (”ParaCoefficient”, dbInteger,2);
table.CreateField (”ParaDW”, dbText,10);
table.CreateField (”ParaModif”, dbInteger,2);
table.CreateField (”ParaMemo”, dbText,255);
table. Append();
m_pDatabase.Close();
}
After the increase completes, if this frequency changer online completes the initialization database order, initialization frequency changer’s functional code. On the software demonstrated that frequency changer functional code database as shown in Figure 4.
The deletion which and the renewal operation in the table deletion and the table records to control software’s database in use the DAO kind are the same, is only the use instruction is different, here no longer gives unnecessary detail. In the frequency changer function stopwatch’s concrete data, needs to obtain through the serial port correspondence from the corresponding frequency changer, this must use VC to program to the computer serial port.
Figure 3
4 computer serial port communication programming
May use many kinds of methods regarding the VC computer serial port correspondence programming to realize. MSComm controls through the serial port transmission and the receive data, therefore, may in the compilation computer serial port signal procedure time uses MSComm to control. MSComm controls when a use is quite convenient, so long as completes the simple serial port initialization establishment, then the transfer corresponding read-write function then completes the computer serial port communication operations. But, uses MSComm controls when the establishment correspondence parameter is carries on groups, namely the data transfer rate, the parity check, the data figure and the stop figure take a parameter to carry on the establishment. Like this causes the correspondence parameter the establishment and the revision not too nimble freely, therefore, does not use MSComm to control to carry on the serial communication programming. Corresponds the API function using Windows to carry on the serial port correspondence programming to be possible to carry on the serial port parameter very nimbly the disposition, but programs is complex, the specialized degree is high, therefore has not used. And so on carries on the operation programming using VC standard correspondence function inp, inpw, inpd, outp, outpw, outpd to the serial port to need directly to understand to hardware circuit’s structure principle, but here does not need to understand to computer’s serial port electric circuit, therefore same has not used. In what the final procedure applies is the third party compilation serial communication Cserial kind. Below carries on the explanation to the CSerial kind.
CSerial::CSerial is the kind of structure function, does not have the parameter, is responsible for the initialization all kind of member variable.
CSerial::Open opens communication port’s member function, has two parameters, one is the serial port number, another is a baudrate.
CSerial::Close closes communication port’s member function. The kind analyzes construction function call this function, therefore may not use explicit transfer this function.
The CSerial::SendData function writes about the data from a buffer the serial port. It brings the first parameter is the buffer indicator, contains must the material which transmits. This function returns to some to port’s actual byte count.
The CSerial::ReadDataWaiting function returns waiting in the communication port buffer’s data, does not have the parameter.
CSerial::ReadData function from port receive buffer read-in data. The first parameter is the buffer indicator, the second parameter is the integer value, gives the buffer the size.
Increase into the source program CSerial.cpp and CSerial.h, transfers a CSerial kind of function in the serial port signal procedure part, may complete the correspondence function very conveniently. Below is in the procedure with the CSerial kind of compilation signal procedure, completes the function is according to the communication protocol which decides to the frequency changer network downloading inquiry instruction, and receives from the station returns information. If launches in salvos three times has not received frequency changer’s response message to demonstrate the frequency changer for the off-line condition.
CSerialSerial;
inti;
CStringm_mes;
Unsignedcharsend[14]={0×02,0×0c,0×00,0×00,0×00,0×00,0×00,0×00,0×00,0×77,0×80,0×00,0×00,0×00};
for (i=1; i<=m_slname; i )
{
send[2]=i;
unsignedcharu=send[0];
for (intl=1; l<13; l )
{u=u^send[l];
}
send[13]=u;
showaf=send[10];
if (Serial.Open(m_port, m_baudrate))
{
Serial.SendData(send,14);
}
Sleep(200);
if (Serial.ReadDataWaiting())
{
Serial.ReadData(recieve,14);
}
else
{
Serial.SendData(send,14);
Sleep(200);
if (Serial.ReadDataWaiting())
{
Serial.ReadData(recieve,14);
}
else
{
Serial.SendData(send,14);
Sleep(200);
if (Serial.ReadDataWaiting())
{
Serial.ReadData(recieve,14);
}
else
{
m_mes. Format (”%disoffline”, i);
m_recc.InsertString(-1, m_mes);
}
}
}
Figure 4
In requests computer’s serial port number and the correspondence speed with in frequency changer’s correspondence is invariable. The Open function’s two parameters are computer’s serial port number and the correspondence speed, when transfers this function initialization serial port, pressed the number evaluation which these two parameters hoped to be possible to correspond normally. If must revise these two parameters, so long as will revise the value to bestow on for these two parameter variable, transfers a time Open function anew initialization computer serial port again then. Has only initialized in the Open function the serial port number, the correspondence speed and 8 bit data position these three parameters, other parameters use the parameter data which the previous serial port initialization forms. But, also requests the transmission in the correspondence the data for the binary data, occasionally to verify and to have 1 stop position, this requests to the Open function to make the revision. To the Open function’s revision is mainly to device control quick (DCB) revision. So long as the old DCB structure will rewrite for the below structure then.
GetCommState(m_hIDComDev,&dcb);
dcb.BaudRate=nBaud;
dcb.ByteSize=8;
dcb.fParity=1;
dcb.fBinary=1;
dcb. Parity=EVENPARITY;
dcb.StopBits=ONESTOPBIT;
After the above revision, conformed to the transmission binary number with the Open function initialization’s serial port, occasionally to verify, 8 bit data positions, 1 stop position and the baudrate and the port invariable request, the computer may carry on the normal correspondence with the frequency changer.
5 network experiments
After the remote control software completes, carries on the network experiment. In the network connects two frequency changers with a computer, to a frequency changer execution clockwise starts to the 30Hz control command, the software control contact surface demonstrated that as shown in Figure 5.
Figure 5
6 conclusions
This article mainly introduced how realizes the frequency changer long-distance network control computer control software to compile. From software’s function frame, the database operation and the computer serial port corresponded 3 aspects to carry on the elaboration, explained in detail got down control software’s method which in the VC environment the compilation conformed with us to request, had certain actual reference value.