(2), background technology
In the relevant document of Digital Electronic Technique, generally all to introduce the rudimentary knowledge of logic algebra.Main contents wherein are the abbreviation of formula, theorem, method for expressing and the crucial logical function of logic algebra.For the computing of logic algebra, the just decimal arithmetic of being familiar with by people, the coding and the computing method of explanation binary number are highly susceptible to understanding and grasping.For digital circuit, circuit itself has just comprised the overall process of " calculating ".For example, in combinational logic circuit, input signal is at that time only depended in output (that is: logic operation result); In sequential logical circuit, input signal is at that time not only depended in output, also depends on the state that circuit is original.So the fundamental purpose of logic algebra is to analyze, design the mathematical tool of (high-level efficiency, high-quality) Fundamental Digital Circuit.
The logical function expression formula of putting in order out according to practical problems often is not the simplest or the form of easy realization.That is, realize that the computing method of logic function or its circuit structure have the necessity that needs optimization, this itself is also comprising high-level efficiency, the pursuit of high-quality algorithm.So the research of the simplifying method of logical function just becomes an important aspect.Well-known equation, map Karnaugh, tabulating method (new-added item cencelling of terms method and Kui En-Joseph McCluskey method) etc. have appearred then.But, the equation abbreviation needs certain skill and experience, does not have fixing step to follow, and is difficult for grasping, be difficult to also to judge whether the abbreviation result has been simplified to that item number is minimum, all the more so during every some complicated logical functions of the simplest formula that the variable number is also minimum, especially abbreviation.Karnaugh map abbreviation method has simply, directly perceived, the advantage that has certain rules can follow, be easy to grasp, but, when logical variable surpasses five, will lose advantage simply and intuitively fully, even become and do not have what too big use value.Tabulating method (Quine-Mcluskey method) has significant superiority for solving the Multi-Variable Logic Function abbreviation, this method has hard and fast rule and step, be convenient to computer operation, but to large-scale logical function simplification, then need very big memory capacity, and then will have a strong impact on the speed of abbreviation.Can reach a conclusion thus: up to the present, utilize abbreviation to pursue high-quality, the high efficiency mode of " computing ", await new breakthrough.Abbreviation is beneficial to finds the solution, and finds the solution but be different from.
Compiler is the computer program that a kind of language is translated as another kind of language.Compiler as input, and produces the equivalence program of writing with target language with the source program written program.Normally, source program is a higher level lanquage, and target language then is the object code of target machine, just writes on the code that is used to move in the computer machine instruction.Compiler is a kind of quite complicated program, writes even understand so all non-easy thing of a program, and most computer scientist and professionals also never write a complete compiler.The generation of compiler algorithm is for the convenient exploitation of software and the concise and execution speed of object code have found an equilibrium point preferably.But,, can not again compiler and higher level lanquage environment be integrated the extremely limited controller of hardware resource.Generally be in another development environment, move installing in the controller under the compiled object code.Small-sized above PLC adopts this mode of operation exactly, and the object code that is produced even reaches megabyte basically also all more than tens of kilobyte.
Interpretive routine also is a kind of language translator as compiler.The difference of it and compiler is: it does not produce target program, but a statement accepting certain higher level lanquage is imported, make an explanation and control computer is carried out, obtain this execution result, and then accept next sentence: while explain and carry out at once.In principle, any programming language all can be explained or be compiled.Generally speaking, just use compiler when the speed of carrying out is of paramount importance factor, this is faster than the source code of being explained because carry out the object code that is compiled, sometimes will be fast 10 times or more.Now,, in miniature even small controller, also have and adopt interpretation algorithms to realize along with the raising of CPU speed and the decline of price, but still higher to the hardware configuration requirement, function software also there are ask for something and restriction.
The general univariate input and output of test-and-control type instrument and meter multiprocessing, needing only by common microprocessor is core, just can finish its function more with flying colors.1), the relation of input and output is too simple, can not adapt to the complicacy requirement of actual conditions preferably but value that there are the following problems:.2), generally can not give full play to the effect and the potentiality of microprocessor.
The PLC manufacturing technology is abroad being monopolized basically.China is very active in the PLC application, develop, manufacturing technology then extremely thin a little less than.So, all to spend billions of first import PLC every year.For this reason, also there is special policy in country, supports the production domesticization of PLC energetically.
(3), summary of the invention:
In order to overcome the shortcoming of prior art, data processing section of the present invention provides a kind of module of finding the solution of logic algebra, and it has high operation efficiency to the quantity of logical variable without limits, be well suited for computing machine or device routine processes, and its program is very brief.
The present invention solves the technical scheme that its key technical problem takes: it comprises
No bracket operation unit a, with expression formula be expressed as single logical variable " with " the inclusive-OR operation form, earlier first logical variable value is deposited among the operation result variable V al; B, the operational symbol of judging the back be " with " or inclusive-OR operator; C, logical operator when the back be " with ", and when the logical value of operation result variable is false (0), just search backward, without computing, up to searching inclusive-OR operator, (perhaps the end of expression formula directly draws operation result,) will search " or " value of the logical variable of logical operator back directly deposits among the operation result variable V al, go on foot since b; D, when the operational symbol that searches the back be " with ", and when the logical value of operation result variable is true (1), also search backward is without computing, up to searching next logical variable, and its value deposited among the operation result variable V al, since the b step, certain again, if searched the end of expression formula, just can finish computing, the value of operation result variable is directly exported; E, when the operational symbol of judging the back be " or ", and the logical value of operation result variable is fictitious time, also search backward without computing, up to searching next logical variable, and deposits its value in the operation result variable in, goes on foot since b again.Certainly,, just can finish computing, the value of operation result variable is directly exported if searched the end of expression formula; F, when the operational symbol of judging the back be " or ", and the logical value of operation result variable is true time, direct output logic result " very " just, other result is not had in the end computing again;
With the bracket operation unit is arranged, A, with expression formula be expressed as single logical variable " with ", " or " and the operational form of " bracket ", logical expression in the bracket can equivalence become a logical variable, bracket " to " count without limits, but bracket to be divided into left parenthesis and right parenthesis; B, when parenthesis part appear at expression formula in, during rear positions, should pay the utmost attention to logical value in the outermost layer bracket to the influence of operation result; C, when needs carry out the logical operation of bracket inside, it is the beginning (being called outer bracket) that parenthesis part appears at expression formula, 1. in the process of search, the logical consequence of current record is 0, the back searches inclusive-OR operator, the back is the bracket structure again, 2. in the process of search, the logical consequence of current record is 1, and the back searches the AND operation symbol, the back is the bracket structure again, obviously, these expression formulas are equivalent to the beginning that parenthesis part appears at expression formula, at this moment, must record parenthesis nesting number: do when running into a left parenthesis and add " 1 " counting, run into logical variable and just use the searching method of above-mentioned no bracket operation unit, do when running into a right parenthesis subtract " 1 " counting, the bracket of successively decorporating, up to bracket is disposed, promptly the bracket count value is 0.
The characteristics of data processing section of the present invention are to explain to carry out the user logic expression formula, according to condition search for, judge net result, do not carry out real logical operation, so, it has high " computing " efficient, also is well suited for computing machine or device routine processes, and its program is also very brief.
(5), embodiment
Data processing section of the present invention comprises no bracket operation unit and the bracket operation unit is arranged, shown in Fig. 1,3.
Logic algebra or title Boolean algebra are to analyze, design the mathematical tool of Fundamental Digital Circuit.Because the most basic logical relation have only with or, non-three kinds, so in logic algebra, the most basic corresponding logical operation also has only three kinds: with computing (logical multiplication computing), exclusive disjunction (logical addition computing), inverse (the Boolean complementation computing is called for short complementary operation).Other computing for example with non-, NOR-operation, AOI computing, XOR etc., can be represented with these three kinds of computings the most basic equivalently.
In the method, require with logical expression be organized into single logical variable " with ", the inclusive-OR operation form.Certainly, the logic NOT that can comprise single logical variable is a contravariant.
In logical expression, have following fundamental relation to exist:
1+A=1 (formula 1)
0+A=A (formula 2)
1*A=A (formula 3)
0*A=0 (formula 4)
Wherein, A can be any type of logical expression.In the method, refer in particular to " with ", the logical expression of inclusive-OR operation form.
1, foundation order of operation and above-mentioned four formula from left to right just have or not bracket logic algebra result's searching method as follows:
1), earlier first logical variable value is deposited among the operation result variable V al.
2), the operational symbol of judging the back be " with " or inclusive-OR operator.
3), the logical operator when the back be " with ", and the logical value of operation result variable is when being false (0), just search backward, without computing, because the result of computing remains 0, up to searching inclusive-OR operator, perhaps the end of expression formula draws operation result.Because have only " or " logical operation just might change the result of current logical operation, will " or " value of the logical variable of logical operator back directly deposits among the operation result variable V al, again since the 2nd) step.
Example 1:Val=ABCD, at first just A invests Val, if A=0, according to formula 4, Val=0.
Example 2:Val=ABCD+EF, if A=0, according to formula (4 He) 2, must: Val=0+EF=EF, promptly have only the EF of inclusive-OR operator back might change the logical value of Val, the computing reference example 1 of back again.
4), the operational symbol of back be " with ", and the logical value of operation result variable is when being true (" 1 "), also search backward without computing, up to searching next logical variable, and deposits its value among the operation result variable V al, again since the 2nd in) step.Certainly,, just can finish computing, the value of operation result variable is directly exported if searched the end of expression formula.
Example 3:Val=ABCD at first invests Val with A, if A=1 according to formula 3, gets Val=BCD, again B is invested Val, continues search.
5), the operational symbol when the back be " or ", and the logical value of operation result variable is fictitious time, also search backward without computing, up to searching next logical variable, and deposits its value in the operation result variable in, again since the 2nd step.Certainly,, just can finish computing, the value of operation result variable is directly exported if searched the end of expression formula.
Example 4:Val=A+BCD, at first just A invests Val, if A=0 according to formula 2, gets Val=BCD, the computing reference example 1 of back again.
6), the operational symbol when the back be " or ", and the logical value of operation result variable is true time, direct output logic result " very " just, end computing.Do not have other result again.
Example 5:Val=A+BCD, at first just A invests Val, if A=1 according to formula 1, gets Val=1, finishes computing.
2, the treatment principle of Boolean calculation bracket problem and solution are as follows:
1), when utilizing this method, still require with expression formula be expressed as single logical variable " with ", the inclusive-OR operation form.The logic NOT that can comprise single logical variable is contravariant and bracket.Logical expression in the bracket can equivalence become a logical variable.Bracket " to " number without limits.But, bracket is divided into left parenthesis and right parenthesis.
2), parenthesis part appear at expression formula in, during rear positions, should pay the utmost attention to logical value in the outermost layer bracket to the influence of operation result.
Example 6:Val=A (BCD+EF () G), when A=0, exportable Val=0.
3), when needs carry out the logical operation of bracket inside, promptly parenthesis part appears at the beginning (being called outer bracket) of expression formula.Example 7:Val=(BCD+EF () G) A, perhaps a), in the process of search, the logical consequence of current record is 0, and the back searches inclusive-OR operator, and the back is the bracket structure again.Example 8:Val=A+ (BCD+EF () G)=(BCD+EF () G).B), in the process of search, the logical consequence of current record is 1, the back searches AND operation symbol, the back is the bracket structure again, routine 9:Val=A (BCD+EF () G)=(BCD+EF () G).Obviously, these expression formulas are equivalent to the beginning that parenthesis part appears at expression formula.At this moment, must record parenthesis nesting number: do when running into a left parenthesis and add " 1 " counting; Run into logical variable and just use above-mentioned searching method; Do when running into a right parenthesis subtract " 1 " counting, the bracket of successively decorporating, up to bracket is disposed, promptly count value is 0.
In example 6, the bracket in the expression formula is called internal bracket.In its search procedure, there has not been the value of computing, the number of only searching for internal bracket gets final product, do when running into a left internal bracket and add " 1 " counting, do when running into a right internal bracket and subtract " 1 " counting, the bracket of successively decorporating, up to bracket is disposed, promptly count value is 0.
4), expression formula after suitable abbreviation etc. is handled, should need not or use bracket less as much as possible.
5), the finding the solution in the process flow diagram of logic algebra, Fig. 1,2 is illustrated in the situation of not using bracket in the logical expression, as seen, it is simple a lot of that its process flow diagram is wanted.In logical expression, bracket is not necessary, even if used bracket, through suitable arrangement, bracket can be sloughed yet.Fig. 2,3,4 the process flow diagram of finding the solution are the time situations that bracket is arranged.Among the figure, I represents the value of I variable, and K represents the counter of outer bracket, and m represents the counter of internal layer bracket, the result of calculation of Val presentation logic expression formula, the terminating symbol of end presentation logic expression formula.
3, main application example
1), exploitation PLC
In general PLC control system, all to handle a lot of logical operations, all the more so in middle-size and small-size PLC.Because the data processing section of this method is brief, concise, so, soft, hardware resource is required very low, be particularly suitable for the PLC that utilizes more common microcomputer development middle-size and small-size.Certainly, high-grade configuration, better effects if.
Concrete grammar is: the data that collect and user's control flow of expression formula address pattern etc. are stored in corresponding data field, again with the data processing section search output of this method.The method of the preparation method of user control program similar " parameter is set " is easy to learn and use, to little, small PLC is especially true.This compares with traditional PLC is its outstanding feature.In addition, " with-or " the unusual ladder diagram of approach relay logic control chart and PLC of expression formula form, also be familiar with by numerous engineering technical personnel.So, the PLC that adopts this method to develop, the user can be in order to avoid training, directly use.
For the analog quantity that collects, they utilizations can be taken back stagnant comparer and convert the digital state amount to.The computing and the output of alternate manner also can be arranged certainly.
In addition, the PLC manufacturing industry is abroad being monopolized basically, and the successful Application of this method will help the generation of the homemade PLC that shows unique characteristics.Checking and concrete an application as this method, I utilize very common single-chip microcomputer 89C51 to develop the miniature PLC of/8 outputs of a kind of 16 inputs, collection I/O, demonstration, communication, programming etc. operate in one, and be very easy to use, need not carry out the application technology training to the user.The clock of 12MHZ, about 20 milliseconds of the maximum scan cycle of user program, total about 3K byte of procedure quantity.Hardware cost is also extremely cheap.
2), exploitation DCS
Utilize this method can develop electrical control equipments such as PLC, intelligent instrumentation, and can networking constitute low-cost, high efficiency Distributed Control System (DCS).
3), developing intellectual resource instrument and meter
Used single-chip microcomputer in the intelligent monitoring instrument and meter in a large number, utilized this method to develop the high-grade control type intelligent instrumentation of output able to programme on original hardware foundation, hardware cost remains unchanged substantially, thereby increases substantially its ratio of performance to price.
4), huge development and use potentiality
PLC originally belongs to different technical fields with instrument and meter, the present invention has opened up the application product zone of small PLC and intelligent measurement and control instrument instrument combined belt, promptly utilize this method can develop, develop the various intelligent measurement and control instrument instrument of PLCization, also can develop, develop the instrumented PLC of various intelligent measurement and control instruments.The utilization and extention of this method will produce the PLC of new generation and the instrument and meter that show unique characteristics, for bringing huge commercial opportunities and value in the control field in the China and even the world.
5), Digital Simulation or Digital Logic computer-aided analysis
Utilize this method also can develop high efficiency Digital Simulation or Digital Logic computer-aided analysis software.
6), the application of others
As a kind of data processing method novel, tool-type,, can not estimate its using value fully owing to the restriction of inventor's knowledge, level etc.A lot of historical inventions, its using value head and shoulders above inventor's the imagination, for example 555 integrated circuit originally.For this method, wish that equally vast person skilled understands it, grasps it, creatively use it, develop the outstanding product that differs from one another.