Three state diagram.

JohnInTX

Joined Jun 26, 2012
4,787
I hope this describe the behavior of the system
Me too:)
From #38:
Exercise : Complete each tasks as per their priorities
Task list
1) Monitor for fire- Priority 1
2) Monitor for fault- Priority 2
3) Start motor , wait, stop motor - Priority 3
4) Monitor for room temperature range- Priority 4

Ideal state: Motor start for 1000ms and Motor stop for 1000 ms. repeat process

Event : When fire sensor detects fire in room , Stop motor

Event : When proximity sensor detects any objects, stop motor

Event : When room temperature is high than set temperature, stop motor
If the system is in the TEMPERATURE HIGH (center right) state because of a high temperature reading, what happens if the FIRE sensor activates? You indicated that FIRE had a higher priority than HIGH TEMPERATURE.

On a separate topic:
It would be helpful to number the states to be able to discuss them easier.
Please consider dropping your camera resolution to something less than 3.5MB per snap. Gigantic pictures make it difficult to edit the diagram and post fixes.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
If the system is in the TEMPERATURE HIGH (center right) state because of a high temperature reading, what happens if the FIRE sensor activates? You indicated that FIRE had a higher priority than HIGH TEMPERATURE..
My idea was that there is one motor in industrial machine that goes on/off for every 1000 milliseconds.

The motor can stop only when there is a fire detected in the room or when the temperature of the room is higher than the set temperature of machine or when the fault has been generated in machine.

The temperature of the room does not change suddenly while fires can happen at any time, That why I set fire sensor for high priority task. I have never worked on an industrial project so I have given priority to the task according to best of my thinking

Both are related to safety issues.but as far as I have read, both the tasks cannot run simultaneously, so we have to decide which task should be run first and which task should be run later.
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
The temperature of the room does not change suddenly while fires can happen at any time, That why I set fire sensor for high priority task. I have never worked on an industrial project so I have given priority to the task according to best of my thinking
That's good thinking but your state diagram doesn't do that. Again:
If the system is in the TEMPERATURE HIGH (center right) state because of a high temperature reading, what happens if the FIRE sensor activates?
Put your finger on that state in your drawing then say "FIRE SENSOR IS ACTIVE". Then look under your finger - do you see anything in that state that 1) watches for the FIRE sensor and 2) leaves that state to get to the FIRE DETECTION state immediately above?
No?
I don't either. That means that if your system detects TEMPERATURE HIGH before FIRE, it will not react because it is stuck in the TEMPERATURE HIGH state until the temperature goes down. How would you fix that?
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
That's good thinking but your state diagram doesn't do that. Again:
Put your finger on that state in your drawing then say "FIRE SENSOR IS ACTIVE". Then look under your finger - do you see anything in that state that 1) watches for the FIRE sensor and 2) leaves that state to get to the FIRE DETECTION state immediately above?
No?
I think below will be the best design

Task list & priorities

1)Start motor , wait, stop motor - Priority 1
2) Monitor for fire- Priority 2
3) Monitor for fault- Priority 3
4) Monitor for room temperature range- Priority 4

State diagram

Motor PROJECT.JPG
 

JohnInTX

Joined Jun 26, 2012
4,787
*sigh*
You've redrawn the diagram but are still missing the logic error(s) I pointed out above. For example, if you are in the Fault State and the FIRE sensor activates, it will not be recognized until Fault OFF. Same with the Low Temp state; a Fault or Fire won't be recognized until the Low Temp state clears. The same is true for the other exception conditions as you go up the drawing.

In the EXAMPLE drawing and text of #35, I described the essentials of a state diagram. This one does not incorporate those essentials. The entry edges to a state do not agree with the 'While' conditions e.g. according to the diagram, the Low Temp state is entered when the 1000ms timer runs out but it waits for the Low Temp condition to clear. I understand what you meant but that's not what you drew. Also, the exit edged from the states on the left have no labels.

How does one know why the state exited? Again, I think I know but that's not what the drawing says. The problem with not fully specifying each transition is that you miss logic errors like I've described.

Do you see the dotted lines in the EXAMPLE saying that the conditions that got the system to the state (the label on the incoming arrow) have to be consistent with the conditions to stay in the state (the circular arrow back to the state)? This drawing is missing that and it's led to errors. You have a HIGH TEMP signal arrow out of MOTOR ON but you are not monitoring any High Temp sensor - there is no circular arrow showing that. You can't do that.

Properly drawn, the state diagram will fully describe a system with no missing parts. If you have an accurate drawing, you will be able to see missing parts and logic errors. If you are sloppy and incomplete, you'll miss things when it's finally coded. Here's an example. See if it follows all the rules I laid out in #35. Visit EACH state and analyze how it got there and where it can go when it leaves. Be sure you understand the sequences and how the priority structure is implemented. Can it be better? Probably but you get the idea I hope. Read the notes at the bottom and convince yourself that the diagram is properly drawn.

From here, it's just how you implement the sequence you need but that's how a state diagram is drawn.
Have fun!
MotorStates2.JPG
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
From here, it's just how you implement the sequence you need but that's how a state diagram is drawn.
Have fun!
View attachment 215731
Thanks your state diagram is millions of times better than my state diagram.

