Creating Process state diagram.

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
Hi, the main purpose of asking this question to understand the process state diagram with real example . I have seen many process diagram with no real example. The explanation given only to understand the state

OK, I am assuming example, switch button is connected to the input of micro and LED is connected to output of side of micro

System has to perform two tasks

1) Flash LED every 1 second's

2) Check button, if user press button turn off flashing LED

I have created state diagram for system.

IMG_20200815_104357.jpg

I am having serious difficulty to work with process state diagram with my state diagram. You can see that I have created a state in the process state diagram but have not connected any state to another state. Because I do not understand how a process state diagram will be made for my system.

This has become a puzzle for me, I have been trying to understand this for a long time. How to convert state diagram into process diagram?
 
Last edited:

hexreader

Joined Apr 16, 2011
536
In the top diagram, if you are in right hand "LED OFF" state, button-not-pressed has two options at the same time. There should be an arrow to one of the other states, not both.
 

Papabravo

Joined Feb 24, 2006
16,523
The solution is not unique and there is no required similarity between the two state diagrams.
I would start with a list of tasks -- that should not be difficult, but don't forget to allow for an "Idle" task that does nothing.
Next I would make a list of events.
Once you have those two lists the path forward should have some clarity.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
I would start with a list of tasks -- that should not be difficult,
I have two tasks

1) Flash LED every 1 second's

2) Check button, if user press button turn off flashing LED

but don't forget to allow for an "Idle" task that does nothing.
ln ideal state LED should be turn off

Next I would make a list of events.
Once you have those two lists the path forward should have some clarity.
External event activate when user press switch button

I think the simplest example is LED and switch
 

Papabravo

Joined Feb 24, 2006
16,523
Each of the tasks can be in one of the four states at any instant of time.
If there is nothing to do, then the idle task is in the running state and the other tasks are in the suspended or blocked state.
When there is an event, one of the tasks that is blocked or suspended becomes Ready to Run
When the scheduler runs it sees there is a task that is ready to run, so it suspends the Idle task and makes the Ready to Run task the Running task.
That task will run to completion and suspend itself or maybe it is prempted, and moved to Ready to run, by a higher priority task

Because you have an asynchronous event, the button press, the order and sequence is not deterministic.

Like I said, the result is neither unique or deterministic.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
I would start with a list of tasks --
@Papabravo Is the list of tasks below suitable to understand state process diagram?

1) Monitor fire sensor : When sensor detects fire, gives the alarm

2) Monitor Door : When some will press button of door bell, Open the door

3) Monitor room temperature : Turn on the Fan when room temperature is high then set temperature.

4) Monitor water tank : Fill the water tank , When water will over flow give the alarm and turn off motor.
 
Last edited:

hexreader

Joined Apr 16, 2011
536
None of the above...

Four forums and hundreds of posts - where the favoured example is given as traffic lights for crossroads with pedestrian countdown.

I think you were even given the state diagram for traffic lights - I forget which post or which forum - there have been so many.
 

jpanhalt

Joined Jan 18, 2008
11,088
My advice before and for the present is to set up a real chip and/or simulator. Test your program. Step through it with a push button stimulus. You will see the problems. Actually, you don't need a chip or a simulator. Step through what you draw in your mind and think of the options.

If we keep providing answers, you will see that the answer works, but your next question will meet the same end. Remember the question I posed to you that involved Gray code (i.e., only one state change per step). You promised to give more thought to your next question. Let's do that. Show us where the errors are.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
None of the above...

Four forums and hundreds of posts - where the favoured example is given as traffic lights for crossroads with pedestrian countdown.

I think you were even given the state diagram for traffic lights - I forget which post or which forum - there have been so many.
I asked this question before only on a one forum But I did not get a satisfactory answer there. My question was for the process state diagram and not the traffic light system.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
My advice before and for the present is to set up a real chip and/or simulator. Test your program. Step through it with a push button stimulus. You will see the problems. Actually, you don't need a chip or a simulator. Step through what you draw in your mind and think of the options.

If we keep providing answers, you will see that the answer works, but your next question will meet the same end. Remember the question I posed to you that involved Gray code (i.e., only one state change per step). You promised to give more thought to your next question. Let's do that. Show us where the errors are.
I know that you gave an advice before to work on a real hardware. That's why I asked questions related to process diagram that needs to be understood purpose before coding.

My question was how can a process state diagram be made for real project

I bought board but it was my bad luck it's not working. I just ordered the development board I am waiting for board I will get in next 4-5 working days

When I will have a board I will definitely learn by coding.
 
Last edited:

hexreader

