An understanding of the state machine
Recently, I am re-learning about the state machine. It is very important. At least I know that there is a state machine in both hardware and software, in terms of control, modern control theory also has the concept of state equations, which is almost the cornerstone of modern control theory. In addition, in motion control theory, the concept of motion groups is essentially a state machine.
I know more or less about software and control, but it is a pity that what is a state machine, hardware, software, and control focuses differently, it is even more important to do motion control software to understand the state machine than to understand the object orientation. Why do we say that we have seen the ladder program of PLC in Motion Control estimation, how many people are aware that this thing in the field of horizontal motion control has been a state machine for decades? How many people are aware that the state machine has been regarded by many software personnel as a mysterious thing, there are so many people in China who are engaged in state machine-based development every day. How many people have thought about it? Many people think it is a simple PLC ladder program, why can most of the applications in Motion Control be completed (I think the ladder program is simple and does not include me), I guess there are not many people who realize that it is based on state machine programming.
Many people think that the state machine is a theoretical thing, which is far away from us. In fact, what I want to say is that it is not like that. Almost every one of us uses a state machine every day. Do you have a choice in life! If you have one, you may choose the state machine. Maybe I think this sentence is not too much. The world may be object-based, but the movements in this world are absolutely state-based. We have done so many years of programs. The world is composed of modules, and the change in the description module should be state. The state machine can not only be an algorithm, but also a framework. I recently read the Lua source code. Unfortunately, when I proposed a state machine, we thought it was related to lexical analysis. This is not the case.
The state machine I found is defined as the following (Finite State Machine ):
My first question:What is a state machine?
FSM definition: In general, a finite state machine system is a system that presents different running states at different stages. These States are finite and do not overlap. Such a system is always in one of its states at a certain time. At this time, it receives some allowed inputs, generates some possible responses, and migrates them to some possible states.
Five elements: Status, event, condition, action, migration
This is a pure software definition, or I think this concept is too general. The state of control is not discrete. Therefore, the finite state machine cannot be unified with the state machine on control. As for the infinite state machine, I have not yet understood the concept clearly.
My second question:What is status?
The above concepts are too general.
2. How to Build a program architecture based on the state machine
I have summarized some of the program architectures I have seen in the past, including the Lua and OpenGL program architectures. I am sure they are state machine-based program architectures, And the PLC background must be the same, some of the software I have seen in my industry is also based on the state machine program architecture. In addition, many protocol parsing and generation principles, including their design, are also based on the state machine, not only TCP/IP is used. It is true that there is more profound understanding of state machines in China and abroad than in China.
If you are interested, I hope you can learn and communicate with each other. At present, I am mainly looking at Lua's source code, hoping to get some inspiration through its source code. As for the state machine in Motion Control, I have to understand it. I hope you will be able to communicate with us more. At present, the design of the state machine in Motion Control is summarized but immature.