Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

State machine problem

Status
Not open for further replies.

johnchau123

Member level 1
Joined
Apr 15, 2006
Messages
40
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Location
Hong Kong
Activity points
1,685
I have some confusions about state machine.
Let take an example.

Suppose I have a very calculator in which I can enter a menu to select functions. I can select calculation modes from modes A to E from menu. If I have to select mode A, I have to press the bottom MENU for once, and for mode E, I have to press MENU for five times. After selecting the mode, I have to press the button CALCULATION to start calculator. The calculation algorithm for different modes are different. So, I propose the state machine is as follows.

S0-------->S1-------->S2-------->S3-------->S4-------->S5
.................|................|..............|..............|...............|
.................|................|..............|..............|...............|
.................-->S6.........-->S7.......-->S8.......-->S9.......-->S10

The dots can be ignored. Sorry for my poor representation.

S0-->S1: triggered by pressing MENU for once
S1-->S2: triggered by pressing MENU for once
....
S4-->S5: triggered by pressing MENU for once
S1-->S6: triggered by pressing CALCULATION for once, and start calculation
S2-->S7: triggered by pressing CALCULATION for once, and start calculation
....
S5-->S10: triggered by pressing CALCULATION for once, and start calculation

That starting point and the end of the program is ignored in this case.

So, I would like to ask is my state machine correct?
If not, what's wrong and could you give me some suggestions??

Thanks all!!
John :)
 

I think you lack just one thing:
All states S6 to S10 go back to S0 when calculation done
 

Thanks mcs51mc.

So, if my state machine has included the return path, it will be correct as one of my friends claim that not so state machines should be included but he did not tell me the reasons behind.

Thanks in advance. :)
 

If your friend ment that a state machine isn't needed for such application I agree with him.

Just put a counter on the "Menu" key.
Pay attention to maximum value of the counter. What if counter equals 5 and "Menu" key is pressed again?
That possibilty isn't included in your state machine also :(

When "Calculation" is pressed jump to a subroutine according to the value of the counter.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top