Joined Apr 16, 2011
536
I just ordered the development board I am waiting for board I will get in next 4-5 working days
That is great news. What board is on order? - what MCU is fitted?

.... sorry I was a bit mean earlier - will try hard to be nicer.

Those 4 examples are too simple to justify state diagrams in my opinion, but might be great projects to get started using your new development board.
 

hexreader

Joined Apr 16, 2011
536
Pity - I do not have that MCU - may not be able to help much, at least until I am able to buy that chip.

Others will no doubt assist - especially on AVR Freaks forum.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
None of the above...
@hexreader Can you give the list of tasks that helps to understand state process diagram because as you said, mine is not suitable that's why I am asking you. You haven't even cleared yet why it's not suitable?

Maybe if you give some example, I will be able to understand my task list and your task list by comparing what is wrong with my task list
 

jpanhalt

Joined Jan 18, 2008
11,088
I asked this question before only on a one forum But I did not get a satisfactory answer there. My question was for the process state diagram and not the traffic light system.
You've been given the answer in terms of what's wrong with your diagram. The states and processes are ambiguous. That is, they are not deterministic. Another word for that is "predetermined." Since you haven't said clearly what you want to do, even if someone here were inclined to do it for you, we couldn't.
I know that you gave an advice before to work on a real hardware. That's why I asked questions related to process diagram that needs to be understood purpose before coding.

My question was how can a process state diagram be made for real project

I bought board but it was my bad luck it's not working. I just ordered the development board I am waiting for board I will get in next 4-5 working days

When I will have a board I will definitely learn by coding.
Note, I also said you could do it without any hardware or simulator, "Actually, you don't need a chip or a simulator. Step through what you draw in your mind and think of the options. "
Despite people giving that advice to you many times, you still don't do it. What do you expect for an answer when you don''t even try to solve it yourself?

When asked what development board you were using, you gave the following:
1598174176923.png
That link is to a thread about using Flash Magic and concludes with your decision to use the PIC18F45K80. No details about the board at all. Why not? Did you think about that answer?

I'm focusing all my attention on understanding things before coding. When I understand fully I can try to write code.
You have 113 posts to date and they all have a similar refrain. But you are not doing that. You moved on from state diagrams to this subject without showing you could do a state diagram. If you can,

How about showing us your "state diagram" for what you want to do in this thread?
 

hexreader

Joined Apr 16, 2011
536
Only recent project of mine that required State Machine was Infrared Receiver for domestic TV remote control.

Used 3 states (idle, leader, receive bits), but might have been improved with more states.

I did not draw out a state diagram beforehand, but should have done.

You can draw state diagrams for projects 1 to 4 if you really, really must. It is just that a state machine is over-kill. A flow chart for each would be more appropriate in my opinion.

... but they are your projects and you seem keen, so why not implement each one and see how they go. Nothing to lose and a chance to learn.
 

jpanhalt

Joined Jan 18, 2008
11,088
We have been through flow charts, state diagrams, and now this. They all reach the same state of confusion before moving to another topic, like how to program with Flash Magic even though the TS doesn't want to get into software yet.
 

jpanhalt

Joined Jan 18, 2008
11,088
There are often multiple ways to do something. For example, one can use hardware, one can use simulation programs, or one can just use paper and think about the process. Suggesting alternatives is not giving different directives. In some cases you also wanted to know how to use hardware or even to code in C. There is always an excuse.

Anyway, it seems you write whatever (e.g., flowchart, state diagram, process state diagram) and don't go back and step through the process to find your errors. YOU need to learn to do that. Eventually, you will be given a problem that matters, and there will be no one to point out your errors. You need to learn to review your own work before you reach that point.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
417
Anyway, it seems you write whatever (e.g., flowchart, state diagram, process state diagram) and don't go back and step through the process to find your errors. YOU need to learn to do that. Eventually, you will be given a problem that matters, and there will be no one to point out your errors. You need to learn to review your own work before you reach that point.
That is the approach I am following from starting

I assume that I have a pic microcontroller proximity sensor and DC motor. DC motor run for 1 second and stop for 1 seconds. This process will repeat forever but when the sensor detects any object , motor should be stop

IMG_20200823_173221.jpg

When I trace it to paper, I don't see any error. This is similar to my first diagram but here I am using sensor and motor instead of LED and switch so no need to check debounc time

I am sure my state diagram is correct. Now your opinion, what is wrong with this state diagram?
 

hexreader

Joined Apr 16, 2011
536
Same mistake as before...
Right hand state has two arrows marked "when sensor is not active" going to two other states. Get rid of one arrow.
 
Top