CN102508465B - Data communication method between programmable controller and upper computer - Google Patents

Data communication method between programmable controller and upper computer Download PDF

Info

Publication number
CN102508465B
CN102508465B CN2011103015522A CN201110301552A CN102508465B CN 102508465 B CN102508465 B CN 102508465B CN 2011103015522 A CN2011103015522 A CN 2011103015522A CN 201110301552 A CN201110301552 A CN 201110301552A CN 102508465 B CN102508465 B CN 102508465B
Authority
CN
China
Prior art keywords
data
programmable controller
host computer
time
communication method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN2011103015522A
Other languages
Chinese (zh)
Other versions
CN102508465A (en
Inventor
谭建平
陈晖�
舒招强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Central South University
Original Assignee
Central South University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Central South University filed Critical Central South University
Priority to CN2011103015522A priority Critical patent/CN102508465B/en
Publication of CN102508465A publication Critical patent/CN102508465A/en
Application granted granted Critical
Publication of CN102508465B publication Critical patent/CN102508465B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The invention discloses a data communication method between a programmable controller and an upper computer. In the programmable controller, data is packed and stored in a data block of the programmable controller through circle interruption, and the data pack is transmitted to an upper computer system through an industrial field bus. In winCC software of the upper computer, the data is unpacked and stored in a text file; a function functional control is used to display data in real time; and a script is compiled to inquire data. Without the need of extra software and hardware support, the method can achieve high-speed data communication, storage, display and inquiry between the programmable controller and the winCC software of the upper computer.

Description

Data communication method between a kind of programmable controller and the host computer
Technical field
The present invention relates to the data communication method between a kind of programmable controller and the host computer.
Background technology
Upper computer software WinCC and programmable controller extensively apply to industrial control field.Though the data memory cycle of programmable controller can reach 1ms, the short data filing cycle of WinCC is 500ms, and for the data that need high speed acquisition, WinCC can't meet the demands.At present, the method for head it off mainly is to select more high-grade programmable controller for use, or writes independently data processing software, causes cost to improve, and exploitation is complicated.
Summary of the invention
Technical matters to be solved of the present invention provides the data communication method between a kind of programmable controller and the host computer, and the data communication method between this programmable controller and the host computer adopts the easiest method to realize high-speed communication at low cost.
For solving the problems of the technologies described above, the technical solution adopted in the present invention is:
Data communication method between a kind of programmable controller and the host computer, in programmable controller, on-the-spot real time data is deposited in the data block of programmable controller every time T 1, by industrial field bus this on-the-spot real time data of depositing is transferred to host computer with the form of packet;
Wherein T1 is less than the default data communication cycle between programmable controller and the host computer;
In upper computer end, the packet that receives is unpacked, and the data after will unpacking are handled; Finish the data communication between programmable controller and the host computer.
In programmable controller, adopt timer interrupt mode that on-the-spot real time data is stored.
Describedly be treated to storage, the data after perhaps directly will unpacking show, draw or inquire about.
The forming process of described packet is that the data packing process is: setting up length in data block is the integer array variable of 2N byte, wherein to be used for storing the real-time industrial field data be the shaping data to a preceding 2N-2 byte, and latter two byte is used for storing the up-to-date Position Number that deposits data in; During data storage each time, upgrade Position Number and real-time industrial field data, N is the number that the data block of foundation can be deposited the integer data.
It is that the process that data unpack is that packet unpacks: a kind of raw data variable of definition in upper computer software, its address and size are arranged to consistent with the data block in the programmable controller, the integer variable array that to set up a total length again be the 2N byte; The triggering cycle that overall script is set in upper computer software is T2, and the data block in the Programmable Logic Controller is collected in the host computer, and the data of obtaining are composed to described shaping variable array.
Described upper computer software is WinCC software, the GetTagRaw function that WinCC software is supported by calling system, data block in the Programmable Logic Controller is collected among the WinCC, and the data after the rreturn value of GetTagRaw function namely unpacked are composed to setting up good variable array; And T1=M*T2; M is the sampling number of T2 time; M and N satisfy relational expression: M<N-1.
WinCC once gathers a batch data from programmable controller with the form of raw data variable, has so just obtained complete high-speed data, has realized high-speed communication indirectly.
In WinCC overall situation script, data unpack the back by relatively this Position Number variate-value A and last secondary data unpack obtain and had Position Number variate-value B in the host computer, draw between the lane place of the valid data of twice acquisition time at interval; If A is greater than B, B was to A data in the array after then only storage unpacked in host computer, and B is individual to N-1 if A less than B, then only stores in host computer, the 1st to A data; Set up the text document data file, according to the form named file of system data with the date, the each storage of data all press " current time--the time: divide: second: the data/line feed of millisecond/line feed/first data/line feed/second/... last data/line feed " form store.
The function performance control is added in configuration data display frame in WinCC, calls the title of SetProp function setup function performance control, horizontal ordinate scope, line color.By revising " data X ", " data Y " attribute, the data that the obtain mode with the described point line is shown in control.
Configuration input and output territory in WinCC is used for receiving the querying condition of user's input, i.e. the data length of the initial query time of data, inquiry.The configuration inquire button is used for triggering C language inquiry script.In script, read in querying condition, browse the corresponding data file by the fseek function, the time that browses to is compared with the inquiry zero-time, if do not satisfy querying condition, then continue down to browse, if satisfy querying condition, begin that then institute's data query is taken out tax and give pointer variable, utilize the function performance control to show.
T1 and T2 satisfy following relational expression: T1 * M=T2, T1 〉=1ms, T2 〉=250ms, T1≤T2.Wherein, T1 is the interrupt cycle that cycle interruption is organized piece in the programmable controller, and T2 is the triggering cycle of WinCC upper computer software overall situation script, and M is the number of the new data that PLC collects in the T2 time, and T1, M, T2 are integer,
M and N satisfy following relational expression: M<N-1.Wherein, M is the number of the new data that PLC collects in triggering cycle of WinCC upper computer software overall situation script, and N is the number that the data block of foundation can be deposited the integer data.
Beneficial effect of the present invention:
Data communication method between programmable controller of the present invention and the host computer has taken full advantage of the opening of WinCC software, has used the function of system itself to greatest extent.The triggering cycle of overall script among cycle by adjusting the programmable controller cycle interruption and the WinCC, the present invention can make the communication cycle of programmable controller and WinCC be down to 10ms by the shortest 500ms and not wait, and realized data storage, demonstration and inquiry by coding, successfully satisfied the requirement of some data needs high speed acquisition.This method does not need extra software and hardware support, just can realize that programmable controller is communicated by letter with the data high-speed between host computer WinCC software, storage, demonstration and inquiry, easy to implement, wireless increase hardware cost, software programming is also simple, can finish the high-speed communication between single-chip microcomputer and the host computer cheaply.
Description of drawings
Fig. 1 is the hardware connection diagram;
Fig. 2 is the overall technological scheme synoptic diagram;
Fig. 3 is the continuous Stored Procedure figure of data in the programmable controller;
Fig. 4 is data storage flow for displaying figure among the WinCC;
Embodiment
The invention will be further described below in conjunction with accompanying drawing.
Embodiment 1:
Shown in Fig. 1-4, a kind of high-speed communication method based on programmable controller and upper computer software, concrete steps are:
1. in programmable controller, set up cycle interruption and organize piece OB35, be set its interrupt cycle is 10ms.Set up data block DB10, in data block, set up integer array variable val[1..101], val[1] to val[100] be used for the storage industry field data, val[101] be used for storing the up-to-date Position Number that deposits data in.Coding as shown in Figure 2, the control signal that transmits according to host computer judges whether needs unlatching high-speed communication function earlier, if open the processing of then carrying out the data rounding, shortening byte, mode by register indirect addressing, data are deposited among the data block DB10 continuously in final updating Data Position numbering variable.
2. in upper computer software WinCC, setting up length is the raw data variable gstag of 202 bytes, and it is corresponding with data block DB10 that its address is set.Write overall script in WinCC, it is 500ms that the triggering cycle is set.Process flow diagram as shown in Figure 3, the integer variable array that to set up a total length be 202 bytes, GetTagRaw function by calling system is supported collects the data block among the PLC among the WinCC, and the rreturn value of GetTagRaw function (data after unpacking) is composed to setting up good variable array.By relatively this Position Number variate-value A (last integer variable of array) and last secondary data unpack obtain and had Position Number variate-value B in the host computer, can draw twice acquisition time at interval between the lane place of interior valid data.If A is greater than B, B was to A data in the array after then only storage unpacked in host computer, and B is individual to N-1 if A less than B, then only stores in host computer, the 1st to A data.Set up the text document data file, according to the form named file of system data with " 20110627 ", the each storage of data all press " time (17:12:50:500) [instant, minute, second, millisecond, the numerical value here is an example] first data of n (line feed) n (line feed) ... last data n " form store.The data that gather every day are stored in the same file in the mode of appending, and the data of same date are not stored in the different files.Like this, host computer just can collect 50 data every 500ms, has realized high-speed communication indirectly, i.e. data of every 10ms.
3. the function performance control is added in configuration data display frame in WinCC, calls the title of SetProp function setup function performance control, horizontal ordinate scope, line color.By revising " data X ", " data Y " attribute, the data that the obtain mode with the described point line is shown in control.
4. configuration input and output territory in WinCC is used for receiving the querying condition of user's input, i.e. the data length of the initial query time of data, inquiry.The configuration inquire button is used for triggering C language inquiry script.In script, read in querying condition, browse the corresponding data file by the fseek function, the time that browses to is compared with the inquiry zero-time, if do not satisfy querying condition, then continue down to browse, if satisfy querying condition, begin that then institute's data query is taken out tax and give pointer variable, utilize the function performance control to show.
The triggering cycle of overall script among cycle by adjusting the programmable controller cycle interruption and the WinCC, the present invention can make the communication cycle of programmable controller and WinCC be down to 10ms by the shortest 500ms and not wait, and realized data storage, demonstration and inquiry by coding, successfully satisfied the requirement of some data needs high speed acquisition.

Claims (6)

1. the data communication method between a programmable controller and the host computer, it is characterized in that, in programmable controller, on-the-spot real time data is deposited in the data block of programmable controller every time T 1, by industrial field bus this on-the-spot real time data of depositing is transferred to host computer with the form of packet;
Wherein T1 is less than the default data communication cycle between programmable controller and the host computer;
In upper computer end, the packet that receives is unpacked, and the data after will unpacking are handled; Finish the data communication between programmable controller and the host computer;
The forming process of described packet is that the data packing process is: setting up length in data block is the integer array variable of 2N byte, wherein to be used for storing the real-time industrial field data be the shaping data to a preceding 2N-2 byte, and latter two byte is used for storing the up-to-date Position Number that deposits data in; During data storage each time, upgrade Position Number and real-time industrial field data, N is the number that the data block of foundation can be deposited the integer data.
2. the data communication method between programmable controller according to claim 1 and the host computer is characterized in that, in programmable controller, adopts timer interrupt mode that on-the-spot real time data is stored.
3. the data communication method between programmable controller according to claim 1 and the host computer is characterized in that, describedly is treated to storage, and the data after perhaps directly will unpacking show, draw or inquire about.
4. the data communication method between programmable controller according to claim 1 and the host computer, it is characterized in that, it is that the process that data unpack is that packet unpacks: a kind of raw data variable of definition in upper computer software, its address and size are arranged to consistent with the data block in the programmable controller, the integer variable array that to set up a total length again be the 2N byte; The triggering cycle that overall script is set in upper computer software is T2, and the data block in the Programmable Logic Controller is collected in the host computer, and the data of obtaining are composed to described shaping variable array.
5. the data communication method between programmable controller according to claim 4 and the host computer, it is characterized in that, described upper computer software is WinCC software, the GetTagRaw function that WinCC software is supported by calling system, data block in the Programmable Logic Controller is collected among the WinCC, and the data after the rreturn value of GetTagRaw function namely unpacked are composed to setting up good variable array; And T1=M*T2; M is the sampling number of T2 time; M and N satisfy relational expression: M<N-1.
6. the data communication method between programmable controller according to claim 5 and the host computer, it is characterized in that, in WinCC overall situation script, data unpack the back by relatively this Position Number variate-value A and last secondary data unpack obtain and had Position Number variate-value B in the host computer, draw between the lane place of the valid data of twice acquisition time at interval; If A is greater than B, B was to A data in the array after then only storage unpacked in host computer, and B is individual to N-1 if A less than B, then only stores in host computer, the 1st to A data; Set up the text document data file, according to the form named file of system data with the date, the each storage of data all press " current time--the time: divide: second: the data/line feed of millisecond/line feed/first data/line feed/second/... last data/line feed " form store.
CN2011103015522A 2011-10-08 2011-10-08 Data communication method between programmable controller and upper computer Active CN102508465B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011103015522A CN102508465B (en) 2011-10-08 2011-10-08 Data communication method between programmable controller and upper computer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011103015522A CN102508465B (en) 2011-10-08 2011-10-08 Data communication method between programmable controller and upper computer

Publications (2)

Publication Number Publication Date
CN102508465A CN102508465A (en) 2012-06-20
CN102508465B true CN102508465B (en) 2013-10-09

Family

ID=46220566

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011103015522A Active CN102508465B (en) 2011-10-08 2011-10-08 Data communication method between programmable controller and upper computer

Country Status (1)

Country Link
CN (1) CN102508465B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103513602B (en) * 2012-06-29 2016-06-22 中国科学院大连化学物理研究所 The PLC waveform data of a kind of accurate timer shaft produces and storage method
CN104049621B (en) * 2014-07-03 2016-09-28 中南大学 A kind of based on host computer with the system identifying method of Programmable Logic Controller
CN107861378A (en) * 2017-11-17 2018-03-30 青岛杰瑞工控技术有限公司 A kind of building method of the multiserver Intelligent remote monitoring system based on WINCC platforms

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19914829A1 (en) * 1999-04-01 2001-01-11 Siemens Ag System and method for in particular graphic monitoring and / or remote control of stationary and / or mobile devices
CN100359517C (en) * 2003-07-24 2008-01-02 上海宝信软件股份有限公司 Method for acquiring, storing and analyzing high-speed process data
CN100487614C (en) * 2006-11-09 2009-05-13 南通明兴科技开发有限公司 Communication method between superior machine and PLC in monitoring system
CN101826273B (en) * 2009-11-11 2012-04-25 深圳市和怡科技有限公司 Network connection based teaching equipment adopting multiple numerical control systems and communication method

Also Published As

Publication number Publication date
CN102508465A (en) 2012-06-20

Similar Documents

Publication Publication Date Title
CN102508465B (en) Data communication method between programmable controller and upper computer
CN103064805A (en) Serial Peripheral Interface (SPI) controller and communication method
CN102662889B (en) Interruption processing method, interrupt control unit and processor
CN101162398A (en) Arbitrarily signal generating device
CN104395845A (en) Control device
CN104063441A (en) Database operation maintenance system and data operation maintenance method thereof
CN109521738A (en) Plant data processing system and method based on agreement transmission
CN102768666A (en) Method and system for storing and reading industrial data
CN102521318A (en) General data exchange device based on extensible markup language (XML)
CN104111961A (en) Data item display refreshing method and device
CN103077142A (en) Simple communication method of bus transmission protocols
CN101895273B (en) Filter of multi-system data and filtering method
CN202841079U (en) Pulse signal generator and pulse signal generation system
CN104049621B (en) A kind of based on host computer with the system identifying method of Programmable Logic Controller
CN205016216U (en) Display screen interface converting device and intelligent wrist -watch
CN103353977A (en) Method for carrying out transmission based on preferentially selecting important remote measurement in power plant unit adjustment
CN105335232A (en) Time sequence multiplexing-based FPGA resource optimization scheme
CN204288762U (en) Novel intelligent Multifunctional LED dot matrix screen control system
CN101996149A (en) Data acquisition method and device
CN1127222C (en) Radio with halting apparatus and method
CN203909588U (en) Cluster-type drug extraction apparatus management system
CN204334567U (en) A kind of monitoring communicator of large-sized multifunction bluetooth video system
CN205958988U (en) High -speed processing system of intelligent agriculture machinery based on thing networking
CN101093483A (en) Method for collecting and refreshing data of knowledge base
CN110083567A (en) A kind of chip architecture

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant