ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2025/3/1 21:12:46ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£
no
matter it is human behavior or equipment. These processes share variables with PLC controller process. This must be done to ensure the concurrency of the system. In the 2nd part of this paper, we discuss that all the concurrent entities are modeled as an automata. The meaning of automata is to transfer from a state to another. We use the I port to form the state of the entities. Use goto statement as the transfer (just like in Assembly language). A simple example is shown like below: / 3) Code of property
Property is the rule that the PLC system must obey. We use LTL (Linear Time Logic) formula as the input format. We should write the counter-property because of the mechanism of SPIN. SPIN will find a situation that our property happens, that should be a counter-example. We couldn¡¯t directly write the LTL formula, but by using macros. Firstly we should define all the propositions in the LTL in a macro (like # define p i5 == 0), then we use propositions defined to form a LTL formula. SPIN can automatically convert the LTL formula to PROMELA code by using ¡°SPIN¨Cf¡± instruction (see more details in manual of SPIN). 4) Notice-waiting mechanism
In the modeling discussion, we propose to add notice-waiting mechanism. Thismechanism also needs reflected in the code. Specific implementation is to sign a bit variable for each non-PLC process (all the process except PLC controller) as a signal. When the automata transfer to a state label, the signal variable is set to 0, and the next assignment requires this variable to be 1 to continue. As the result of PROMELA grammatical features, the process will hang onwards. In the PLC process no such restrictions, on the contrary, PLC process can set these variables to 1, thus ensuring every move must go through at least one PLC scan to complete. That is the so called notice-waiting mechanism. Follow the four steps above; we get a complete code of a SPIN input file of our system. Then we can use SPIN to check the model. For the steps of operating SPIN model checker, see the manual of SPIN (visit www.spinroot.com). SPIN will give the result whether a counter- example is found, and we can analyze using the theory mentioned above with the trail files that spin gives. Using this detection mechanism, we developed a tool for model checking PLC-checker. It helps to build visual models and the implementation of checking, and can give a simple analysis to the result. Of course, the counter-example it find should be checked manually to make sure whether it is a true counter-example. However,
64
with the help of trail file, this is not a very difficult task. We also successfully implemented some checking using PLC-checker (shown in the next section). In a classic textbook example, a counter-example was found. Although the probability of occurrence of counter-example is very low, but it does happen and can have serious consequences. This tool is alsoproves the correctness and validity of the theory in this article.
5. Running PLC-Checker
We will show the effectiveness of PLC checker by checking a two-door channel model. A two-door channel is used to prevent a closed room from the contact with the outside world. into the tool, also the definition of the property, we execute thechecking. Figure 3shows the result. As we can see, there is one error in the result. It is proved to be a true counter-example by checking the trail file manually. That is to say our mechanism is effective in checking such kind of PLC programs. 6. Conclusions
We study the theory of modeling and checking on PLC system in formal method in this paper. The requirement of PLC modeling is analyzed, and the models ofconcurrent entities are built up through time interval strategy. Then we prove the time interval model a super set of the PLC system, and decrease the model by adding notice-waiting mechanism. It alsoensures all the changes in the system can be scanned by the PLC controller. We find the error of the system by checking out the counter-example of the system. Finally, the way of using SPIN to check the model is given. Also the corresponding model checking tool PLC-Checkeris introduced. In this stage, the mechanism still has many imperfections, such as the handling of the timer. But it has great and unique advantages in solving the problem of state exploration. We are still on active exploration of such issues.
65
REFERENCES
[1] Pavlovic, R. Pinger and M.Kollmann, ¡°Automated Formal Verification of PLC Programs Written in IL,¡± Conference on Automated Deduction (CADE), Bremen, July 2007, pp. 152-163.
[2] M. B. Younis and G. Frey, ¡°Formalization of Existing PLC Programs: A Survey,¡± Proceedings of CESA 2003, Lille, 2003.
[3] N. Bauer, S. Engell, S. Lohmann, M. Remelhe and O. Stursberg, ¡°Verification of PLC Program Given as Sequential Function Charts,¡± Lecture Notes in Computer Science, Vol. 3147, 2004, pp. 517-540.
[4] S. R. Koo, P. H. Seong and S.D. Chaa, ¡°Software Design Specification and Analysis Technique for the Safety Critical Software based on Programmable Logic Controller (PLC),¡± Proceedings of the Eighth IEEE International Symposium on High Assurance Systems Engineering HASE¡¯04), Florida, March 2004, pp. 283-284. [5] A. Mader and H. Wupper, ¡°Timed Automaton Models for Simple Programmable Logic Controllers,¡± Proceedings of the 11thEuromicro Conference on Real-Time Systems1999, York, June 1999, pp.106-113.
[6] E. Brinksma1, A. Mader and A. Fehnker, ¡°Verification and Optimization of a PLC Control Schedule,¡± International Journal on Software Tools for Technology Transfer (STTT), Vol. 4, No. 1, October 2002, pp. 21-33.
[7] S. Lamp¡äeri`ere and J. J. Lesage, ¡°Formal Verification of the Sequential Part of PLC Programs,¡± 5th Workshop on Discrete Event Systems (WODES2000), Ghent, August 2000, pp. 247-254.
[8] S. Kowalewski, S. Engell, J.Preu?ig and O. Stursberg, ¡°Verification of Logic Controllers for Continuous Plants Using Timed Condition/Event-System Models,¡± Automatica: Special Issue on Hybrid Systems, Vol. 35, No. 3, March 1999, pp. 505-518.
66
PLCµÄ½¨Ä£ÓëÐÎʽ»¯¼ì²éÒÑ·½·¨
ÕªÒª
¸ß¿É¿¿ÐԵĹؼüÊǵçÆø¿ØÖÆÉ豸µÄÐÔÄÜ¡£ PLC×ÛºÏÁ˼ÆËã»ú¼¼Êõ£¬×Ô¶¯¿ØÖƼ¼ÊõºÍͨÐż¼Êõ£¬²¢³ÉΪ¹ã·ºÓÃÓÚ¹¤Òµ¹ý³ÌµÄ×Ô¶¯»¯¡£¸´ÔÓµÄPLCϵͳµÄһЩҪÇó²»ÄÜÓÉ´«Í³µÄÑéÖ¤·½Ê½Ö§¸¶¡£ÔÚÕâÖÖÖ½£¬¶ÔPLCϵͳµÄ½¨Ä£ºÍÑéÖ¤µÄÓÐЧ·½·¨±»Ìá³ö¡£ÎªÁ˱£Ö¤PLCµÄ¸ßËÙÐÔÄÜ£¬ÎÒÃÇÌá³öÁË¡°Ê±¼ä¼ä¸ôģʽ¡±ºÍ¡°Í¨ÖªµÈ´ý¡±µÄ¼¼Êõ¡£Ëü¿ÉÒÔ¼õÉÙ״̬¿Õ¼ä²¢Ê¹ÆäÄܹ»Ñé֤ijЩ¸´ÔÓµÄPLCϵͳ¡£ÁíÍ⣬´ÓÄÚÖÃPLCÐͺÅΪPromelaÓïÑÔµÄÓïÑÔת»»µÃµ½Ó빤¾ßPLC-¼ì²éÔ±½øÐн¨Ä£ºÍcheckingPLCϵͳµÄÉè¼Æ¡£ÔËÓÃPLC-¼ì²éÆ÷¼ì²éÒ»¸ö¾µäµÄPLCÀý×Ó£¬Ò»¸ö·´Àý±»·¢ÏÖ¡£ËäÈ»Õâ¸öÂß¼´íÎóµÄ·¢Éú¸ÅÂʷdz£Ð¡£¬Ëü¿ÉÄܻᵼÖÂϵͳ±ÀÀ£ÖÂÃüµÄ¡£
¹Ø¼ü´Ê£ºÄ£ÐͼìÑ飬ģÐ͵ÄPLC£¬PLCµÄ¼ì²é£¬ÐÎʽ»¯·½·¨
1ÒýÑÔ
PLCÊÇ£¬¿ÉÒÔ´Ó´«¸ÐÆ÷½ÓÊÕµÄÐÅÏ¢µÄ×Ô¶¯¿ØÖÆÉ豸£¬¼ÆËãÉ豸»òÆäËû¿É±à³Ì¿ØÖÆÆ÷Âß¼ÊäÈëÐźţ¬²¢Êä³öÂß¼ÐźŽøÐд¦Àí¡£¿ØÖÆËã·¨¿ÉÒÔʹÓñê×¼µÄÓïÑÔ£¬ÈçÌÝÐÎͼ£¨LD £©£¬½á¹¹»¯Îı¾Ð´È루 ST£©£¬»òÖ¸ÁîÁÐ±í£¨IL £© [ 1 ]¡£¿É±à³Ì¿ØÖÆÆ÷²ÉÓÿɱà³ÌÓïÑԵļ¼ÇÉ¿ØÖÆ´ó¹æÄ£¼¯³Éµç·ÒѾ¹ã·ºÓ¦ÓÃÓÚÔÚÐÐÒµ[ 2 ]¡£ÒòΪ°²È«¹Ø¼üÈí¼þµÄ¿ÉÔì³ÉÉúÃü»ò²Æ²ú£¬ºËʵÑÏÖØË𺦰²È«¹Ø¼üÈí¼þÒѾ³ÉΪһ¸ö±Ø²»¿ÉÉٵIJ½Öè±£Ö¤Èí¼þÖÊÁ¿ÒªÇó¡£±¾Ð£Ñé·½·¨ÎªPLCÈÔÍ£Áôͨ¹ý·ÂÕæºÍ²âÊÔ¡£µ«ÊÇ£¬ËûÃDz»Äܺ¸ÇËùÓпÉÄܵÄÇé¿öÏ£¬ÌØÊâPLCµÄÉè¼ÆÄ£ÐÍÊÇ·ñÂú×ãÐèÇó¡£Òò´Ë£¬Ä£Ðͼì²â¿Æ¼¼ÍƳö½øÈëPLCÁìÓòÒªgivetheoretical PLCµÄ·ÖÎöÉè¼Æ±äµÃÖØÒª¡£PLCµÄÄ£Ðͼì²âµÄÖ÷Òª²½ÖèÊǽ¨Á¢PLCÐͺţ¬ÈçÊ÷Á¢Ñù°å´Ó¹¦ÄÜͼ[ 3 ]¡£ PLCÐͺż¯ÖÐÔÚ³ÉÁ¢Ê±ÊôÐÔ[ 4 ]¡£Ëü¿ÉÒÔ½¨Ä£°´Ê±¼ä×Ô¶¯»úµÄ·½·¨[5]»òʱ¼ä¶Î½¨Ä£·½·¨[ 6 ]¡£Òò´Ë£¬Ä£Ð͵Ä״̬¿Õ¼ä½«¼õÉÙÁËÓëʱ¼ä×Ô¶¯»ú¡£ÎÞÂÛÄÄÖÖ;¾¶Ö®Ò»Ñ¡Ôñ£¬×îÖյijéÏóÄ£ÐÍ¿ÉÒԵõ½[ 7 ]¡£ÈçºÎ½¨Á¢Ò»¸öÁ¼ºÃµÄPLCµÄ³éÏóÄ£ÐÍÊÇ×îÖØÒªµÄÎÊÌâµÄ¼ì²é¡£ÓÉÓÚÊÖ¹¤½¨Ä£ÈÝÒ×ÒýÈëÐí¶à´íÎó£¬ËùÒÔ½¨Á¢Ò»¸ö¼¯³ÉµÄ½¨Ä£ºÍ²âÊÔ¹¤¾ßÊǷdz£ÖØÒªµÄ£¬ÕâÒ²ÊǹØ×¢±¾ÎĵÄÎÊÌâÖ®Ò»¡£PLC¿ØÖƳÌÐòµÄʵʱ²Ù×÷ϵͳ£¨¶àÈÎÎñ»¹Êǵ¥ÈÎÎñ£©ÔËÐÐ;±¾ÎÄÖ÷ÒªÊÇ»ùÓÚÉϵĶàÈÎÎñµ÷¶ÈµÄPLCϵͳ¡£µÄµÚ2½ÚÎÄÕÂÓнéÉܵĽ¨Ä£·½·¨PLCϵͳ¡£µÚ3½Ú¸ø³öÁ˸ÃÄ£Ð͵ķÖÎöºÍ¸Ä½ø£¬ÒòΪÎÒÃÇÐèÒª½µµÍµÄ¿ÉÄÜÐÔα´íÎó¡£µÚËIJ¿·ÖÉè¼ÆÁËÒ»¸öÄ£Ðͼì²â¹¤¾ßPLC-¼ì²éÆ÷¼ì²éËù½¨Á¢µÄÄ£ÐÍ£¬°üÀ¨Òý½øת»¯PLC³ÌÐòµ½SPINµÄ·½Ê½ÊäÈëÓïÑÔPromelaÓïÑÔ´úÂë¡£×îºó£¬Ò»¸ö¾µäµÄPLCÀýÈ类ʩ¼Óµ½¼ì²éºÍÁٽ绡¶Î£¬ÀýÈçÓÉPLC £¬¼ì²é·¢ÏÖ¡£
67
2£¬PLC½¨Ä£
ÓÐÈý¸ö²½ÖèÄ£ÐͼìÑéµÄ£ºÔìÐÍ£¬µÀ¾ß£¬PLCµÄ½¨Ä£ÓëÐÎʽ»¯·½·¨1055¼ì²éÒÑERTYÃèÊöºÍÑéÖ¤¡£×îÖØÒªµÄÊÇÈçºÎ½¨Á¢ÏµÍ³Ä£ÐÍ¡£ÔÚϵͳÖУ¬ PLC¿ØÖÆÆ÷²»ÊÇ·ÖÀëµÄ£¬¶øÊǾßÓÐÆ乤×÷»·¾³£¬Ë¾»úºÍÈËÀཻ»¥[8]¡£Òò´Ë£¬ÕâЩÒòËØÒ²Ó¦¸Ã½¨Ä£¡£»·¾³£¬ÈËÀàºÍPLC¿ØÖÆÆ÷ÊǶÀÁ¢µÄ£¬²¢·¢µÄÏ໥Âß¼¡£´ËÍ⣬¸ÃÄ£Ðͼì²â¹¤¾ßSPINµÄÊäÈëÓïÑÔPromelaÓïÑÔÊÇרעÔÚÃèÊö²¢·¢£¬ËùÒÔ´ÓÕâ¸ö˼·³ö·¢£¬ÎÒÃǽ¨Á¢ÕâЩÒòËطֳɼ¸¸ö²¢·¢½ø³ÌÊʺϴÓSPINµÄ¼ì²é£¬ËüÒ²½«×¼È·µØÃèÊöϵͳ¡£ÎªÁËÃèÊö·½±ã£¬ËûÃǽ«Ëùν²¢·¢ÊµÌå¡£ PLC¿ØÖÆÆ÷Ó뻥¶¯Í¨¹ýÔÚͼÏñ±íÖеķûºÅ²¢·¢ÊµÌå¡£PLCϵͳµÄ·ûºÅ°üÀ¨I£¨ÊäÈë¶Ë¿Ú£© £¬Q£¨Êä³ö¶Ë¿Ú£©ºÍM £¨Öмä¼ÌµçÆ÷£© ¡£Í¼1ÊÇÒ»¸öͼÖеÄPLCϵͳģÐÍ¡£Ê±¼ä¼ä¸ô½¨Ä£²ßÂÔ£ºÓùúÆìÄÄЩÌض¨µÄ²¢·¢ÊµÌåµÄλ״̬±íʾ²¢ÐÐʵÌåµÄ״̬£¬¶ø²»¿¼Âǵ½ÏµÍ³Ê±ÖÓ¡£Õâ¿ÉÄÜ»áºöÂÔʱ¼ä¹ú¼ÒµÄ²îÒ죬´Ó¶ø¼ò»¯ÁËPLCÐͺš£¸Ã½¨Ä£²ßÂÔ²»»á½«ÏµÍ³Ê±ÖÓÐÔÖÊ£¬²»ÍêÈ«¶ÔÓ¦ÓëÔÀ´µÄPLCÄ£ÐÍ¡£ÕâÖ÷ÒªÊÇÓÉÓÚ¼ÓÈëÁËϵͳʱÖӻᵼÖÂPLCϵͳģÐͱäµÃ¹ý´ó£¬²»´æÔÚΪģÐͼì²â¹¤¾ßÀ´´¦ÀíÕâô´óµÄÄ£ÐÍ¡£ÆðµãÔìÐÍÏñ״̬ ÕâÊDz»ÊÇÒª¿¼ÂÇPLCµÄɨÃè´ÎÊý£¬µ±Ç¨ÒÆÊǾÑé·á¸»¡£²»¹ÜÓжàÉÙɨÃèËü¾Ñé·á¸»£¬ËûÃǶ¼½«°üÀ¨ÔÚÕâ¸öÄ£ÐÍ¡£ÔÚ»»¾ä»°Ëµ£¬ÕæʵģÐͽ«ÊÇÄÚÖõÄÒ»¸ö×Ó¼¯Ä£ÐÍ£¨Ê±¼ä¼ä¸ôÄ£ÐÍ£© ¡£ÕæÕýµÄPLC»·¾³ÊǸ´Ôӵģ¬²¢ÇÒ°üÀ¨Ò»¸÷ÖÖÓ²¼þºÍÈËÀàÐÐΪ¡£ÏÂÃæÎÒÃÇ»á¸ø²»Í¬ÖÖÀàµÄPLC»·¾³µÄ²¢·¢ÊµÌåµÄ·ÖÎö¡£ 1 £©Ó²¼þʵÌå
PLCϵͳµÄÓ²¼þʵÌåÖ÷ÒªÊÇһЩÉ豸µÄPLC¿ØÖÆ¡£ÕâЩÉ豸µÄ״̬¿ÉÒÔÊÇPLC¿ØÖÆÆ÷µÄÊäÈë¶Ë¡£Òò´Ë£¬±¾ÓëÆäÏà¹ØÁªµÄIºÍQ £¬Ó²¼þʵÌå½áºÏ¶øÓ²¼þ¶¼ÓÐ×Ô¼ºµÄ¹¤×÷Á÷³Ì£¬Õâ¸öÁ÷³ÌÊÇͨ¹ý¶ÔÓ²¼þµÄÒªÇó¾ö¶¨¡£Õâ¸ö¹¤×÷Á÷³Ì¿ÉÒÔ±»³éÏó³É×Ô¶¯»ú¡£¸Ã×Ô¶¯»úÊÇÓÃÀ´ÃèÊöÓ²¼þµÄ¹¤×÷״̬¡£¶¨Òå2.1 ¡£ AÓ²¼þʵÌåÊÇÒ»¸öÔª×é°üĤ= < Ienv£¬Qenv £¬ A> £¬ÆäÖÐIenvÓëÓ²¼þµÄI¶Ë¿Ú°ó¶¨ÊµÌ壬 QenvÓë¸ÃʵÌåÔÚQ¶Ë¿Ú°ó¶¨¡£ AÊÇ×Ô¶¯»úÃèÊöʵÌåµÄ¹¤×÷Á÷³Ì£¬ AÊÇÔª×éA =
68