# State diagram, state table, etc.

1. Jan 28, 2010

### disclaimer

1. The problem statement, all variables and given/known data

Hi everyone;

I've got a problem to solve that involves three containers which should be filled with sand, each of them has a sensor attached at the same level, so if the amount of sand drops below that limit, it will be refilled. If all were empty, the refilling arm would first go to 1, then 2, and finally 3. Something like this:

2. Relevant equations
No equations.

3. The attempt at a solution

I'm not sure how many states are needed, I'm guessing at least 3 (probably 4: 1st empty, 2nd empty, 3rd empty, all full). Could anyone help me make a state table or state diagram to get things going? Also, would I be better off using a Moore or Mealy model? Anyone know of good resources dealing with similar problems? Help greatly appreciated.

2. Jan 28, 2010

### Staff: Mentor

Start with a truth table. There are 3 bins that can be empty (0) or full (1). Set up a counting on the left of the truth table -- how many lines does that give you? That tells you how many states you will have in your state diagram (well, unless you have a Reset state, but you probably won't in this problem).

http://en.wikipedia.org/wiki/State_machine

.

3. Jan 28, 2010

### disclaimer

Thanks, maybe I wasn't too precise, the bins don't have to be filled in one cycle. One cycle involves refilling only one bin which narrows the amount of possible states down to 4 I guess. After refilling, the arm returns to the initial state and so on. There would have to be 4 outputs, converting to binary:

00 - no action, stay in initial state
01 - refill 1st
10 - refill 2nd
11 - refill 3rd

Is that correct?

4. Jan 28, 2010

### mistermath

How much information do you need to keep about your states? For example, one "state" can be 1 - full, 2 needs refill, 3 needs refill, filler is over bin 2. Is that a separate "state" as opposed to filler over bin 3.. what about both 2/3 needing refills, is that a separate state?

5. Jan 28, 2010

### disclaimer

I know what you mean, but that is not the case here. We don't have "general" states representing the signals from all the sensors at a time, each of them is treated seperately as a state. So state 1 - 1st is empty, state 2 - 2nd empty and so on.

6. Jan 30, 2010

### disclaimer

Is it possible that all states always reduce to one, no matter if I assume 4 or 8? Either I'm doing something wrong here or I don't know why. Can anyone help? Thanks.

7. Jan 30, 2010

### MarcMTL

You can't reduce to one state. I don't even think it'd be considered a state machine at that point.

Here's some pointers: You'll need to make a mealy machine, as the next state depends on the current state AND the inputs (sand level for each bin). Don't forget, you'll probably have a "get more sand" state, which will be called upon in between the filling of the containers.

Simply draw the problem out. Start at the initial state, and branch off from there. What happens if you get a call for more sand? What if you're currently filling the first OR second container and the third one asks for sand?

You should be able to simplify it down to 8 states; 4 seems insufficient.

8. Jan 31, 2010

### disclaimer

I guess the possible inputs have to be:

$$\bar{X}\bar{Y}\bar{Z}$$ 000

$$\bar{X}\bar{Y}Z$$ 001

$$\bar{X}YZ$$ 011

$$\bar{X}Y\bar{Z}$$ 010

$$XY\bar{Z}$$ 110

$$XYZ$$ 111

$$X\bar{Y}Z$$ 101

$$X\bar{Y}\bar{Z}$$ 100

Thank you. Can't I just assume 5 states then?

A - all full
B - get sand
C - 1st full (entry action: refill)
D - 2nd full (entry action: refill)
E - 3rd full (entry action: refill)

Just a general sketch:

Is that possible? In such a case the states probably won't reduce to one because of the intermediate state.

EDIT: I suppose adding the "get sand" state requires one more output. I can't possibly have the same input/output combinations branching off to two different states. That just wouldn't make sense at all. Also some kind of output has to tell the system to take some sand first before refilling any of the containers. Whenever I start to think that I'm already there, something always pops up and makes my great theory fall into shambles...

Last edited: Jan 31, 2010