I can improve my skills by practicing more I will create a state diagram by taking a new problem statement

Would it be a good example for state diagram?

1) Read the data from sensor 1 and send data to PC and get acknowledge from the PC

2) Read the data from sensor 2 and send data to PC and get acknowledge from the PC

3) Read the data from sensor 3 and send data to PC and get acknowledge from the PC

4) Read the data from sensor 4 and send data to PC and get acknowledge from the PC
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Sure! But study what I posted until you fully understand it.
I have studied your notes but I am struggling in the points given in post 50.

I am struggling in planning My idea was to create a state diagram for a small weather monitoring system. So weather system send the speed of wind, temperature, and humidity value to PC at every let say 30 microseconds.

Second conditions when Micro read sensor data and send to PC, PC should be acknowledge that it has received data otherwise give error message, fail and read the next sensor , repeat all process.

Here timing is critical. Every value should be transferred at the right time and acknowledge must be received at the right time.

So , I am having trouble creating a state diagram without having a well defined problem statement

Edit my attempt

IMG_20200827_203825.jpg
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
So , I am having trouble creating a state diagram without having a well defined problem statement
Amazing how that happens.

I don't want to scold you here but your diagram indicates that you haven't really learned the lessons that I and the others have been trying to teach you in this thread. Regardless of any questions about the logic of the problem, your diagram does not even conform to the rules for drawing a state diagram that I laid out several times above and on the state diagrams I drew for you. If you can't draw out a proposed solution to a problem in a manner that allows inspection and testing of that solution then you have no solution. Simple as that.

I would recommend that you go no further until you have reviewed the information in this thread and you fully understand how a state diagram or flow chart is drawn, what each part means, and how each part relates to some logical process. You also have to be able to trace all of the possible flow paths through all of the states with your finger or a pencil and inspect and understand the logic at each step. I pointed out several opportunities to do just that. You did not do it and so you haven't learned any of those lessons nor those from the other members that contributed to this thread.

With that, I'll stop here until you go back and learn the basics. It's pointless to proceed until then.

Good luck!
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Amazing how that happens.

I don't want to scold you here but your diagram indicates that you haven't really learned the lessons that I and the others have been trying to teach you in this thread. Regardless of any questions about the logic of the problem, your diagram does not even conform to the rules for drawing a state diagram that I laid out several times above and on the state diagrams I drew for you. If you can't draw out a proposed solution to a problem in a manner that allows inspection and testing of that solution then you have no solution.
I already informed to you that I do not have a well-defined problem statement so I cannot create a state diagram. You can see I have tried to make one problem statement but I am struggling because of lack experience in the electronic world. I thought you should not think that I am not making any efforts to learn so I posted the incomplete state diagram to show my efforts to solve problems.

Edit: I know i need a lot of practice I will try to make good problem statement. Once I will sure about it than I will draw state diagram.
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
1) Read the data from sensor 1 and send data to PC and get acknowledge from the PC

2) Read the data from sensor 2 and send data to PC and get acknowledge from the PC

3) Read the data from sensor 3 and send data to PC and get acknowledge from the PC

4) Read the data from sensor 4 and send data to PC and get acknowledge from the PC
This is a reasonable problem statement. My first thought was 4 states in a circle.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
This is a reasonable problem statement. My first thought was 4 states in a circle.
My solution

IMG_20200828_020859.jpg

I don't know how much time it would take to comple one task so I just mentioned T

edit forgot to set count down timer in state
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
Look, you have a final year project (FYP) in your future, Why not work on it?

That's the same advice my mother would have given me. I won't repeat the rest of it, but it seems to me that a motivated student would be motivated to complete the FYP!
 

JohnInTX

Joined Jun 26, 2012
4,787
+1 Working on FYP is not a bad idea. But if TS is having trouble with the basics those need to be worked on preferably in something simple IMHO.
But whatever TS is comfortable with should work.

For the task at hand, after sending a sensor reading to the PC you have to wait for an ACK. The diagram does not do that.
 

jpanhalt

Joined Jan 18, 2008
11,087
+1 Working on FYP is not a bad idea. But if TS is having trouble with the basics those need to be worked on preferably in something simple IMHO.
But whatever TS is comfortable with should work.

For the task at hand, after sending a sensor reading to the PC you have to wait for an ACK. The diagram does not do that.
I am assuming the FYP is more defined. Of course, that depends on the professor.
 

jpanhalt

Joined Jan 18, 2008
11,087
I had given three ideas to my teacher but she did not like my ideas, so she told me to read the research papers again to find new ideas.

We have schools and colleges still closed due to covid-19 and anyway there is 1 year time to complete the project. The project of any one has not been approved yet. Everyone has been asked to read the research paper.
Please give us a link to those papers and briefly describe the ideas you told your teacher (or professor?). Maybe we can help formulate a more acceptable problem.

BTW, To me, a teacher is usually in instructor for grades K -12 (12th grade = 18 years old in the US). A professor is an instructor at a college or university (student age 18 to anything). There are several ranks to consider, any one of which may be called professor when speaking in the third person. Face to face, "Professor" or another honorific may be used. Are you in high school or college/university?
 
Top