This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Configurable Finite state Machine need help

Hai All,

I am Implementing finate state machine and approach is as follows:

enum FSM_GATE_STATES
{
 GateOpen=0,
 GateClose
...
...
};
struct FSM_Gate
{
        enum FSM_GATE_STATES ActiveState;
};
struct FSM_Gate m_FSM_Gate;
void main()
{
  m_FSM_Gate.ActiveState=Gopen;
switch(m_FSM_Gate.ActiveState)
{
 Case GateOpen:
    if(gateOpen_Gateclose())
    {
       m_FSM_Gate.ActiveState=GateClose;
    }
  else
 {
  //generate out put
  }
 break;
Case GateClose:
//similar implementation
break;
...
..
}
}
bit gateOpen_Gateclose()
{
 if(inputTable[1]&&inputTable[2]....n)/*inputs from the field*/
 {
   return 1;
 }
 else
{
 return 0;
}
}

This my approach of FSM...
Since the FSM is as single program..I am having 19 states and 38 transition conditions...It is very hard to maintain it as configurable...

Is there any other efficient approach...
I need to place the transition conditions in EEPROM give me suggestions...
In this program transition condition is like function
that is
bit gateOpen_gateClose
{ if(inputTable[]....) { return 1; } else { return 0; }
}

I want to make transition as configurable data.....
can this function changed in to boolean expresssions???? and stored in EEPROM..Or How to place a function in external EEPROM any linking should be done???..Kindly give me suggestion....

  • Since the FSM is as single program..I am having 19 states and 38 transition conditions...It is very hard to maintain it as configurable...

    I do not know if this will help, but in a few cases I have used this technique (which, by the way, speed up the processing)
    #define GROUP_MASK 0xf0
    #define group0 0
    #define group1 0x10
    ....
    #define statea (grupup0 + 0)
    #define stateb (grupup0 + 1)
    #define stateq (grupup1 + 0)

    switch (state & GROUP_MASK)
    case group0
    ProcessGroup0();
    ....

    ProcessGroup0
    switch (state & ~GROUP_MASK)

    erik

  • The 8051 architecture has a separate memory space for executable code - called CODE space. There is no write access to CODE space.

    The only way you can add functions is by reprogramming your CODE memory.

    If you want something with runtime loadable code, you need an architecture other than 8051.

    If you want your code to be table-driven, that will require the use of Function Pointers - which will require that you thoroughly understand the issues in using them on an 8051. Again, you may well be better off choosing another architecture.

    www.keil.com/.../search.asp

  • OK, so you might be able to pull some cunning tricks with IAP (In-Application Programming) - but is it worth it?