Quote
Not clear on what you are trying to do here. Is this supposed to be a loop? Or are you placing this SWITCH statement inside of a loop that's not visible in these examples?
Yes in a loop. Sorry for incomplete examples just trying to explain the concept of what I wanted to do. (English isn't my native language either so having a hard time explaining).
This is a good example of a state machine design:
http://m.eet.com/media/1174905/f-gomez.pdf
And I want to use a tecnique like this to implement my robot programs. As this is what I am used to compared to flowcharts. The Case switch would be an easy approach if there isn't any disadvantages having the robot program inside a case statement inside a loop.
The question in short is- I want to place my robot program inside a case statement inside a loop when certain transition conditions are met I change my state and execute another "choice" in the case. Are there any disadvantages to this approach?
So if there isn't any disadvantages doing something like my example for an easy state machine I would be glad.
The state machine should always be executed until the program is done, the state machine could call subprogram containing state machines in them as well.
A little better Example of code: (Please disregard syntax errors and only see this as a concept example)
State = 0
Done = false
Repeat
Case state of
0:
;Go to pre POS
Ptp pre
State = 10
10
; if part detected grab it
If part_detected then
Grab_part()
State = 20
Else
;All parts taken do something before done
Do_something()
State = 100
End if
........
........
100:
; Program done
Done = true
End switch
Until done
Display More
Hope this clears things up a bit if not I should do a complete example with state diagram and code to show clearly what I mean.