Finite state machine development.

Go To Last Post
128 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

skeeve wrote:

Methinks I see a bug:

A process can go from Blocked to Suspended, but not the other way around.

That could be deliberate.

FreeRTOS might require that the "owner" of a suspended process deal with blocking.

If so, that should be stated.

 

The task may be Suspended by a separate task making the API call, or it may suspend itself, in which case it's in limbo until another task Resumes it, 

 

Blocked state is implicit by requesting access to a resource that can't be satisfied immediately, e.g. semaphore, mutex, queue. A task can't be Blocked in any other way, e.g. by another task. So the task may be Blocked (waiting for a resource) and then Suspended by a separate task. 

 

To go from Suspended to Blocked, the task must execute at least one API call, which then blocks. i.e. it has to go via the Running state. Suspended->(Resumed)->Running->Blocked

 

The Blocked state can timeout but the Suspended state cannot.

 

I wish I could have worded that better !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

obdevel wrote:

Then use one of the examples given that represents a real-world device you're familiar with, e.g. traffic light, elevator, turnstile, rather than something abstract or invisible.

Exactly I did this post 84. I don't think there can be anything more simple than LED and switch button  I created state diagram for real project. After that I was trying to create a process state diagram in which I did not understand anything. 

 

Last Edited: Fri. Aug 21, 2020 - 07:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But I am not able to imaging process state diagram with any real project.

 My request  was to help me how you can understand process state diagram

 

That question was answered in #48...go back and take a look.  You can always let someone else do the state machiens, if it is a big issue...there are many areas to get involved with, such as graphics rendering, or  numerical methods,!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Fri. Aug 21, 2020 - 07:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Djsarkar wrote:

avrcandies wrote:

You don't seem interested at all in any help offered, do you go through #86 or other examples?

 

There is no doubt that you have given a great answer. I not saying now how to make a state diagram because I understand how to create

 

My question was how to understand the process state diagram with a real example. I have read all the states in the process state diagram and I understand it But I am not able to imaging process state diagram with any real project.

 My request  was to help me how you can understand process state diagram by comparing it with a real embedded project.

 

 

 

Actually here (https://www.state-machine.com/doc/AN_PELICAN.pdf) is a real world example of using the FSM (actually this is something that obdevel was also mentioning in his post - a traffic light?) - something I was referring to back in my original post (#2 I believe it was), something you may have missed to look at perhaps? 

Ilya

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

shtirka wrote:
Actually here (https://www.state-machine.com/doc/AN_PELICAN.pdf) is a real world example of using the FSM

Hmm -That PDF is mostly concerned with explaining the "state-machines.com" framework as opposed to emplaning the concepts. It definitely assumes some prior knowledge and is probably not particularly useful

 

Interestingly - it references the article I linked to in #91: https://www.drdobbs.com/architecture-and-design/uml-statecharts-at-1099/188101799

We seem to be going round in circles.

 

@OP There are no quick answers or magic bullets available; after over 100 posts you should have already realised that. A serious investment of learning time is required by yourself. Pick one of the various resources mentioned in the previous posts, read it thoroughly and have a go at writing some code. We freaks will always help if you get stuck coding.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:

shtirka wrote:
Actually here (https://www.state-machine.com/doc/AN_PELICAN.pdf) is a real world example of using the FSM

Hmm -That PDF is mostly concerned with explaining the "state-machines.com" framework as opposed to emplaning the concepts. It definitely assumes some prior knowledge and is probably not particularly useful

 

Interestingly - it references the article I linked to in #91: https://www.drdobbs.com/architecture-and-design/uml-statecharts-at-1099/188101799

We seem to be going round in circles.

 

@OP There are no quick answers or magic bullets available; after over 100 posts you should have already realised that. A serious investment of learning time is required by yourself. Pick one of the various resources mentioned in the previous posts, read it thoroughly and have a go at writing some code. We freaks will always help if you get stuck coding.

 

I will certainly grant that the app note is framework specific in its nature - however the app note section of the state-machine.com also has the application note called A crash course in UML State machines which actually isnt framework specific. But like many others, was actually a little off as to what the OP wants and actually knows so didnt think of it immediately

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Traffic lights control system

 

I have taken idea from below video h https//www.google.com/url?sa=t&source=w...https://m.youtube.com/watch%3Fv%...

 

Say, for example, we have a four-way intersection 

A simple  traffic light consists of a red, amber, and green light. The typical sequence is as follows:

  1. Green (safe to proceed)
  2. Amber (slow down, red light soon)
  3. Red (stop)

Let’s assume that  green traffic light on for 12 seconds and Amber for 3 seconds and Red on for 12 second's

 

I have created state diagram for Traffic lights control system

 

 

 

 

I hope it demonstrates the state diagram for 

Traffic lights control system

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Apart from the fact that in some countries the sequence is "red, red/amber, green, amber" the fact is that your diagram above appears to have too many states for a system that is simply cycling "green, amber, red" ?!? Your diagram appears to show four identical cycles of the same thing??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Apart from the fact that in some countries the sequence is "red, red/amber, green, amber" the fact is that your diagram above appears to have too many states for a system that is simply cycling "green, amber, red" ?!? Your diagram appears to show four identical cycles of the same thing??

 

Thank you for quick help As you suggested I have done few changes

 

 

If my this diagram is correct, can anyone help me to creates the process state diagram

Last Edited: Mon. Aug 24, 2020 - 09:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


 

 

I simply typed "UK traffic light state diagram" into Google Image search and got many results:

 

https://www.google.co.uk/search?q=uk+traffic+light+state+diagram&sxsrf=ALeKk01Y6Z3Pyq3CrcWZo3JrdETknNTwsw:1598262110418&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjGwOWqxrPrAhUFuHEKHdvsDKkQ_AUoAXoECA0QAw&biw=1718&bih=1319

 

Some are relevant, some aren't. One of the simplest is:

 

 

That immediately tells me (as I suspected when I typed " red, red/amber, green, amber" above!) that there are 4 states for UK lights. In some countries it is even simpler:

 

 

In this case there are only 3 states. That is why I'm a bit surprised by your diagram showing TWELVE states !!

 

 

 

Last Edited: Mon. Aug 24, 2020 - 09:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think your states should be defined as:

    State 1   Green 1 ON, RED2 ON, RED 3 ON, RED 4 ON, all others OFF (12 seconds)

    State 2   Amber 1 ON, RED2 ON, RED 3 ON, RED 4 ON, all others OFF (3 seconds)

    State 3   Green 2 ON, RED1 ON, RED 3 ON, RED 4 ON, all others OFF (12 seconds)

    State 4   Amber 2 ON, RED1 ON, RED 3 ON, RED 4 ON, all others OFF (3 seconds)

    State 5   Green 3 ON, RED1 ON, RED 2 ON, RED 4 ON, all others OFF (12 seconds)

    State 6   Amber 3 ON, RED1 ON, RED 2 ON, RED 4 ON, all others OFF (3 seconds)

    State 7   Green 4 ON, RED1 ON, RED 2 ON, RED 3 ON, all others OFF (12 seconds)

    State 8   Amber 4 ON, RED1 ON, RED 2 ON, RED 3 ON, all others OFF (3 seconds)

 

So each of the four directions gets 12 seconds of GREEN for every 60 seconds

 

Edit: typo

Edit2: Obviously, the above is not UK format

Edit3: Possibly UK format:

    State 1   Green 1 ON, RED2 ON, RED 3 ON, RED 4 ON, all others OFF (12 seconds)

    State 2   Amber 1 ON, RED2 ON, RED 3 ON, RED 4 ON, AMBER 2 ON, all others OFF (3 seconds)

    State 3   Green 2 ON, RED1 ON, RED 3 ON, RED 4 ON, all others OFF (12 seconds)

    State 4   Amber 2 ON, RED1 ON, RED 3 ON, RED 4 ON, AMBER 3 ON, all others OFF (3 seconds)

    State 5   Green 3 ON, RED1 ON, RED 2 ON, RED 4 ON, all others OFF (12 seconds)

    State 6   Amber 3 ON, RED1 ON, RED 2 ON, RED 4 ON, AMBER 4 ON, all others OFF (3 seconds)

    State 7   Green 4 ON, RED1 ON, RED 2 ON, RED 3 ON, all others OFF (12 seconds)

    State 8   Amber 4 ON, RED1 ON, RED 2 ON, RED 3 ON, AMBER 1 ON, all others OFF (3 seconds)

 

 

 

David

Last Edited: Mon. Aug 24, 2020 - 10:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh I missed the fact that this was four sets of lights. Ignore previous comments.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
In this case there are only 3 states. That is why I'm a bit surprised by your diagram showing TWELVE states !!

 

Djsarkar  has drawn (yet another) diagram showing a 4-way intersection with round-robin type sequencing. So the high level hierarchical states are:

 

  1. North can drive all others stop.
  2. East can drive all others stop.
  3. South can drive all others stop.
  4. West can drive all others stop.

 

Within each of those super states; depending on the country/continent; there are 3 or 4 light aspects (to use a railway term).

 

BTW: I think the hierarchical state machine concept introduced in my #91 and shtirka's #105 via state-machine.com is brilliant. It can really help reduce complexity

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:

 

Djsarkar  has drawn (yet another) diagram showing a 4-way intersection with round-robin type sequencing. So the high level hierarchical states are:

 

  1. North can drive all others stop.
  2. East can drive all others stop.
  3. South can drive all others stop.
  4. West can drive all others stop.

 

Within each of those super states; depending on the country/continent; there are 3 or 4 light aspects (to use a railway term).

I am  happy that  you have considered it a state diagram.

 

As said to create a state diagram for the traffic control system that I have created

 

Now Can anyone give me an example to understand a state process diagram as gave an example of traffic light system to understand the state diagram?

 

 

Last Edited: Mon. Aug 24, 2020 - 02:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


But the diagram is still wrong isn't it? If there are four sets of lights then they should be in pairs and all four should change state at the same time shouldn't the? Using google image search I found this for a 4 way junction with lights and the "ticks" are added by me to show what state the lights are in at one time:

 

 

So the East/West lights mimic each other and both green at the same time and while they are green the North/South lights are both the same at Red.

 

So the entire system still only has 3 or 4 states (depending on how the lights cycle in a given country) and the North-South act as a matched pair while the East-West act as another matched pair and the NS are "opposite" to EW

 

While you can add the compilcation of "turn filters" where there's an intermediate phase for the "difficult turn" (right in UK, left in US/Europe) to cross paths your own suggestion of North only then East only then South only then West only does not really reflect "normality" does it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, the event source that controls the machine state is, in the simplest model, just a single timer, and the machine rotates through a repeating pattern.

 

Clearly, it gets more complex once you introduce pedestrians, different timer priorities (such as rush hour) or vehicle detection.

 

Elevators/lifts are similar. Relatively simple in concept but things like mechanical safety interlocks tend to complicate matters.

 

Sometimes these requirements can be bolted on afterwards, sometimes you wish you'd considered everything at the outset ;)

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
If there are four sets of lights then they should be in pairs

Not for round-robin where only one set of the four goes green at a time. It works well for junctions where a significant number of vehicles need to turn. The scheme avoids the junction becoming blocked by vehicles wanting to turn right (UK) and having to wait for a gap.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I was living in Jeddah, only one of the 4 entry points to a 4 way intersection was allowed to move at any one time. You couldn't trust the drivers supposedly going where you had just come from.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:

When I was living in Jeddah, only one of the 4 entry points to a 4 way intersection was allowed to move at any one time. You couldn't trust the drivers supposedly going where you had just come from.

 

I lived in Riyadh for a couple of years. Sounds very familiar. Along with 5 lanes of traffic on a 3-lane street, or turning left from the right-most lane, etc ...

 

You must have been very brave; we had a driver.

 

Parties at the Australian embassy were good fun. On the BBQ were lamb, chicken and 'special chicken', and enough alcohol to fill many diplomatic bags. As long as you could make it from the embassy front door to your car without falling face down in the gutter you were ok.

 

Systems engineering as a discipline is very different when money is no object.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now Can anyone give me an example to understand a state process diagram as gave an example of traffic light system to understand the state diagram?

What does that jibberish mean--nothing?   Why would you need more examples, plenty have been described.  After 120 posts, you seem to be going nowhere with all of this...maybe go back and start with the first reply--all the info you need has already been described several times. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Now Can anyone give me an example to understand a state process diagram as gave an example of traffic light system to understand the state diagram?

What does that jibberish mean--nothing?   Why would you need more examples, plenty have been described.  After 120 posts, you seem to be going nowhere with all of this...maybe go back and start with the first reply--all the info you need has already been described several times. 

 

Now I want to create a process state diagram.

 

Task list

 

1) Monitor for fire
2) Monitor for room temperature range
3) Monitor for object detection
4) Start motor , wait, stop motor

 

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

 

Event : When proximity sensor is high, stop motor

 

Event : When fire sensor detects fire , stop motor

 

Event : When room temperature is high than set temperature, stop motor

 

Is the example  taken by me is suitable to create the process state diagram?

 

I have idea to create state diagram but don't have idea how to create process state diagram for real project

 

 

Last Edited: Mon. Aug 24, 2020 - 05:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So the East/West lights mimic each other and both green...

Unless, as is common here, only one of the four directions is activated (rather than pairs) so that turning traffic has a chance...

 

Of course, these are ALL over-simplified examples, unless we are ready to consider turn lane occupancy sensors, time of day preferences for certain traffic directions, pedestrian crossing, etc.

 

(Is this horse dead yet?)

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have idea to create state diagram but don't have idea how to create process state diagram for real project

Now you are just posting complete nonsense statements ...plenty of examples are given...go back and take a good look.

 

When leaving either motor state (or equivalently, for this chart, entering either motor state), reset the timer to zero

Or you can define the timer itself to form some states, the choices are yours. 

motor_off_state--->timer_reset_state_A---->motor_on_state

 

motor_on_state--->timer_reset_state_B---->motor_off_state

 

A & B can be separate sttates  (easy), or they can be one state (timer_reset_state), since the next destination can

 be determined by whether the motor is already on or off.  YOU get to choose all of your states, you could have as many as you want.  

 

