Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/26/04 02:09
Read: times


 
Msg Score: +2
 +2 Good Answer/Helpful
#83870 - State machines
Responding to: ???'s previous message

State machines are a method of implementing sequential logic.

We normally have a variable called the 'state'. This is normally initialised to 0. So state 0 is our first state.

The state value tells us where we are now.
We implement conditions to determine the next state also known as 'the transition'.

When we call the code known as the 'state machine' this is called 'clocking' the state machine. Your processor is a good example of a state machine - it reads instructions which determine what it does now and does next.


Put simply, each state is a step in the process you want to achieve.


In 'c' it would look something like this

my_fsm()
{
static char my_state = 0; //the 'state' variable

switch(my_state)
{
case 0: //state 0
setb LED;
my_state = 1;
break;
case 1: //state 1
clrb LED;
my_state = 2;
break;
case 2: //state 2
if (P1^1 == 1) my_state = 0;
break;
}
}

If this piece of code was called once per second, the led would flash and keep flashing only if P1.1 was high.

You could have a state machine for each input bit if you wished and you would call each of these state machines every second or what ever time you wanted. You would use the timer to do this.











List of 5 messages in thread
TopicAuthorDate
State Machine ?            01/01/70 00:00      
   state machine            01/01/70 00:00      
      Question continued            01/01/70 00:00      
   finite automa            01/01/70 00:00      
      State machines            01/01/70 00:00      

Back to Subject List