Multi-functional data collector, acquisition system and method based on wisdom factory
Technical field
The invention belongs to industrial Internet of Things communication technique field, more particularly to a kind of distributed multifunctional data acquisition unit,
Acquisition system and method.
Background technology
Technology of Internet of things develops rapidly in recent years, and the various products based on Internet of Things application technology emerge in an endless stream, also absurd fantastic
Give birth to that species is abundant, Various types of data collector product vdiverse in function.From " industry 4.0 ", " industry internet " and " China's system
After making the rise of the concepts such as 2025 ", industrial circle can upload even more there is an urgent need to which the Various types of data such as field apparatus are gathered in real time
To the server end on upper strata.But the controller species very abundant of industrial field device at this stage, communication interface type are more
Sample, communications protocol are multifarious.
In order to solve the problems, such as the Data Collection of equipment, it is necessary to spend very big energy and cost, and traditional data are adopted
Truck can only gather the hard spot signal such as some DI, AI.Industrial this present situation, seriously constrains the development of industrial Internet of Things, hinders
" the process of industry 4.0 " is hindered.
The content of the invention
Instant invention overcomes above-mentioned the deficiencies in the prior art, there is provided one kind disclosure satisfy that most industry are existing
The data acquisition of field device, and network structure is simple, the multi-functional data that conveniently further can be flexibly coordinated its function
Collector, acquisition system and method, so as to it is more economical, convenient, efficiently by the various equipment in scene and the number of distributed collection point
According to reading, complete and accurate bottom data is provided for the foundation of wisdom factory.
The technical proposal of the invention is realized in this way:
A kind of Multi-functional data collector based on wisdom factory, including microprocessor and be connected respectively with microprocessor
Power module, 485 transponder chips, 232 transponder chips, I/O signal change-over circuit and two Ethernet protocol chip stacks;
Power module is used to provide power supply for collector;485 transponder chips, 232 transponder chips respectively have RS-485 interfaces,
RS-232 interface, for connecting external equipment and collecting device data;Ethernet protocol chip stack has Ethernet interface, is used for
Connection host computer or other collectors simultaneously transmit data;I/O signal change-over circuit, there is I/O port, for connecting external equipment simultaneously
Gather signal or equipment is controlled, 485 transponder chips, 232 transponder chips, I/O signal are changed electricity by microprocessor
Road, the signal of Ethernet protocol chip stack collection or data are handled and managed.
Preferably, described microprocessor is the STM32F103C8 single-chip microcomputers based on Cortex-M3 kernels.
Preferably, 485 transponder chips are SP3485 chips, 232 transponder chips are SP3232 chips.
Preferably, I/O signal change-over circuit includes being used to gather and controls the simulated measurement input circuit of analog signal, uses
In the switching value input circuit of controlling switch amount signal and switching value output circuit for controlling low-power equipment.
Preferably, it is also associated with power isolation module between power module and 485 transponder chips.
Based on the more Function Data Collect System of wisdom factory, including host computer, master device, collected equipment and such as
Upper described at least one data acquisition unit, RS-485 interfaces, RS-232 interface are separately configured to lead by host computer
Stand or slave station mode;When being configured to slave station mode, master device can be carried out by ModbusRTU agreements to data acquisition unit
Read-write operation;When being configured to master station mode, again can by host computer to this be configured to master station mode interface it is logical
News agreement is selected, so as to which the collected equipment different from scene is communicated.
Preferably, described master device is PC or PLC.
Based on the acquisition method of above-mentioned more Function Data Collect System, when electric on data acquisition unit, initialized first
Processing, after it is stable, the Ethernet protocol chip stack, 485 transponder chips, 232 transponder chips of collector are carried out just
Beginningization processing;Then initialization operation is carried out to communications parameter, I/O channel pattern with host computer configuration software, wait to press confirmation by
After button, program judges parameter setting success, then configuration terminates;RS-485 interfaces, RS-232 interface by host computer independently
Ground is configured to main website or slave station mode;When being configured to master station mode, master station mode is configured to this by host computer
The communications protocol of interface is selected, so that data acquisition unit is communicated from live different collected equipment;When with
When being set to slave station mode, master device can be written and read operation to data acquisition unit by ModbusRTU agreements, to obtain it
The data of collection.
Preferably, when site layout project during multiple data acquisition units, each collector is by Ethernet interface with chrysanthemum
The form of chain is connected, and to form distributed data acquisition system, host computer or master device can be assisted by ModbusTCP
View, read the data of Ethernet interface.
Preferably, the above method specifically refers to:
One, first, initialization function is called on microcontroller after electricity, to clock, interruption and GPIO, serial ports, timer,
Analog-digital converter ADC, it is directly accessed all peripheral resources progress initialization operations of device DMA;
Two, microcontroller calls each hardware initialization function pair Ethernet protocol chip stack, 485 transponder chips, 232 to receive
Send out all external hardwares of device chip and carry out initialization operation;
Three, then system enter configuration function, enter according to the parameter write in advance in FLASH flash memory storages area in microcontroller
Row initialization serial ports, agreement selection function;Thereafter, each configuration parameter can be entered at any time by host computer configuration software
Row modification, modification terminates and after success, data acquisition unit can trigger a warm reset, make microcontroller reset;After reset, micro-control
When device processed goes to configuration function, configured good new parameter in FLASH flash memories is loaded into from new, and according to the parameter to related work(
It can be initialized;
Host computer configuration software can write configuration parameter in any time that microcontroller is run, and microcontroller receives
The configuration of existing hardware resource will not directly be changed during these configuration parameters, but these parameters are write in FLASH flash memories, only
Change the configuration parameter in FLASH flash memories;After parameter read-in to be configured is errorless, it is anti-that microcontroller can according to circumstances will be prompted to information
Feed host computer, after the completion of waiting the current hot job of microcontroller, then trigger warm reset signal, avoid loss of data etc. existing
As occurring;After microcontroller reset, just the configuration parameter in these FLASH flash memories is loaded into, reaches the purpose of parameter configuration;
Communication baud rate of the configuration parameter including serial ports, even-odd check, data bits, stopping digit, agreement selection, according to
Corresponding agreement has all selections of master station mode, slave station mode, station address, data address, verification mode;Also include the work of Ethernet
Make mode, address, all parameters in port;
Four, host computer configuration software includes collector main program, I/O signal processing routine, I/O channel configurator, serial ports
Master-slave swap program, MODBUS RTU slave stations driver, MODBUS RTU main websites driver, Ethernet chip control journey
Sequence, MODBUS TCP servers end driver and agreement option program;Serial ports refers to RS-485 interfaces, RS-232 interface;
Collector main program mainly handles various communications, and IO read-write and refreshing;The program of the part is with every
20ms cycle carries out Infinite Cyclic execution;When receiving the parameter configuration order that host computer is sent, serial ports is by parameter read-in
Into FLASH flash memories and software reset's microcontroller;To avoid the data that microcontroller normal communication obtains being mistakenly considered
The modification parameter information that position machine is sent, the other special heads of difference of appointment data bag are needed between microcontroller and host computer
Portion, and pass through the modification of mutual Handshake Protocol completion final data;
Five, MODBUS RTU slave stations driver, MODBUS RTU main websites driver, Ethernet chip control program,
MODBUS TCP servers end driver and other communications protocol driver major functions are bottom hardware reading and writing datas
Realization and protocol data parsing realization;Wherein certain communication can be called according to configuration of the host computer configuration software to collector
Protocol procedure parses to the data of acquisition, obtains correct data and writes corresponding address area;Or, it would be desirable to transmit
Data according to setting communications protocol form pack, exported by corresponding communication port;RS-485 interfaces, the RS-232 of bottom
Interface and serial ports master-slave swap program, receiving portion is read out using interrupt mode, and is stored data into order caching;
Transmitting portion is write data into by the transmission function in collector main program cycle body and sent in data buffer area, then passes through phase
The register answered sends data by RS-485 interfaces, RS-232 interface and Ethernet.
And MODBUS RTU slave stations driver, MODBUS RTU main websites driver, the drive of MODBUS TCP servers end
Dynamic program and other communications protocol drivers, the different power function of each freedom are formed, and above-mentioned every kind of agreement is all corresponding
Some power functions, the data read are parsed and send data in what manner;And the selection of agreement is according to journey
Protocol keyword variable in sequence is automatically selected, and the protocol keyword variable variable can be matched somebody with somebody by upper computer software
Put, and be saved in FLASH flash memories;In use, according to different protocol keyword variables by RS-485 interfaces, RS-232 interface
Main website or slave station mode are separately configured to by host computer;
Six, IO update and signal processing, i.e., I/O signal processing routine is mainly the data collected to I/O channel
Processing is filtered, and the data after processing are write into corresponding input variable area;Meanwhile the variable in output variable area is handled
After write I/O channel register, by corresponding passage by data output.
It is using the design philosophy and beneficial effect of technical solution of the present invention:
The data acquisition unit of the present invention uses industrially conventional direct current 24V power supplies (supply district can be with 7~35V of DC),
Easily it can install on the spot in equipment enclosure at the scene, power supply and installation are quite convenient to.
Using channel multiplexing technology, set by host computer or wire jumper selects, multiple input/output functions can mapped
Onto an input and output terminal.The space of PCB can be so saved, product is tried one's best, and it is small to do, so as to save scene
Installing space;Meanwhile the data point of industry spot is more dispersed, often the quantity of a local data point is seldom, but respectively
The type of individual local data point but may be different, meets multiclass with a type of product with channel multiplexing technology can
The digital independent of type, and port number does not have to design a lot, to avoid passage excessively redundancy.
Abundant communication interface, the key of industrial Internet of Things are networkings, and data can go directly upper strata high in the clouds software from bottom.Pin
To the rich of field device interface, and field data bus is rich, the present invention be integrated with simultaneously Ethernet interface,
RS-485 interfaces and RS-232 interface.
When further applying, by the configuration of host computer, RS-485 interfaces or RS-232 interface can be configured to not
The communication port of congenerous.Wherein, RS-485 interfaces, RS-232 interface can be by the configuration softwares built in host computer independently
Ground is configured to main website or slave station mode;When being configured to slave station mode, other master devices (such as PC, PLC etc.) can be with
Operation is written and read to it by ModbusRTU agreements;, again can be logical to this by host computer when being configured to master station mode
The communications protocol of news mouth is selected, so as to which the equipment (such as various PLC etc.) different from scene is communicated.Due to agreement
Species is very abundant, it is impossible to all agreements is all integrated into collector, so under many circumstances, the parsing of agreement is also
It is to need to realize (such as configuration software, OPC, protocol-driven etc.) by host computer, and the communication interface of field apparatus is
In the case of serial ports, RS-485 interfaces, the RS-232 interface of collector can be configured to master station mode, while connect with Ethernet
Mouth can be configured to the pattern of serial server, and the data can of such equipment is so existed by real-time performance serial ports transparent transmission
The corresponding protocol-driven of upper computer selecting is written and read operation to it.
The data acquisition unit has two embedded Ethernet interfaces, can by another ethernet device of information flow direction, when
When now arranging many such collectors, each collector can be connected in the form of daisy chain, facilitate field network
Wiring, to form distributed data acquisition system.The equipment such as host computer or PLC can read net by ModbusTCP agreements
The data of network port.It is also possible to which miscellaneous equipment is connected on the network interface, the extension of network is conveniently realized.
Configured by host computer, can be with the function of redefining I/O channel and each PORT COM of memorial tablet, so that data are adopted
The adaptability of storage is more strengthened, and meets the demand of the data acquisition of various industry spots as much as possible.
Brief description of the drawings
Fig. 1 is the hardware block diagram of data acquisition unit of the present invention;
Fig. 2 is the structured flowchart of acquisition system host computer configuration software of the present invention.
Embodiment
The embodiment of the present invention is as follows:
Reference picture 1, a kind of Multi-functional data collector based on wisdom factory, including microprocessor and respectively with microprocessor
Device connected power module, 485 transponder chips, 232 transponder chips, I/O signal change-over circuit and two Ethernet protocols
Chip stack;Power module is used to provide power supply for collector;485 transponder chips, 232 transponder chips have RS-485 respectively
Interface, RS-232 interface, for connecting external equipment and collecting device data;There is Ethernet protocol chip stack Ethernet to connect
Mouthful, for connecting host computer or other collectors and transmitting data;I/O signal change-over circuit, there is I/O port, it is outer for connecting
Portion's equipment simultaneously gathers signal or equipment is controlled, and microprocessor believes 485 transponder chips, 232 transponder chips, IO
Number change-over circuit, the signal of Ethernet protocol chip stack collection or data are handled and managed;Received and dispatched in power module and 485
Power isolation module is also associated between device chip.
The STM32F103C8 based on Cortex-M3 kernels of microprocessor selection STMicw Electronics single-chip microcomputer.The monolithic
Machine uses LQFP encapsulation, has 48 pins, in the case where fully meeting application, is reduced as far as the occupancy of pcb board
Space;The RAM memory of flash storage and 20K with 64K, it is sufficient to meet in general communications protocol and data processing
Ability;With three universal asynchronous serial interfaces, the RS-485 interface and a RS-232 that can meet the present invention connect
The demand of mouth;With two SPI synchronous serial interfaces, operation can be written and read to two Ethernet protocol chip stacks.
Ethernet protocol chip stack uses the W5500 chips of WIZnet companies.The chip is that a devices at full hardware TCP/IP is embedding
Enter formula ethernet controller, eased internet connection scheme is provided for embedded system.W5500 is integrated with TCP/IP
Protocol stack, 10/100M ethernet data link layers (MAC) and physical layer (PHY).It can not have to collect in single-chip microcomputer with the program
Into ICP/IP protocol stack so that the resource of single-chip is significantly discharged, and the performance requirement of single-chip microcomputer is also greatly lowered,
Reduce software development difficulty simultaneously.
RS-485 transponder chips select SP3485 chips.The chip is a low-power consumption Half-duplex transceiver, and they are complete
The requirement of full up sufficient RS-485 and RS-422 serial protocols.SP3485 chips meet the electric of RS-485/RS-422 serial protocols
Specification, message transmission rate may be up to 10Mbps (bringing onto load).Because the application scenario of 485 buses is typically all in industry spot
Long range communication, therefore for the protection to collector, it is necessary to design antisurge and power isolation circuit.The chip and 485 connects
The circuit of oral area point is powered using insulating power supply device B0505, while interface circuit needs to be resisted using Transient Suppression Diode
Surge designs;The serial ports of single-chip microcomputer and control output are connected thereto by optocoupler.
RS-232 transponder chips select SP3232 chips.Transistor-Transistor Logic level is converted to rs-232 standard level by the chip, full
Sufficient EIA/TIA-232-F standards, operating voltage directly can be powered with 3.3V.The peripheral circuit of the chip is simple, it is only necessary to several
The 0.1uF of individual 0805 encapsulation electric capacity.
Power module uses LM2596-5 switching power source chips, carries out lowering and stabilizing blood pressure to supply voltage, is changed into DC 5V, does
For the operating voltage of the circuits such as IO.Meanwhile using linear stabilized power supply AMS1117-3.3 chips, 5V voltages are further changed
For 3.3V voltages, carried out to single-chip microcomputer, RS-485 transponder chips, RS-232 transponder chips, Ethernet protocol chip stack etc.
Power supply.In addition, RS-485 transponder chips and RS-485 interface circuits are powered with insulating power supply module B0505, logarithm
Protected according to collector.
I/O signal change-over circuit includes being used to gather and control the simulated measurement input circuit of analog signal, for controlling switch
Measure the switching value input circuit of signal and the switching value output circuit for controlling low-power equipment.
Simulated measurement input circuit can receive 4~20mA, 0~5V, 0~10V signal, it is only necessary to be carried out by short-circuited conducting sleeve
Selection.By π type filter circuits, analog quantity is filtered, removes HF noise signal.Meanwhile signal passes through operation amplifier
Enter single-chip microcomputer after the signal follower of device composition, the output impedance of signal can so be improved, reduce signal by load (this
In load refer to the input pin of single-chip microcomputer, it has equiva lent impedance) influence, improve the reading accuracy of analog quantity.
Switching value input circuit, isolated using high speed photo coupling, protect collector internal structure, while can also receive
High-frequency pulse input signal.When input be high-speed pulse signal when, its port can be arranged to by software merit rating
The pattern of high-speed pulse, it can so read the code device signal obtained from motor speed for scene.It is this to configure
Signalling channel into high-speed pulse input needs to design the timer input for being connected to single-chip microcomputer and flutters and catch pin.So, to the list
Piece power traction pin and corresponding timer are configured, you can realize the counting of high-speed pulse.
Switching value output circuit uses relay isolation and amplifier, can directly control the small-powers such as alarm lamp, magnetic valve to set
It is standby;The powerful devices such as motor are controlled by contactor simultaneously.By software merit rating, its passage can be configured to PWM
Output mode, lighting scene brightness, motor speed etc. are controlled for some specific occasions.This kind of compound mixed passage must
The output that some timer must be connected to is compared on terminal.
Collector main program is the core of the whole configuration software of host computer, mainly responsible initialization, configuration processing, mailing address
Reason and I O process work;
When electric on collector, the initializing resource processing routine of single-chip microcomputer is initially entered to clock, interruption service, timing
Device, serial ports, I/O resource carry out initialization process;After it is stable, Ethernet protocol chip stack, 485 transceivers to collector
The all hardware of chip, 232 transponder chips, LED light carries out initialization process;Then program is waited for, and use is upper
Machine configuration software carries out initialization operation to communications parameter, I/O channel pattern, and after ACK button is pressed, program judges that parameter is set
Work(is set to, then configuration terminates, and lights corresponding LED and represent to set successfully;
Afterwards, into the cyclic part of program, this is the main part of program, is constantly entered according to the cycle time of setting
Row Communication processing, IO renewals and I/O signal processing, fault treating procedure.
Specifically, reference picture 2 is explained as follows:
One, first, initialization function is called on microcontroller after electricity, to clock, interruption and GPIO, serial ports, timer,
Analog-digital converter ADC, it is directly accessed all peripheral resources progress initialization operations of device DMA;
Two, microcontroller calls each hardware initialization function pair Ethernet protocol chip stack, 485 transponder chips, 232 to receive
Send out all external hardwares of device chip and carry out initialization operation;
Three, then system enter configuration function, enter according to the parameter write in advance in FLASH flash memory storages area in microcontroller
Row initialization serial ports, agreement selection function;Thereafter, each configuration parameter can be entered at any time by host computer configuration software
Row modification, modification terminates and after success, data acquisition unit can trigger a warm reset, make microcontroller reset;After reset, micro-control
When device processed goes to configuration function, configured good new parameter in FLASH flash memories is loaded into from new, and according to the parameter to related work(
It can be initialized;
Host computer configuration software can write configuration parameter in any time that microcontroller is run, and microcontroller receives
The configuration of existing hardware resource will not directly be changed during these configuration parameters, but these parameters are write in FLASH flash memories, only
Change the configuration parameter in FLASH flash memories;After parameter read-in to be configured is errorless, it is anti-that microcontroller can according to circumstances will be prompted to information
Feed host computer, after the completion of waiting the current hot job of microcontroller, then trigger warm reset signal, avoid loss of data etc. existing
As occurring;After microcontroller reset, just the configuration parameter in these FLASH flash memories is loaded into, reaches the purpose of parameter configuration;
Communication baud rate of the configuration parameter including serial ports, even-odd check, data bits, stopping digit, agreement selection, according to
Corresponding agreement has all selections of master station mode, slave station mode, station address, data address, verification mode;Also include the work of Ethernet
Make mode, address, all parameters in port;
Four, host computer configuration software includes collector main program, I/O signal processing routine, I/O channel configurator, serial ports
Master-slave swap program, MODBUS RTU slave stations driver, MODBUS RTU main websites driver, Ethernet chip control journey
Sequence, MODBUS TCP servers end driver and agreement option program;Serial ports refers to RS-485 interfaces, RS-232 interface;
Collector main program mainly handles various communications, and IO read-write and refreshing;The program of the part is with every
20ms cycle carries out Infinite Cyclic execution;When receiving the parameter configuration order that host computer is sent, serial ports is by parameter read-in
Into FLASH flash memories and software reset's microcontroller;To avoid the data that microcontroller normal communication obtains being mistakenly considered
The modification parameter information that position machine is sent, the other special heads of difference of appointment data bag are needed between microcontroller and host computer
Portion, and pass through the modification of mutual Handshake Protocol completion final data;
Five, MODBUS RTU slave stations driver, MODBUS RTU main websites driver, Ethernet chip control program,
MODBUS TCP servers end driver and other communications protocol driver major functions are bottom hardware reading and writing datas
Realization and protocol data parsing realization;Wherein certain communication can be called according to configuration of the host computer configuration software to collector
Protocol procedure parses to the data of acquisition, obtains correct data and writes corresponding address area;Or, it would be desirable to transmit
Data according to setting communications protocol form pack, exported by corresponding communication port;RS-485 interfaces, the RS-232 of bottom
Interface and serial ports master-slave swap program, receiving portion is read out using interrupt mode, and is stored data into order caching;
Transmitting portion is write data into by the transmission function in collector main program cycle body and sent in data buffer area, then passes through phase
The register answered sends data by RS-485 interfaces, RS-232 interface and Ethernet.
And MODBUS RTU slave stations driver, MODBUS RTU main websites driver, the drive of MODBUS TCP servers end
Dynamic program and other communications protocol drivers, the different power function of each freedom are formed, and above-mentioned every kind of agreement is all corresponding
Some power functions, the data read are parsed and send data in what manner;And the selection of agreement is according to journey
Protocol keyword variable in sequence is automatically selected, and the protocol keyword variable variable can be matched somebody with somebody by upper computer software
Put, and be saved in FLASH flash memories;In use, according to different protocol keyword variables by RS-485 interfaces, RS-232 interface
Main website or slave station mode are separately configured to by host computer;
Six, IO update and signal processing, i.e., I/O signal processing routine is mainly the data collected to I/O channel
Processing is filtered, and the data after processing are write into corresponding input variable area;Meanwhile the variable in output variable area is handled
After write I/O channel register, by corresponding passage by data output.
The preferred embodiment of the present invention is only intended to help and illustrates the present invention.It is all that preferred embodiment does not have detailed descriptionthe
Details, it is only described embodiment also not limit the invention.Obviously, according to the content of this specification, can make a lot
Modifications and variations.This specification is chosen and specifically describes these embodiments, is to preferably explain the principle and reality of the present invention
Border is applied, so that skilled artisan can utilize the present invention well.The present invention only by claims and its
The limitation of four corner and equivalent.Disclosed above is only several specific embodiments of the application, but the application not limits to
In this, the changes that any person skilled in the art can think of, should all fall in the protection domain of the application.