If you list the steps to make  pizza...you can list 5 steps, or 75 steps ...you get to choose.  States are a compact way of logically summarizing & organizing your steps. YOU control that organization.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Aug 24, 2020 - 07:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

I have idea to create state diagram but don't have idea how to create process state diagram for real project

Now you are just posting complete nonsense statements ...plenty of examples are given...go back and take a good look.

 

When leaving either motor state (or equivalently, for this chart, entering either motor state), reset the timer to zero

Or you can define the timer itself to form some states, the choices are yours. 

motor_off_state--->timer_reset_state_A---->motor_on_state

 

motor_on_state--->timer_reset_state_B---->motor_off_state

 

A & B can be separate sttates  (easy), or they can be one state (timer_reset_state), since the next destination can

 be determined by whether the motor is already on or off.  YOU get to choose all of your states, you could have as many as you want.  

 

If you list the steps to make  pizza...you can list 5 steps, or 75 steps ...you get to choose.  States are a compact way of logically summarizing & organizing your steps. YOU control that organization.

 

Dear avrcandies I have read all posts from beginning to end many times But I have not seen anyone mentioning the state of running, ready, suspended and blocked anywhere. Even I haven't seen these four state in your previous and last post.

 

Maybe this is my last post in this thread because  I don't really understand how to make process state diagram for motor project. 

 

When I am trying to make a state process diagram for the motor project I see only four states (ready, running, suspended and blocked) after that I do not understand what to do.

 

 

To mod: Please lock this thread. If you think that enough information has been given to make the process state diagram,.

 

Thanks everybody for help me. I apologize if I could not understand even after convincing me a lot

Last Edited: Mon. Aug 24, 2020 - 09:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But I have not seen anyone mentioning the state of running, ready, suspended and blocked anywhere

SO WHAT?  I haven't seen anyone mention jumping, sleeping, or clapping...YOU define the states you want for your desired modes (states) related to the needed conditions & app to be implemented.  You define what conditions take you from one mode/step to the next.   So you have no idea what conditions you want to require to move from the ready state to the running state (inset one dollar, wait for a -20 blizzard, voltage>108 V,  2minutes elapsed,  etc)?  You have not even bothered to really define/describe what your states are.  Blocked??? what kind of motor or system mode is that? Suspended?? Why use names that give zero meaning to the problem at hand?

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We were in Jeddah for 5 years ('82 to '87). Our wives shared a TCN driver for shopping. I drove myself. We only had an Aussie consulate, but it was also suitably "watered". I preferred the Swiss Consulate parties. My dive buddy was connected.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Djsarkar wrote:
To mod: Please lock this thread
Your wish is my command.

Pages

Topic locked