Author Topic: State diagrams  (Read 4042 times)

0 Members and 1 Guest are viewing this topic.

Offline djsbTopic starter

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
State diagrams
« on: March 14, 2010, 04:26:12 pm »
Hi,
Does anyone know where I can get a CLEAR explanation of state diagrams and finite state machines? It is one of the areas that I have never been able to grasp. It would be nice if there where some easy to understand examples that I can work through. Maybe someone could point me to a chapter in a book?
Thanks.

David.
David
Hertfordshire, UK
University Electronics Technician, London, PIC16/18, CCS PCM C, Arduino UNO, NANO,ESP32, KiCad V8+, Altium Designer 21.4.1, Alibre Design Expert 28 & FreeCAD beginner. LPKF S103,S62 PCB router Operator, Electronics instructor. Credited KiCad French to English translator
 

Offline rossmoffett

  • Regular Contributor
  • *
  • Posts: 234
  • Country: us
Re: State diagrams
« Reply #1 on: March 14, 2010, 06:25:31 pm »
Well.. I'll do the best I can.  I never had any written explanation of how to do it, we just had to learn for my digital logic class.

A state machine has a statement inside of it which is executed, and then it has paths leaving it with conditional statements (they lead to the next state machine).  If the statement is true, then that path is taken.  If not, then you're stuck.

That's it.  You can make huge complicated state diagrams with that simple principle.  I made an arcade game, dance dance revolution, using state machines.  Sometimes the code blocks they executed were discrete logic or VHDL.

The point of a state machine is to create an orderly sequence of events, because with unclocked discrete logic, unexpected events are much more likely to occur.
ArcAttack - A group of musical Tesla coil performers with semi-regular blog updates.
 

Offline fsleeman

  • Regular Contributor
  • *
  • Posts: 54
Re: State diagrams
« Reply #2 on: March 15, 2010, 01:29:01 pm »
Procedural programming languages like C are basically glorified state machines. If you replaced all of decision making keywords (for, while, switch, etc.) with if statements you would have something that would look like a state machine. The finite part implies that there is only a finite number of states and that the entire behavior of the system can be determined and therefore validated. Writing the states and their transitions like a flow chart can make it easier to locate undefined states. If you have every written source code I am sure you know how easy it is to miss a condition in a if statement of a while loop. This kind of state validation is especially important for control systems because undefined states can cause really nasty problems.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf