Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein is only in order to explain the present invention, is not intended to limit the present invention.
Fig. 1 is the system architecture schematic diagram of industrial equipment in an embodiment.As it is shown in figure 1, this system architecture includes mainboard 110 and microcontroller 120.Mainboard 110 is provided with CPU (CentralProcessingUnit, central processing unit), PCH (PlatformControllerHub, platform controller, i.e. south bridge), SIO (SuperInputOutput, interface chip) and temperature sensor.SIO and microcontroller 120 are connected by I2C (InterIntegratedCircuit, integrated circuit) bus.PCH is connected with microcontroller 120 by SMBUS1 (SystemManagementBus, System Management Bus), and microcontroller 120 is connected to the RESET pin of PCH, ReloadDefault pin, PLT_RST pin.The analog output signal pin AIN1/AIN2/AIN3 of mainboard 110 is connected with microcontroller 120.
The more expansible communication interfaces of SIO and other functional modules, for instance house dog etc..Temperature sensor is used for sense temperature, and temperature signal can be converted to voltage signal output.PLT_RST (Platformreset, platform reset signal), after system normally powers on, this platform reset signal is high level, is otherwise low level.ReloadDefault represents as BIOS (BasicInputOutputSystem, basic input output system) this signal detected after can automatically to fall clearly CMOS (ComplementaryMetalOxideSemiconductor, complementary metal oxide semiconductors (CMOS)) be default value.Reset is the reset signal on PCH, i.e. the reset signal of mainboard.PowerButton is the starting-up signal on PCH, i.e. the starting-up signal of mainboard.I2C bus is the twin wire universal serial bus developed by PHILIPS company, is used for connecting microcontroller and ancillary equipment thereof, and it is a kind of specific form of synchronous communication, has interface line few, and control mode is simple, and device packing forms is little, and traffic rate is advantages of higher relatively.AIN1/AIN2/AIN3 is analog output signal pin, for receiving the analogue signal foot needing to gather, for instance temperature, voltage etc..PWM1 and PWM2 is pulse width modulation, and microcontroller regulates the rotating speed of intelligent fan by programming the duty cycle rates changing output, reaches to control the purpose of system temperature.LED1 and LED2 is status indicator lamp.The signal of FP_RST can be given to PCH, and when for low level, PCH can export systematic reset signal automatically, and wherein, the signal produced when FP_RST is low level is hand-reset signal.
Microcontroller 120 can be arranged as required to different power down voltage thresholds, for instance 4.5V (volt), 3.7V (volt) and 3.0V (volt) etc..When voltage is lower than power down voltage threshold, then can automatically generate an interruption, current interrupt task will be performed.If this time electric voltage exception event result in mainboard power down and do not have normal boot-strap, then microcontroller 120 will adopt three kinds of modes to force mainboard to be started shooting, as exported a low level pulse to the Reset signal of PCH, or give a PowerButton signal low level pulse of output, or give clear cmos signal one low level pulse of output.
Fig. 2 is the flow chart of industrial device controls processing method in an embodiment.As in figure 2 it is shown, this industrial device controls processing method, comprise the following steps:
Step 202, detects that the mainboard of external interrupt signal and industrial equipment is in under-voltage state, it is judged that whether platform reset signal is low level, if so, then performs step 204, if it is not, perform step 218.
Step 204, time delay the first Preset Time, then perform step 206.
Concrete, the first Preset Time can set as required, such as 2 seconds or 5 seconds etc..Timing is carried out by opening timing device.
Step 206, judges whether platform reset signal is low level again, if so, then performs step 208, if it is not, perform step 210.
Step 208, the starting-up signal of output mainboard is low level, and to arrange this starting-up signal after time delay the second Preset Time be high level, then performs step 212.
Concrete, the second Preset Time can set as required, such as 400 milliseconds, 500 milliseconds, 1 second etc..Timing is carried out by opening timing device.
Step 210, the reset signal of output mainboard is low level, and to arrange this reset signal after time delay the 3rd Preset Time be high level, then performs step 212.
Concrete, the 3rd Preset Time can set as required, such as 400 milliseconds, 500 milliseconds, 1 second etc..Timing is carried out by opening timing device.
Step 212, time delay the 4th Preset Time, then perform step 214.
Concrete, the 4th Preset Time can set as required, such as 2 seconds or 5 seconds etc..Timing is carried out by opening timing device.
Step 214, then judge whether platform reset signal is low level, if so, then perform step 216, if it is not, perform step 218.
Step 216, exporting clear cmos signal is low level, and time delay the 5th Preset Time, and arranging cmos signal is high level, then performs step 218.
Concrete, the 5th Preset Time can set as required, such as 400 milliseconds, 500 milliseconds, 1 second etc..Timing is carried out by opening timing device.
Step 218, the mode of operation of switching mainboard is init state, is initialized by mainboard, then the mode of operation switching mainboard is normal condition.
Concrete, the mode of operation of mainboard is divided into three states, namely BOD state (under-voltage state), ReInit state, normal condition.Wherein, BOD state is to be entered by interrupt service routine after power down, and the current mode of operation of switching mainboard is under-voltage state;ReInit state refers to the state recovering abnormal front environmental variable, i.e. init state;Normal condition refers to properly functioning duty.Fig. 3 is the transition diagram of three kinds of states.As it is shown on figure 3, after mainboard normally starts, acquiescence enters into normal condition, produce to interrupt after the anomalous events such as power down occur when external voltage, entering interrupt service routine, switching current state is under-voltage state, is monitored processing, after monitoring is disposed, current state is switched to init state, then recovers abnormal front environmental variable, be then switched to normal condition again, change according to above-mentioned switch logic, it is ensured that mainboard properly functioning.
Above-mentioned industrial device controls processing method, when detecting that mainboard is in under-voltage state, repeatedly judge whether platform reset signal is low level, if low level, then electric voltage exception, output starting-up signal is low level, if high level, then normal in order to ensure mainboard, need to export reset signal is that low level resets, then whether detection platform reset signal is low level again, if low level, then removing cmos signal is output as low level, again mainboard is initialized, make mainboard normal boot-strap, if detection platform reset signal is high level again, directly mainboard is initialized, make mainboard normal boot-strap, improve production production capacity, do not need manual reset, reduce human cost, by time delay Preset Time to provide enough time to carry out cushioning and responding for mainboard, guarantee the accuracy of detection.
Fig. 4 is the flow chart of industrial device controls processing method in another embodiment.As shown in Figure 4, in conjunction with Fig. 2, this industrial device controls processing method, including:
Step 402, detects that the mainboard of industrial equipment powers on first, this mainboard is initialized.
Concrete, initialize and include clock, under-voltage initialization, house dog initialization, serial ports initialization, bus apparatus initialization, initialization of register, intervalometer initialization, the initialization of analog digital conversion passage, system journal initialization etc..
Step 404, it is judged that whether platform reset signal is low level, if so, performs step 406, if it is not, perform step 414.
Step 406, it is judged that the starting-up signal output number of times of mainboard, whether less than preset times, if so, then performs step 408, if it is not, perform step 412.
Concrete, preset times can set as required, as 3 times, 5 inferior.
Step 408, the starting-up signal of output mainboard is low level, and to arrange this starting-up signal after time delay the 6th Preset Time be high level.
Concrete, the 6th Preset Time can according to needing to set, such as 0.5 second, 1 second etc..Timing is carried out by opening timing device.
Step 410, time delay the 7th Preset Time, it is then back to step 404.
Concrete, the 7th Preset Time can according to needing to set, such as 2 seconds, 5 seconds etc..Timing is carried out by opening timing device.
Step 412, record initializes failed daily record, then performs step 414.
Concrete, log facilitates subsequent query analysis.The form of daily record includes index, res1, data, res2, type, res3, code, res4, dmt.Wherein, index is field sequence number, from 0 to 0xffff;Res1 is segmentation character, is defaulted as space;Date is the date, and form is " 2014-10-01 ";Res2 is segmentation character, is defaulted as space;Type is type of message;Res3 is segmentation character, is defaulted as space;Code is position code, is generally used for the BIOS operation phase and indicates;Res4 is segmentation character, is defaulted as space;Dmt is the end mark of 2 bytes, 0x0D, 0x0A.
Type type of message, defines as follows:
The instruction of code position code is as follows:
Wherein, power is power supply, and PCIBus is bus, and pausekey is intervalometer, and BIOS is basic input output system.
Daily record storage mode adopts from the past record next time of the head of every one page, when recorded the second from the bottom of each page, start after having recorded to wipe lower one page, so can search the position of the last item record when mainboard start next time definitely, otherwise be likely to result in false judgment.As it is shown in figure 5, recordable 15 of each page, after recorded the 14th of page 1 article, wipe page 2.Due to the restriction of storage size, logout cannot store too much, adopts and record is carried out classified statistic, then final statistical information is sent to host computer.Statistical information definition is as follows:
Step 414, enables house dog, carries out feeding Canis familiaris L..
Concrete, house dog and watchdogtimer, be a timer circuit, generally having an input, cry and feed Canis familiaris L., the RST end of microcontroller is arrived in an output, when microcontroller normal operation, one signal of output is to feeding Canis familiaris L. end at set intervals, to watchdog zero clearing, if it exceeds the scheduled time does not feed Canis familiaris L., house dog timing exceedes, a reset signal will be provided to microcontroller, make microcontroller reset, it is prevented that microcontroller crashes.
Step 416, the mode of operation of detection mainboard.
Step 418, if the mode of operation of mainboard is normal condition, then processes the message of reception, then returnes to step 414.
Step 420, if the mode of operation of mainboard is under-voltage state, then processes according to under-voltage state, then returnes to step 414.
Concrete, under-voltage state carries out processing namely processing according to step 202 to step 218, does not repeat them here.
Additionally, when external interrupt produces, perform step 430: the mode of operation of mainboard switches to under-voltage state, then log, and enter the step of step 416 mode of operation detection.
Above-mentioned industrial device controls processing method, by when the system is first powered on, initializes mainboard, and whether detection mainboard starts, if not actuated log, then adopts under-voltage state to process, it is ensured that the normal startup of mainboard.
In one embodiment, when the mode of operation of mainboard is normal condition, processes the message received, specifically include: the message received is verified, if verification is passed through, then perform this message.
Concrete, the agreement of message communication includes message header, length, order, operation code, data field, check code etc..Message header can be fixing character, such as " s ", " t ".Length refers to length field, is 255 to the maximum, which includes command field, operation code, data field etc..Order is the command code carrying out communication between host computer.Data are the data field required for corresponding each order.Check code is by length, command code, operation code, data accumulation and gained.Such as, host computer can obtain system temperature, cpu temperature etc. by CMD_GET_TEMP_VAL.Host computer sends and obtains heat command request ' s'-'t'-0x03-0x03-0x00-0x00 CheckSum.Microcontroller is to host computer response command: ' s'-'t'-0x12-0x03-0x00-data [0..15] CheckSum.
Fig. 6 is that in an embodiment, the message received is verified by this, if verification is passed through, then performs the flow chart of the step of this message, specifically includes:
Step 602, verifies sequence number by message field and is initialized as zero.
Step 604, it is judged that whether serial ports receives message, if so, then performs step 606, if it is not, then perform step 630.
Step 606, detection message field verification sequence number.
Step 608, if the message field verification sequence number of detection is 0, it is judged that message field verification sequence number is whether the byte corresponding to 0 is a first default byte, if so, performs step 610, if it is not, perform step 612.
Step 610, verifies sequence number by message field and adds 1, returns again to perform step 604.
Step 612, verifies sequence number by message field and sets to 0, and returns again to perform step 604.
Step 614, if the message field verification sequence number of detection is 1, then judges that message field verification sequence number is whether the byte corresponding to 1 is a second default byte, if so, then performs step 610, if it is not, perform step 612.
Step 616, if the message field verification sequence number of detection is 2, then judges that message field verification sequence number is whether the byte corresponding to 2 is effective length, if so, then performs step 610, if it is not, perform step 612.
Step 618, if the message field verification sequence number of detection is 3, then judges that message field verification sequence number is whether the byte corresponding to 3 is effective order, if so, then performs step 610, if it is not, perform step 612.
Step 620, if the message field verification sequence number of detection is 4, then judges that message field verification sequence number is whether the byte corresponding to 4 is effective operation code, if so, then performs step 610, if it is not, perform step 612.
Step 622, if detection message field verification sequence number be 5, then judge message field verification sequence number be the data field represented by the byte corresponding to 5 whether more than preset value, if so, then perform step 624, if it is not, execution step 626.
Whether complete step 624, determine whether to receive data, if receiving, then performs step 610, if not receiving, then returns to execution step 604.
Step 626, it is judged that verification, with whether correct, if so, then performs step 628, if it is not, then perform step 630.
Step 628, performs this message, then performs step 630.
Step 630, verifies sequence number by message field and sets to 0, then terminate.
By processing according to above-mentioned steps 602 to 630, complete reception message, and message is verified.
Fig. 7 is the flow chart in an embodiment, external input signal being received and processing.As it is shown in fig. 7, in conjunction with Fig. 1, external input signal is received by this industrial device controls processing method and processes, including:
Step 702, receives external input signal.
First, initialize external interrupt pin trailing edge and trigger, and interrupt flag bit is 0.FP_RST is an externally input signal, has two functions, and one is responsible for reset mainboard, and it is default value that another function is responsible for removing CMOS parameter, and the two is determined by the time span being pressed.Such as arranging after pressing FP_RST, mainboard may reset, and is consecutively pressed and exceedes the appointment time, then can perform to remove the action of CMOS.
Step 704, it is judged that whether interrupt flag bit produced by this external input signal is 0, if so, then performs step 706, if it is not, then perform step 708.
Step 706, removes interrupt flag bit, external interrupt pin is set to rising edge and triggers, and output reset signal is low level, and then arranging interrupt flag bit is 1, and to maintain reset signal be that low level exceedes the appointment time, then arranges that to remove cmos signal be low level.
Concrete, it is intended that the time be set press after perform to remove time of CMOS action, such as 4 seconds.
Step 708, remove interrupt flag bit, external interrupt pin is set to trailing edge trigger, output reset signal is high level, time delay the 8th Preset Time, then arrange remove cmos signal be high level.
Above-mentioned external input signal is processed, it may be achieved the button time length that is triggered produces different orders.
Additionally, above-mentioned industrial device controls processing method can be applicable to the BIOS operation phase, detect that BIOS does not run complete, then recording events daily record, and carry out under-voltage state process;Also apply be applicable to the operating system stage, in the operating system stage, host computer is installed an application program, and send heartbeat message by this application program, if mainboard is not received by heartbeat message within the time of regulation, then think that operating system occurs abnormal, then operating system is resetted;Also apply be applicable to run mode and instant power-down abnormality processing occurs.Above-mentioned industrial device controls processing method achieves the part of baseboard management controller and controls function, it is possible to the state of monitoring mainboard, it is ensured that mainboard abnormal restoring; improve self-service service ability; and support the firmware upgrade of mainboard is reached flexible extension function, reduce cost and highly versatile.
Fig. 8 is the structural representation that in an embodiment, industrial device controls processes device.As shown in Figure 8, this industrial device controls processes device, including detection of power loss module 810, judge module 820 and handover module 830.Wherein:
Detection of power loss module 810 is for detecting that the mainboard of external interrupt signal and industrial equipment is in under-voltage state.
Judge module 820 is used for judging whether platform reset signal is low level, if, then again judge after time delay the first Preset Time whether platform reset signal is low level, if, the starting-up signal then exporting mainboard is low level, and to arrange this starting-up signal after time delay the second Preset Time be high level, if not, the reset signal then exporting mainboard is low level, and to arrange this reset signal after time delay the 3rd Preset Time be high level;And it is high level or after reset signal is high level arranging this starting-up signal, time delay the 4th Preset Time, then judge whether platform reset signal is low level, if so, then exporting clear cmos signal is low level.
nullHandover module 830 is for after the clear cmos signal of output is low level,And time delay the 5th Preset Time,Arranging cmos signal is high level,The mode of operation switching mainboard again is init state,And the mode of operation switching mainboard after mainboard initializes again is normal condition,And if detecting that the mainboard of industrial equipment is in under-voltage state,When judging platform reset signal not as low level,The mode of operation of switching mainboard is init state,And after mainboard initializes,The mode of operation switching mainboard again is normal condition,And it is high level or after reset signal is high level arranging described starting-up signal,Time delay the 4th Preset Time,Judge again when platform reset signal is high level,The mode of operation of switching mainboard is init state,Mainboard is initialized,The mode of operation switching mainboard again is normal condition.
Above-mentioned industrial device controls processes device, when detecting that mainboard is in under-voltage state, repeatedly judge whether platform reset signal is low level, if low level, then electric voltage exception, output starting-up signal is low level, if high level, then normal in order to ensure mainboard, need to export reset signal is that low level resets, then whether detection platform reset signal is low level again, if low level, then will remove cmos signal output low level, again mainboard is initialized, make mainboard normal boot-strap, if detection platform reset signal is high level again, directly mainboard is initialized, make mainboard normal boot-strap, improve production production capacity, do not need manual reset, reduce human cost, by time delay Preset Time to provide enough time to carry out cushioning and responding for mainboard, guarantee the accuracy of detection.
Fig. 9 is the structural representation that in another embodiment, industrial device controls processes device.As it is shown in figure 9, this industrial device controls processes device, except including detection of power loss module 810, judge module 820 and handover module 830, also include initialization module 840, logger module 850, state detection module 860 and processing module 870.Wherein:
This mainboard, for detecting that the mainboard of industrial equipment powers on first, is initialized by initialization module 840.Concrete, initialize and include clock, under-voltage initialization, house dog initialization, serial ports initialization, bus apparatus initialization, initialization of register, intervalometer initialization, the initialization of analog digital conversion passage, system journal initialization etc..
This judge module 820 is additionally operable to judge whether platform reset signal is low level, if, determine whether that whether the starting-up signal output number of times of mainboard is less than preset times, if, the starting-up signal then exporting mainboard is low level, and to arrange this starting-up signal after time delay the 6th Preset Time be high level, then after time delay the 7th Preset Time, again judge whether platform reset signal is low level.
If logger module 850 exports number of times more than or equal to preset times for the starting-up signal judging mainboard, then record initializes failed daily record.Concrete, log facilitates subsequent query analysis.The form of daily record includes index, res1, data, res2, type, res3, code, res4, dmt.Wherein, index is field sequence number, from 0 to 0xffff;Res1 is segmentation character, is defaulted as space;Date is the date, and form is " 2014-10-01 ";Res2 is segmentation character, is defaulted as space;Type is type of message;Res3 is segmentation character, is defaulted as space;Code is position code, is generally used for the BIOS operation phase and indicates;Res4 is segmentation character, is defaulted as space;Dmt is the end mark of 2 bytes, 0x0D, 0x0A.
If state detection module 860 is for judging platform reset signal and be high level or after record initializing failed daily record, enables house dog, carry out hello Canis familiaris L., detect the mode of operation of mainboard.
If processing module 870 is normal condition for the mode of operation of mainboard, then process the message of reception, and if the mode of operation of mainboard be under-voltage state, then process according to under-voltage state.
Above-mentioned industrial device controls processes device, by when the system is first powered on, mainboard is initialized, and whether detection mainboard starts, if not actuated log, then adopts under-voltage state to process, it is ensured that the normal startup of mainboard.
The message received is verified by this processing module 870, if verification is passed through, then performs this message.
This processing module 870 is additionally operable to that message field is verified sequence number and is initialized as zero;Judge whether serial ports receives message, if, then detect message field verification sequence number, if the message field verification sequence number of detection is 0, then judge that message field verification sequence number is whether the byte corresponding to 0 is a first default byte, if, then message field is verified sequence number and add 1, again return to perform described judge whether serial ports receives message, if not, then message field is verified sequence number to set to 0, again return to perform described judge whether serial ports receives message;
If the message field verification sequence number of detection is 1, then judge that message field verification sequence number is whether the byte corresponding to 1 is a second default byte, if, then message field is verified sequence number and add 1, again return to perform described judge whether serial ports receives message, set to 0 if it is not, then message field is verified sequence number, again return to perform described judge whether serial ports receives message;
If the message field verification sequence number of detection is 2, then judge that message field verification sequence number is whether the byte corresponding to 2 is effective length, if, then message field is verified sequence number and add 1, again return to perform described judge whether serial ports receives message, set to 0 if it is not, then message field is verified sequence number, again return to perform described judge whether serial ports receives message;
If the message field verification sequence number of detection is 3, then judge that message field verification sequence number is whether the byte corresponding to 3 is effective order, if, then message field is verified sequence number and add 1, again return to perform described judge whether serial ports receives message, set to 0 if it is not, then message field is verified sequence number, again return to perform described judge whether serial ports receives message;
If the message field verification sequence number of detection is 4, then judge that message field verification sequence number is whether the byte corresponding to 4 is effective operation code, if, then message field is verified sequence number and add 1, again return to perform described judge whether serial ports receives message, set to 0 if it is not, then message field is verified sequence number, again return to perform described judge whether serial ports receives message;
If the message field verification sequence number of detection is 5, then judge that message field verification sequence number is whether the data field represented by the byte corresponding to 5 is more than preset value, if, whether complete then determine whether to receive data, if receiving, then message field is verified sequence number and add 1, if not receiving, then return to execution and described judge whether serial ports receives message;
If the message field verification sequence number of detection is 6 or to judge that message field verifies sequence number be that the data field represented by the byte corresponding to 5 is when being less than or equal to preset value, judge verification and whether correct, if, then will perform described message, after having performed, message field is verified sequence number to set to 0, set to 0 if it is not, then message field is verified sequence number.
Figure 10 is the structural representation that in another embodiment, industrial device controls processes device.As shown in Figure 10, this industrial device controls processes device, except including detection of power loss module 810, judge module 820, handover module 830, initialization module 840, logger module 850, state detection module 860 and processing module 870, also include externally input module 880, interrupt flag bit detection module 890 and module 892 is set.Wherein:
Externally input module 880 is used for receiving external input signal.
Interrupt flag bit detection module 890 is used for judging whether interrupt flag bit produced by this external input signal is 0.
Module 892 is set for when judging that produced by this external input signal, interrupt flag bit is 0, remove interrupt flag bit, external interrupt pin is set to rising edge trigger, output reset signal is low level, then arranging interrupt flag bit is 1, and maintenance reset signal is that low level exceedes the appointment time, arranging removing cmos signal again is low level, and when judging that produced by this external input signal, interrupt flag bit is not 0, then remove interrupt flag bit, external interrupt pin is set to trailing edge trigger, output reset signal is high level, time delay the 8th Preset Time, arranging removing cmos signal again is high level.
nullAbove-mentioned industrial device controls processing method and device,When detecting that mainboard is in under-voltage state,Repeatedly judge whether platform reset signal is low level,If low level,Then electric voltage exception,Output starting-up signal is low level,If high level,Then normal in order to ensure mainboard,Need to export reset signal is that low level resets,Then whether detection platform reset signal is low level again,If low level,Then removing cmos signal is output as low level,Again mainboard is initialized,Make mainboard normal boot-strap,If detection platform reset signal is high level again,Directly mainboard is initialized,Make mainboard normal boot-strap,Improve production production capacity,Do not need manual reset,Reduce human cost,By time delay Preset Time to provide enough time to carry out cushioning and responding for mainboard,Guarantee the accuracy of detection.
One of ordinary skill in the art will appreciate that all or part of flow process realizing in above-described embodiment method, can be by the hardware that computer program carrys out instruction relevant to complete, described program can be stored in a computer read/write memory medium, this program is upon execution, it may include such as the flow process of the embodiment of above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-OnlyMemory, ROM) or random store-memory body (RandomAccessMemory, RAM) etc..
Embodiment described above only have expressed the several embodiments of the present invention, and it describes comparatively concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that, for the person of ordinary skill of the art, without departing from the inventive concept of the premise, it is also possible to making some deformation and improvement, these broadly fall into protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.