Disclosure of Invention
The invention aims to provide a comprehensive control method of an electromagnetic valve bank, which realizes high real-time and reliable mutual logic control of the electromagnetic valve bank through a multithread independent control function of the electromagnetic valve bank and is used for solving the problem that the conventional electromagnetic valve control method cannot meet the requirement on comprehensive control of the electromagnetic valve.
In order to achieve the purpose, the scheme of the invention is as follows: a control method of an electromagnetic valve group is characterized in that the control method is connected to a control panel through a communication card at a PC end, and then an independent control line is led out from the control panel to an electromagnetic valve wire harness on a valve body for comprehensive control, and the control method comprises the following steps:
(1) initializing, and setting target current, current change rate and time change rate of the electromagnetic valve group at a PC end;
(2) in a set cycle, if a PC end receives an electromagnetic valve control command sent by a user, sending a control current to an electromagnetic valve to be controlled, if only one electromagnetic valve control command is received, calculating a difference value between the current and the target current of the electromagnetic valve, and entering the step (3); if a plurality of electromagnetic valve control commands are received, entering the step (5);
(3) if the difference value between the current and the target current of the electromagnetic valve is less than or equal to the current change rate, directly sending the target current as a control current, namely completing the control of the electromagnetic valve;
(4) if the difference value between the current and the target current of the electromagnetic valve is larger than the current change rate, sequentially sending control current by taking the time change rate as an interval according to a cycle period, wherein the control current sent each time is the sum of the control current sent last time and the current change rate until the sent control current is equal to the target current, and controlling the electromagnetic valve;
(5) and (4) carrying out multithreading independent processing on the plurality of solenoid valve control commands, wherein each control command is processed according to the steps (3) to (4) until all the control commands are processed.
In the step (3), for comparing the difference between the current and the target current of the solenoid valve with the current change rate, the embodiment is implemented by calculating the difference between the current and the target current of the solenoid valve at the PC terminal, dividing the difference by the current change rate to obtain a current quotient and a current remainder, and determining that the current quotient is greater than 1 or less than 1.
In the step (4), if the remainder of the current is 0, the difference value between the current and the target current is exactly an integral multiple of the current change rate, which means that the current change rate is sequentially superposed, the current sent at the last time is exactly equal to the target current, and the number of times of the sent current control command is a current quotient value;
if the remainder of the current is not 0, the current is sequentially overlapped according to the current change rate, the control current sent for the last time does not reach the target current, the control current needs to be sent more times in order to reach the target current, the target current is directly sent for the last time, and therefore the number of times of sending the current control command is that the current quotient value is added with 1.
The sending of the control current is also affected by the time change rate, in step (3) and step (4), if the time change rate is larger than the set cycle period, every time one cycle period is waited, the waiting time t is the time of accumulating one cycle period, and when the accumulated time + the cycle period > the time change rate, in the next cycle period, the specific time point of sending the control current is determined through the cycle period- (the accumulated time + the cycle period-the time change rate).
In the step (4), if the time change rate is smaller than the cycle period and the last sent control current is not equal to the target current value in the cycle period, accumulating the number of times of sending the remaining control current to the next cycle period, and updating the current quotient value until the sent current control command is the target current.
In the step (5), when the plurality of solenoid valves are controlled, the greatest common divisor of the time change rates of the plurality of solenoid valves is taken as the time change rate of the solenoid valve group for current control, and multithreading independent processing is carried out on the control command of each solenoid valve according to the steps (3) to (4).
When any control command is being executed, if a control command is added, the added control command is added at the beginning of the next cycle period or in the process of waiting for the cycle.
The control method of the present invention will stop the current control during the jump interval of the loop cycle when the control command being executed receives a command stop or pause signal.
The control method of the invention has the functions of state monitoring and automatic reset, the control algorithm is initialized before being executed, the fault accumulation time of all the control panels is cleared during the initialization, when a certain control panel has a fault, the control panel waits for a certain time according to the set reset time length and tries to reset again, then the time length is recorded into the fault accumulation time length no matter whether the reset is successful, if the accumulated time length caused by repeated reset exceeds the set time, the control method does not reset any more, and informs a user that the control panel has problems and needs to be processed.
The existing control method has no real-time state monitoring and automatic recovery functions, so that when an accident occurs to a hardware system, a user cannot find that the fault occurs and cannot confirm the fault reason. The invention has the advantages of greatly shortening troubleshooting time and system recovery time caused by hardware problems by state monitoring and automatic resetting, and enabling a user to more efficiently apply the solenoid valve bank control system to test the valve body or the transmission.
The invention achieves the following beneficial effects: the invention is established on a hardware platform with low cost and high operability, and by designing an independent solenoid valve group integrated control system, on one hand, the invention realizes the friendly and easy use of software functions through the real-time state monitoring and automatic resetting, and on the other hand, the invention realizes the high real-time and reliable mutual logic control of the solenoid valve groups through the multithread independent control function of the solenoid valve groups. The electromagnetic valve control system loss of the comprehensive system on the current corresponding hardware platform is filled, and the cost of the traditional valve body test with the electromagnetic valve bank and the automatic change device test is reduced and the test efficiency is improved.
Detailed Description
The invention is described in further detail below with reference to the figures and specific examples.
As shown in figure 1, the invention is connected to a control panel through a communication card at a PC end, and then an independent control line is led out from the control panel to an electromagnetic valve wire harness on a valve body for comprehensive control.
Referring to fig. 2, the control method of the present invention is described below with a cycle period of 100ms as an example:
1, when not receiving any control command, the PC terminal performs repeated waiting circulation with a circulation period of 100ms, and the internal operation of the computer occupies low resources.
2, when the PC end receives a control command sent by a user within 100ms, immediately quitting the waiting cycle of 100ms and sending a control current to the solenoid valve required to be controlled by the user.
The user can select the solenoid valve to be controlled from the solenoid valve list on the human-computer interaction interface at the PC end.
If the PC end only receives a control command, namely only one electromagnetic valve needs to be controlled, firstly calculating the difference value between the current and the target current of the electromagnetic valve, then dividing the difference value by the current change rate to obtain a quotient and a remainder (hereinafter referred to as a current quotient and a current remainder), and entering the step 4; if the PC receives a plurality of control commands at the same time, that is, a plurality of solenoid valves are required for control, the process goes to step 6.
4, when the current quotient is less than or equal to 1: (1) and if the time change rate is less than 100ms, the PC end sends the target current as the control current and sends the control current once, and the control of the electromagnetic valve is finished.
(2) If the time change rate is greater than 100ms, the waiting time t is accumulated for 100ms every time the time change rate is greater than 100ms, and when the time change rate is greater than (t +100ms) > the next 100ms, the specific time point (accurate to 1ms) for sending the control current is confirmed through 100ms- (t +100 ms-time change rate).
5, when the current quotient is greater than 1: (1) if the time change rate is less than 100ms, the quotient and remainder (hereinafter referred to as time quotient and time remainder) of 100ms and the time change rate are calculated. Comparing the time quotient with the current quotient, when the time quotient is smaller than the current quotient, changing a current control command according to time change rate accumulation time within 100ms until the time quotient is used up, accumulating the difference value of the current quotient minus the time quotient to the next 100ms period and updating to a new current quotient, and comparing the new current quotient with the time quotient until the time quotient is larger than the current quotient; and when the time quotient is greater than the current quotient, changing the current control command within 100ms according to the current quotient times, and directly jumping out of the control algorithm to enter a waiting loop after the last control is finished.
(2) If the time change rate is greater than 100ms, accumulating time once every 100ms, when the accumulated time +100ms is greater than the time change rate, subtracting the difference value of subtracting the time change rate from the accumulated time +100ms within the 100ms and then subtracting 100ms to confirm a specific time point (accurate to 1ms) for sending the current command, recording a new time remainder after sending is the difference value of subtracting the time change rate from the accumulated time +100ms into the next 100ms cycle, subtracting 1 from the corresponding current quotient until the current quotient is changed to 0 finally, and immediately jumping out of the cycle.
In the above case:
if the current remainder is 0, the number of times of the control current sent by the PC end is a current quotient value, and the control current sent each time is the sum of the control current sent last time and the current change rate;
if the current remainder is not 0, the number of times of sending the control current is that the current quotient value is added with 1, all the control currents before the control current is sent for the last time are the control current sent for the last time and the current change rate, and the control current sent for the last time is the target current value.
For example, to control a solenoid valve, a time change rate is 30ms, a current change rate is 20mA, a target current is 80mA, and a current is 0mA is taken as an example for explanation: the calculation results in a current quotient of 4, a current remainder of 0, a time quotient of 3 and a time remainder of 10, and then 4 times of control current transmission are required.
Sending a control current of 20mA every 30ms, then sending the control current 3 times in the first 100ms cycle period, and making current changes 3 times, wherein the current changes are respectively 20mA for 30ms, 40mA for 60ms and 60mA for 90ms, the time remainder is 10ms, the 10ms is placed in the next 100ms cycle, and at the moment, only one current change is made in the next 100ms, namely, sending a control current of 80mA in the next 20ms of 100 ms.
And 6, when a plurality of commands aiming at the plurality of solenoid valves are processed simultaneously, performing multithread independent processing on the plurality of solenoid valves according to the steps (3) to (5) by taking 100ms as a cycle period.
If the time change rates corresponding to the control commands of the plurality of electromagnetic valves are different and are all smaller than 100ms, sequentially executing the control commands according to the time change rates in a 100ms cycle period, and if all the control commands are completely executed after one cycle period is finished, finishing the control of the plurality of electromagnetic valves; otherwise, the next cycle processing of 100ms is carried out until all the control commands are processed.
The processing sequence of the plurality of solenoid valves of the present invention will be described by taking the processing of 4 solenoid valve control commands as an example: the time change rate for command 1 is 30ms, the time change rate for command 2 is 40ms, the time change rate for command 3 is 50ms, and the time change rate for command 4 is 70 ms. In the first 100ms loop cycle, command 1 is processed at 30ms, command 2 is processed at 40ms, command 3 is processed at 50ms, command 1 is processed at 60ms, command 4 is processed at 70ms, command 2 is processed at 80ms, command 1 is processed at 90ms, and command 3 is processed at 100 ms.
Since the time remainder of command 1 is 10ms, the time remainder of command 2 is 20ms, the time remainder of command 3 is 0, and the time remainder of command 4 is 30, under the condition that the control current of each control command does not reach the target current, each control command is sequentially processed according to the sequence of the time remainders from small to large in the next cycle period of 100ms until all the control commands are processed completely.
In the control method of the invention, when any control command is being executed, if a control command is added, the added control command will start in the next 100ms cycle or be in the process of waiting for the cycle to join.
On a human-computer interaction interface of the PC end, a user can select any solenoid valve in a solenoid valve list through a mouse, click a pause or stop function button, and when the PC end receives a stop or pause command, the PC end recognizes a command signal and stops current control in a jump interval period of a 100ms cycle period. Or setting the condition of the pause or stop control command, and automatically triggering the pause or stop control command when the set condition is met.
The control method of the invention has several functions:
(1) state monitoring and automatic reset function
This function is enabled throughout the initialization and normal application processes.
The initialization is a full-automatic process, and the corresponding flow mode is as follows: entering software, initializing software → initializing NI USB-8452 communication card and chip control board → judging connected electromagnetic valve and initializing electromagnetic valve → normal work.
During initialization, the control boards which are not connected with any electromagnetic valve and the control boards which cannot be initialized normally can be automatically and repeatedly refreshed (when a plurality of control boards are initialized together, the probability that some boards cannot be initialized normally once exists, at the moment, software can automatically search and try to reset to a normal function again), in order to prevent the control boards from being continuously occupied by system resources due to the fact that the control boards cannot be initialized normally and are refreshed infinitely, the method adopts an intelligent algorithm to stop the infinite repeated refreshing, and the algorithm is as follows:
when software is initialized, clearing fault accumulation time of all control boards, when a certain control board has a fault, waiting for a certain time according to set reset time length, re-trying to reset, and then recording the time length into the fault accumulation time length no matter whether the reset is successful, wherein if the accumulated time length caused by repeated reset exceeds 2 minutes, the system does not reset any more, and informs a user that the control board has problems and needs to be processed. The control panel that has the problem and can not reset can not influence the use of normal control panel in the reset process.
Conventional software does not have the functions of real-time state monitoring and automatic recovery, so that when an accident occurs to a hardware system, a user cannot find that a fault occurs and cannot confirm the fault reason. The state monitoring and automatic resetting have the advantages that troubleshooting time and system recovery time caused by hardware problems are greatly shortened, and a user can more efficiently use the solenoid valve bank control system to test the valve body or the transmission.
(2) All the electromagnetic valves are controlled by independent threads and efficiently combined
The software carries out algorithm distribution on SPI communication control of the electromagnetic valve, and adopts a high real-time communication mode based on the SPI command of current control and an event triggering mode based on the SPI command of non-current control respectively. The high real-time communication mode and the event triggering mode are processed by two threads, so that timely response can be ensured when any solenoid valve has control requirements, and timely response control and synchronous control of each solenoid valve are met after the condition triggering of the solenoid valve is met.
The invention is established on a hardware platform with low cost and high operability, and by designing an independent solenoid valve group integrated control system, on one hand, the invention realizes the friendly and easy use of software functions through the real-time state monitoring and automatic resetting, and on the other hand, the invention realizes the high real-time and reliable mutual logic control of the solenoid valve groups through the multithread independent control function of the solenoid valve groups. The electromagnetic valve control system loss of the comprehensive system on the current corresponding hardware platform is filled, and the cost of the traditional valve body test with the electromagnetic valve bank and the automatic change device test is reduced and the test efficiency is improved.