Summary of the invention
The object of the present invention is to provide a kind of integrated control method of solenoid valve block, the integrated control method passes through electricity
Magnet valve group multithreading independent control function realizes the high mutual logic control of reliable solenoid valve block in real time, existing to solve
Electromagnetic valve control method be unable to satisfy the demand to solenoid valve comprehensively control.
To achieve the above object, the scheme of the invention is: a kind of integrated control method of solenoid valve block, the controlling party
Method is connected to control panel by the address card at the end PC, then by control panel draw the solenoid valve harness on separate control lines to valve body into
Row comprehensively control, the control method are as follows:
(1) it initializes, and in target current, current changing rate and the time rate of change of the end PC setting solenoid valve block;
(2) in the cycle period of setting, if PC termination receives the solenoid valve control order of user's transmission, to needing to control
The solenoid valve of system sends control electric current and calculates solenoid valve current flow and target if only receiving a solenoid valve control order
The difference of electric current, and enter step (3);If receiving multiple solenoid valve control orders, (5) are entered step;
(3) if the difference of solenoid valve current flow and target current is less than or equal to current changing rate, directly by target electricity
Stream is sent as control electric current, that is, completes the control to the solenoid valve;
(4) if the difference of solenoid valve current flow and target current is greater than current changing rate, according to cycle period, with when
Between change rate be that interval successively sends control electric current, the control electric current sent every time is all that the control electric current of last transmission adds
The value of current changing rate, until the control electric current of transmission is equal to target current, control of the completion to solenoid valve;
(5) multithreading independent process is carried out to multiple solenoid valve control orders, each control command is according to step (3)
~(4) processing, until all control commands handle completion.
In the step (3), for the difference and current changing rate between solenoid valve current flow and target current
Size compare, the present embodiment is realized in the following way, i.e., at the end PC, calculates solenoid valve current flow and target current
Between difference, and the difference is divided by with current changing rate, obtains electric current quotient and electric current remainder, judge that electric current quotient is greater than
1 or less than 1.
In the step (4), if electric current remainder is 0, the difference of current flow to target current is exactly that electric current becomes
The integral multiple of rate illustrates to be sequentially overlapped according to current changing rate, and the electric current that last time is sent is exactly equal to target current, sends out
The current control order number sent is electric current quotient;
If electric current remainder is not 0, illustrate to be sequentially overlapped according to current changing rate, the control electric current that last time is sent also reaches
Fall short electric current, in order to reach target current, control electric current needs are multiple primary, and what is directly transmitted for the last time is target electricity
Stream, therefore the current control order number sent is that electric current quotient adds 1.
The transmission of control electric current is also influenced by time rate of change, in step (3) and step (4), if time rate of change
Greater than the cycle period of setting, then one cycle period of every waiting, waiting time t are the time for accumulating a cycle period, when
When accumulated time+cycle period > time rate of change, in next cycle period, pass through cycle period-(accumulated time+circulation
Cycle-time change rate), determine the specific time point for sending control electric current.
In step (4), if time rate of change is less than cycle period, and in cycle period, the control that last time is sent
Electric current processed is not equal to target current value, then accumulates remaining control electric current transmission times to next cycle period, update electricity
Quotient is flowed, until the current control order sent is target current.
In step (5), when controlling multiple solenoid valves, the greatest common divisor of multiple solenoid valve time rate of changes is taken to make
Current control is carried out for the time rate of change of solenoid valve block, the order processed of each solenoid valve is carried out according to step (3)~(4)
Multithreading independent process.
Control method of the invention is when there is any control command to be carrying out, if increasing a control command newly, this is new
The control command of increasing can start in next cycle period or in addition when waiting cyclic process.
Control method of the invention is when the control command being carrying out receives order stopping or pause signal, electric current control
System will stop in the interval that jumps of cycle period.
Control method of the invention has condition monitoring and auto-reset function, before control algolithm execution, will do it
Initialization empties the failure accumulated time of all control panels in initialization, after some control panel breaks down, by setting
The waiting of reset duration reattempt to resets after a certain period of time, whether succeed regardless of resetting later, which is recorded to former
Hinder in cumulative time length, if repeating time duration caused by resetting is more than setting time, is no longer resetted, and inform
This control panel of user needs to handle there are problem.
Existing control method causes to occur surprisingly when hardware system there is no real-time status monitoring and auto restore facility
When, user can not have found to have already appeared failure and can not confirm failure cause.The present invention passes through condition monitoring and the band that automatically resets
The benefit come greatly is shortened because malfunction elimination time and system recovery time caused by hardware problem, allow user Geng Gao
The application solenoid valve block control system of effect is tested to carry out valve body or speed changer.
It is that the present invention reaches the utility model has the advantages that the present invention establishes on low cost, the high hardware platform of operability, by setting
Independent solenoid valve block complex control system is counted, on the one hand passing through realtime monitoring and automatically reseting realizes software function
It is friendly easy-to-use, it is mutual that high solenoid valve block reliable in real time is on the other hand realized by solenoid valve block multithreading independent control function
Logic control.The electromagnetic valve controlling system missing for not only having filled up integrated system on current corresponding hardware platform, even more to biography
The valve body of the provided with electromagnetic valve group of system is tested and the automatic cost for changing device test reduces and testing efficiency is promoted.
Specific embodiment
The present invention is described in further detail with specific embodiment with reference to the accompanying drawing.
As shown in Figure 1, the present invention is connected to control panel by the address card at the end PC, then draws separate control lines by control panel
Solenoid valve harness on to valve body carry out comprehensively control.
As Fig. 2 is described as follows control method of the present invention by taking the cycle period of 100ms as an example:
1, in the case where not receiving any control command, the end PC carries out repeating to wait following with the cycle period of 100ms
Ring, it is very low to occupy resource for computer internal operation at this time.
2, when the end PC received in 100ms user transmission control command when, exit at once 100ms etc. it is to be recycled,
The solenoid valve of control is required to send control electric current to user.
User can select the solenoid valve for wanting control on the human-computer interaction interface at the end PC in solenoid valve list.
3, if the end PC only receives a control command, i.e., only a solenoid valve needs to control, then first calculates solenoid valve
Difference between current flow and target current, then be divided by with current changing rate, obtain quotient and the remainder (hereinafter referred to as electric current quotient, electricity
Flow remainder), and enter step 4;If the end PC receives multiple control commands simultaneously, that is, the more a solenoid valve is needed to be controlled,
Then enter step 6.
4, in the case that electric current quotient is less than or equal to 1: if (1) time rate of change is less than 100ms, the end PC sends target electricity
Stream is control electric current, and is only sent once, that is, completes the control to solenoid valve.
(2) if time rate of change is greater than 100ms, every waiting 100ms, waiting time t accumulate 100ms, as (t+
100ms) > time rate of change when, in next 100ms, pass through 100ms- (t+100ms- time rate of change), confirmation send control
The specific time point (being accurate to 1ms) of electric current processed.
5, in the case that electric current quotient is greater than 1: if (1) time rate of change is less than 100ms, calculating 100ms and time change
The quotient and remainder (hereinafter referred to as time quotient, time remainder) of rate.Compare time quotient and electric current quotient, when time quotient is less than electric current quotient,
Temporally change rate accumulated time carries out current control order variation in 100ms, until time commercialization is complete, electric current quotient is subtracted
The difference accumulation of time quotient is to the next 100ms period and is updated to new electric current quotient, then with new electric current quotient compared with time quotient,
Until time quotient is greater than electric current quotient;When time quotient is greater than electric current quotient, current control is carried out according to electric current quotient's number in 100ms
Order variation, until after the completion of last time controls, directly jump out control algolithm be recycled into etc. it is to be recycled.
(2) if time rate of change is greater than 100ms, every waiting 100ms accumulates a time, when accumulated time+100ms is big
When time rate of change, carried out again with 100ms in the 100ms by the difference that accumulated time+100ms subtracts time rate of change
Subtract each other confirmation send current order specific time point (being accurate to 1ms), be sent completely rear new time remainder be accumulated time+
100ms subtracts the difference of time rate of change and charges to next 100ms circulation, and corresponding electric current quotient subtracts 1, until last electric current quotient becomes
0, circulation is jumped out immediately.
In these cases:
If electric current remainder is that the control current times that the end 0, PC is sent are electric current quotient, the control electric current sent every time is upper
The control electric current once sent adds current changing rate;
If electric current remainder is not 0, the control current times sent are that electric current quotient adds 1, and last time sends control electricity
All control electric currents before stream are the control that the last control electric current sent is sent plus current changing rate, last time
Electric current is target current value.
It is 30ms, current changing rate 20mA, target with time rate of change for example, to control a solenoid valve
Electric current is 80mA, and current flow is illustrated for being 0mA: it is 4 that electric current quotient, which is calculated, and electric current remainder is 0, and time quotient is 3,
Time remainder is 10, then needing to send 4 secondary control electric currents.
Every 30ms sends the control electric current of 20mA, then 3 secondary control electric currents are sent in first 100ms cycle period, into
The variation of 3 primary current of row, the 60mA of the 40mA and 90ms of the respectively 20mA of 30ms, 60ms, time remainder are 10ms, this 10ms
It is placed into 100ms circulation next time, only carries out primary current variation in 100ms next time at this time, i.e., next 100ms's
The control electric current of 80mA is sent when 20ms.
6, when processing is directed to a plurality of order of multiple solenoid valves simultaneously, using 100ms as cycle period, by step (3)-
(5), multithreading independent process is carried out to multiple solenoid valves.
If the corresponding time rate of change of multiple solenoid valve control orders is all different, and when small 100ms, then at one
In 100ms cycle period, according to the size of time rate of change, each control command is sequentially executed, if a cycle period terminates
Afterwards, all control commands, which are performed both by, finishes, then completes the control to multiple solenoid valves;Otherwise, it is recycled into next 100ms
Loop cycle processing, until all control commands have been handled.
For handling 4 solenoid valve control orders, the processing sequence of multiple solenoid valves of the invention is illustrated: life
Enabling 1 corresponding time rate of change is 30ms, and 2 corresponding time rate of changes of order are 40ms, and 3 corresponding time rate of changes of order are
50ms, 4 corresponding time rate of changes of order are 70ms.In first 100ms cycle period, in 30ms, processing order 1,
4,80ms of processing order processing order when processing order 1,70ms when processing order 3,60ms when processing order 2,50ms when 40ms
Processing order 3 when processing order 1,100ms when 2,90ms.
Since the time remainder of order 1 is 10ms, ordering 2 time remainder is 20ms, and ordering 3 time remainder is 0, life
The time remainder for enabling 4 is 30, then, in the case where the control electric current of each control command equal miss the mark electric current, under
In the cycle period of one 100ms, according to the sequence of time remainder from small to large, each control command, Zhi Daosuo are successively handled
Some control commands handle completion.
It,, should if increasing a control command newly when there is any control command to be carrying out in control method of the invention
Newly-increased control command can be recycled in next 100ms to be started or is added in waiting cyclic process.
On the human-computer interaction interface at the end PC, user can choose any solenoid valve by mouse in solenoid valve list,
Click pause or stop function button, when PC termination receive stopping or pause command when, the end PC by recognition command signal, and
The interval that jumps of 100ms cycle period stops current control.The either condition of setting pause or stopping control command, full
When foot imposes a condition, automatic trigger pause or stopping control command.
Control method of the invention have it is several under several functions:
(1) condition monitoring and auto-reset function
The function is whole during initialization and normal use to be enabled.
It is initialized as full-automatic process, corresponding flow model are as follows: enter software, software initialization → initialization NI USB-
The solenoid valve that 8452 address cards and chip controls plate → judgement have connected, and initialize solenoid valve → normal work.
In initialization, for be not connected with any solenoid valve control panel and can not the control panel of normal initialization can be automatic
Repeat refresh (had when multiple control panels initialize jointly certain planks once can not normal initialization probability, it is soft at this time
Part can be searched automatically and attempt to be reset to normal function again), control panel quality problems itself can not be normally initial in order to prevent
Change and infinitely refreshing causes system resource persistently to occupy, the present invention stop using intelligent algorithm infinitely repeat refreshing, algorithm are as follows:
When software initialization, the failure accumulated time of all control panels is emptied, after some control panel breaks down, by setting
Fixed reset duration waiting reattempts to resets after a certain period of time, later regardless of whether reset succeeds, the duration be recorded to
In failure cumulative time length, if repeating time duration caused by resetting is more than 2 minutes, system is no longer resetted, and
Inform that this control panel of user needs to handle there are problem.The problematic control panel that can not be resetted will not influence just in reseting procedure
The use of normal control panel.
Conventional software causes there is no real-time status monitoring and auto restore facility when hardware system occurs unexpected,
User can not have found to have already appeared failure and can not confirm failure cause.Condition monitoring and automatically reseting has the advantage that, pole
Big shortening because of malfunction elimination time and system recovery time caused by hardware problem, allow user it is more efficient apply solenoid valve
Set control system is tested to carry out valve body or speed changer.
(2) all solenoid valve controls are separate threads and efficient combination
This software has carried out algorithm distribution for the SPI Communication Control of solenoid valve, is the SPI life based on current control respectively
The high real-time communication mode that uses, and the SPI order based on non-current control is enabled to use event triggered fashion.High real-time communication mode
It is divided to two thread process with event triggered fashion, can guarantees timely respond to when any solenoid valve has demand for control in this way,
Control and each solenoid valve synchronously control are timely responded to after meeting the triggering of solenoid valve condition.
The present invention establishes on the high hardware platform of low cost, operability, comprehensive by designing independent solenoid valve block
Control system, on the one hand passing through realtime monitoring and automatically reseting realizes the friendly easy-to-use of software function, on the other hand logical
Crossing solenoid valve block multithreading independent control function realizes the high mutual logic control of reliable solenoid valve block in real time.Not only fill up
The electromagnetic valve controlling system missing of integrated system, the even more valve body to traditional provided with electromagnetic valve group on current corresponding hardware platform
Test and the automatic cost reduction for changing device test and testing efficiency are promoted.