#40 State Machines Part-6: What is a Hierarchical State Machine?

Поделиться
HTML-код
  • Опубликовано: 12 авг 2021
  • This lesson continues the subject of STATE MACHINES. Today you will get the first glimpse of the modern hierarchical state machines. You will learn what hierarchical state machines are and how they differ from the traditional finite state machines. You will also get an idea of how to implement state hierarchy in C and you'll see which aspects are easy and which are harder to implement. Finally, you'll port your TimeBomb application from the toy Micro-C-AO framework to the professional QP/C framework, where hierarchical state machines are fully supported.
    This lesson comes with two projects:
    - the partial implementation of state hierarchy with the uC/AO active object framework.
    - the full implementation of state hierarchy with the QP/C active object framework.
    -------
    Resources:
    Companion web page for this video course:
    www.state-machine.com/quickstart
    GitHub repository for projects for this video course:
    github.com/QuantumLeaps/moder...
    Transcript of this lesson:
    www.state-machine.com/course/...
    Music credits:
    The background music comes from:
    www.bensound.com/royalty-free...
  • НаукаНаука

Комментарии • 24

  • @StateMachineCOM
    @StateMachineCOM  Год назад +2

    NOTE: The source code, as presented in the video, might cause compilation errors with the newer MDK-ARM / uVision toolsets. This is because the underlying compiler in MDK-ARM has been changed to "Compiler-6", while the older "Compiler-5" is considered now obsolete. The updated code that compiles cleanly with "Compiler-6" is available from the companion website at:
    www.state-machine.com/video-course
    and from GitHub:
    github.com/QuantumLeaps/modern-embedded-programming-course

  • @jotabr570
    @jotabr570 2 года назад +11

    Thanks Miro, as always these lessons are valuable as gold for any embedded professional or enthusiast

  • @harshithbhat7372
    @harshithbhat7372 2 года назад +3

    Mr. Miro Samek must be named as father of Embedded Systems.
    Hats off!

  • @psykjavier
    @psykjavier 2 года назад

    Amazing you are making the embedded world more exciting..!! thank you very much for teach us the real optimal and standard implementation of state machines.

  • @MahmoudAli-sv7fj
    @MahmoudAli-sv7fj 2 года назад +1

    Great and excellent work

  • @ManikantaRaju
    @ManikantaRaju 2 года назад +3

    Have been waiting for hierarchical state machines lecture for a long time. Finally its here 😁. Thanks Miro. You are doing a great job helping the embedded developer community

    • @StateMachineCOM
      @StateMachineCOM  2 года назад +4

      Hierarchical State Machines are a deep subject and this first lesson was only an introduction. State hierarchy is very much like inheritance and therefore it comes with its own design patterns and idioms. Just think how many books have been written about these aspects of OOP (!) Hierarchical State Machines offer similarly rich semantics and just as many various aspects that are worth discussing. I'll explain some of these in the upcoming lessons. Stay tuned!

    • @ManikantaRaju
      @ManikantaRaju 2 года назад

      @@StateMachineCOM wow
      Thats very interesting to hear. I only have one complaint. Please bring the videos fast 🚴三😄

  • @t.p.2305
    @t.p.2305 2 года назад

    Thanks so much!!

  • @weizhao4664
    @weizhao4664 2 года назад

    不错不错

  • @nileshgopnarayan4464
    @nileshgopnarayan4464 Год назад +1

    Nice content looking for this since long time. Btw is there any video on interaction between state machine

    • @StateMachineCOM
      @StateMachineCOM  Год назад +1

      Yes, there are many such videos! Interacting state machines are called "Active Objects" and there is the whole playlist about those: ruclips.net/p/PLPW8O6W-1chxSKPGnPbK8kZnQQHepv47I

  • @nguyenphamhung7598
    @nguyenphamhung7598 2 года назад

    From VN with loves

  • @mrk3ma1
    @mrk3ma1 2 года назад +1

    Are you planning to explain the the QPC framework HSM_Init() and HSM_Dispatch() functions and how they are functioning in future lessons? Also your lessons are pure gold.

    • @StateMachineCOM
      @StateMachineCOM  2 года назад +2

      While I am planning to explain how to use the QP/C framework in the future, I was not actually planning to go into the nitty-gritty details of internal implementation of QHsm_init/QHsm_dispatch. These functions provide the exact same interface already discussed for the toy "uC/AO framework". But of course, the full-featured implementation of hierarchical state machines is somewhat complex and I'm not sure if explaining all this would make it easier to use. --MMS

    • @mrk3ma1
      @mrk3ma1 2 года назад

      ​@@StateMachineCOM Thank you for your quick response. I understand that implementing entry/exit is complex for nested HSM. I wanted to learn how to implement dispatch and init functions since I don't want to implement full featured HSM but only the initial state transition part for superstates(not entry and exit actions). It would have helped to learn how these functions operate so I can use the only parts that I need. I want to make HSM as simple, small and fast as possible for my application. However, either way your content is very helpful, keep up the good work!

  • @supershaye
    @supershaye 2 года назад +1

    Definitely looking forward to learning more about HSM's. I have now run into the issue you discussed with FSM's where I have a lot of states handling events in the same way. It means that I get a lot repeated code within my codebase and I would definitely like to clean this up. A HSM looks like a plausible way of getting rid of this repeated code by passing the events to a higher level state. Would you say Embedded GUI's implemented using HSM's are easy to understand?

    • @StateMachineCOM
      @StateMachineCOM  2 года назад +2

      I would recommend that you google for "Statecharts in User Interface" or similar. Among others, you will then find the book "Constructing the User Interface with Statecharts" by Ian Horrocks (recommended read for UI designers). Otherwise, the arguments often given is that statecharts (HSMs) are "too difficult to implement". This is a misconception that I tried to debunk in this video and the future lessons as well. --MMS

  • @breakersun
    @breakersun 2 года назад

    Thank you Doctor for such insightful tutorials.
    I have a little problem with SW2 in lesson-40_ucao with my TM4C123GXL launchpad, seems SW2 can't trigger button2PressedEvt or button2ReleasedEvt. So I monitored the GPIOF_AHB DATA register in debug mode. It turns out the DATA never changed while SW2 was pressed or released. That's weird.
    Then I tested with TI's example gpiointerrupt_EK_TM4C123GXL_TI in CCS, it works, the SW2 can turn on and off green LED.
    So I was wondering what's the difference in between. Would you mind give me some hints?

    • @StateMachineCOM
      @StateMachineCOM  2 года назад

      You have two options: 1) download the project for this lesson from the companion web-page to this course at state-machine.com/video-course and this code should work, or 2) watch the setup of the SW2 button at 3:56 of this video. The tricky aspect here is that the GPIOF.1 pin is multiplexed with the NMI. Therefore, for security, the access to this pin must be first unlocked, which is demonstrated. I hope this help. --MMS

  • @paulhe5485
    @paulhe5485 2 года назад

    Thanks Dr Mico, really nice course.
    I have a question about the the usage of SUPER which is defined as beblow
    #define SUPER(super_) (((Hsm *)me)->temp = (StateHandler)(super_), SUPER_STATUS)
    but I've not seen any place this handler is called. could you explain a little bit of how this temp state handler is used? thanks very much.

    • @StateMachineCOM
      @StateMachineCOM  2 года назад +1

      The macro SUPER() is used to specify the hierarchical state nesting by designating the superstate of a given state. This macro is called when the current state handler cannot handle a given event. In that case, the current state handler calls SUPER() and assigns the superstate to me->temp and returns the SUPER_STATUS. This information is then used by the "event processor" to propagate the event to the designated superstate. Please note that this is NOT a state transition, so changing the active state me->state would be wrong. Instead, the propagation of the event to the superstate is just a temporary situation, because the superstate can again propagate the event to even higher-level superstate. Therefore, the name of the variable is "temp". I hope this clarifies the usage and the naming. --MMS

  • @toddmoore112
    @toddmoore112 2 года назад +7

    I have just one question . why have you not enabled ads on your RUclips channel ? you must be knowing that you can enable monetization on your videos .

    • @StateMachineCOM
      @StateMachineCOM  2 года назад +19

      Thank you for appreciating my work. But if you really like to help, please spread the word about this video course! You could make posts or comments on: stackoverflow, reddit, quora, linkedin, facebook, or wherever you see fit. People constantly ask about specific subjects, about fundamental concepts, and about learning resources. This course is such a resource, but it is still relatively unknown. Please help others to find it and make this course more popular in the process. --Miro