
Explore finite state machines and UML state machines to model reactive software with states, events, transitions, and outputs; visualize with state charts and leverage code generation tools.
Explore Mealy and Moore state machines, showing how outputs attach to transitions versus states, with a light-control example and notes on entry actions in UML state machines.
Examine Mealy and Moore state transition tables, showing outputs from present states and events in a light control example, and introduce Harel charts and UML state machines.
Explore a light control Mealy machine using an Arduino Uno, PWM dimming via analogWrite, and serial host commands to turn an LED on or off.
Define LED state and events with C enums, implement a Mealy machine using a nested switch, and control LED brightness via PWM on Arduino.
Learn to receive host data via serial on Arduino, use Serial.available and Serial.read to emit on and off events, and drive a led with a Mealy state machine.
Demonstrate implementing a light control UML state machine using a Moore machine, detailing entry actions, state transitions, and run_entry_action, with comparisons to the previous Mealy approach.
Demonstrates ProTimer, a productivity timer built on a flat state machine for Arduino Uno with a 16x2 lcd, covering time set, countdown, idle, abort, and productive time tracking.
Explore UML simple and composite states to model an application's lifecycle, using idle, time-set, countdown, pause, and stat scenarios, with regions, substates, and superstate concepts.
Learn how UML state machines model internal state activities with entry, exit, and do labels, tied to actions via a behaviour-expression, and when each action executes.
Explore UML state machine transitions (internal, external, and local) covering triggers, guards, and actions, including how internal transitions avoid exiting the state and external transitions perform exit and entry actions.
Explore how events drive a state machine through external or internal transitions, using signal components and optional parameters, with microwave oven and calculator examples modeled by structures or enums.
Model the productivity timer with a UML state machine, handling increment time, decrement time, START_PAUSE, Abort, and TIME_TICK events, and track current, elapsed, and productive time.
Define entry and exit actions for UML state machines in an embedded timer: initialize idle display, show time in time-set, display paused, countdown on tick, and clear displays on exit.
Explore drawing transitions from the idle state, mapping increment time to time set and implementing an internal time_tick sequence that beeps.
In the time_set state, internal transitions adjust c_time and update the display. Abort returns to idle to reset; start_pause initiates countdown only if time is at least 60.
Implement the PAUSE state in a UML state machine, processing INC_TIME and DEC_TIME, resuming with START_PAUSE, and handling TIME_TICK for countdown with a choice pseudo state.
Implement the STAT state from IDLE with START_PAUSE to show STAT for 1 second. Auto return to IDLE via TIME_TICK with guard ss=10; compare flat and hierarchical state machines.
Set up Microsoft Visual Studio Code with the PlatformIO extension to implement the state machine in C for embedded projects, avoiding the Arduino IDE for better features.
Create a new PlatformIO project in Visual Studio Code for an Arduino Uno, configure the board and framework, and build, upload, and view serial monitor output.
Define enums and structures for signals, states, and events, using a generic event_t and structure embedding. Organize code into header and source files with include guards for a state machine.
Implement the initial transition in the protimer state machine by creating protimer_init that initializes mobj, sets the active_state to IDLE, and resets p_time to 0.
Explore implementing a state machine with three approaches: nested switch, state handler with function pointers, and state table, detailing how each state has its own handler.
Demonstrate a nested switch based finite state machine in protimer_state_mach.cpp, using a state_machine with active_state, state handlers, and event signals like entry, exit, inc_time, and time_tick.
Learn to implement nested switch-based fsm handlers with guard conditions converted to if statements, handle internal and external transitions, and build the protimer event dispatcher.
The lecture outlines hardware connections for an Arduino timer: three push buttons with pull-down resistors, a buzzer on pin 12, and a 16x2 LCD in 4-bit mode with pin mappings.
Implement the loop to read the button pad status with digitalRead, using pull-down pins, and form btn_pad_value with debouncing. Then dispatch INC_TIME, DEC_TIME, START_PAUSE, or ABRT events to the protimer_event_dispatcher.
Dispatch the time tick event every 100 milliseconds using Arduino millis(), maintaining a static current_time and updating a time tick event’s sub-second field before sending it to the state machine.
Explore button bouncing when a push button interfaces with Arduino using pulldown or pullup resistors, and implement software debouncing for clean voltage transitions.
Implement software button debouncing using a three-state state machine model (not pressed, bounce, pressed) with a 50 ms timeout via millis, in a function that returns the debounced button value.
Install Arduino's official liquid crystal library in PlatformIO and add it to your project to drive hd44780-based 16x2 lcd displays. Create a LiquidCrystal object with rs, enable, d4–d7 pins, then use wrapper functions to print text, set the cursor, and initialize the display.
Implement lcd.cpp by creating a LiquidCrystal LCD object with Arduino pins (rs, rw, en, d4-d7) and including lcd.h. Use lcd.clear(), lcd_print(), and lcd.scrollDisplayLeft to implement the functions.
Implement and initialize a 16x2 lcd with column-first coordinates, cursor control, and lcd_begin(width,height). Use display_time and display_message to render mm:ss at specified coordinates for idle, paused, and other states.
Implement and test display_message using lcd_set_cursor and lcd_print_string, play a 25 ms beep at 4 kHz with tone on the buzzer, and format time (minutes and seconds) with sprintf.
Implement the initial transition to the idle state by correctly triggering its entry action in the protimer state machine, sending the entry event and testing the one-time entry action.
Test the hardware timer app on board with LCD, buzzer, potentiometer and buttons, validating idle, set time, countdown, debounce, start/pause, abort, and a stat state fix using a tick_count approach.
Learn how to use function pointers in C by storing function addresses, declaring function pointer variables, and calling through pointers, while understanding type signatures, compatibility warnings, and typedef aliases.
Learn to pass a function pointer as an argument and implement add, subtract, and multiply without if or switch, using a state table of function pointers.
Explores the state handler approach using a function pointer in active_state to dispatch to state handlers, replacing nested switches and enabling direct handler calls and transition handling.
Introduce the state table approach for an fsm, using a table of event handlers and function pointers to replace switches, and explain creating per-state entry and exit handlers.
Prototype all state handlers and expose them in main.h, build a state table mapping events to handlers and next states, then convert it to a two dimensional array in C.
Learn how two dimensional arrays in C store data in a row-wise memory layout, with indexing by row and column to access table-like data.
Initialize a two dimensional protimer state table of function pointers to map the idle, time_set, countdown, pause, and stat states with signals, for the dispatcher.
Implement a state machine using a state table in C++, initialize protimer and idle state, fetch entry functions via the state_table pointer, and dispatch events with entry and exit actions.
Explore hierarchical state machines (hsms) to reduce complexity and code repetition compared to flat state machines by using composite states, substates, and super states, with unified transition handling.
This lecture introduces run-to-completion and the QP framework for event-driven hierarchical state machines, covering event producers, dispatchers, and the event processor for nested states.
Download and install the QP framework and QP-nano Arduino library, copy them to Arduino sketchbook, and prepare to test transitions and event propagation on PC with visual code and PlatformIO.
Explore transition execution sequences in a nested hierarchical state machine, including event propagation and the order of behavioral actions, using the QP framework and QM tool for testing.
Design an Arduino project to test a nested hierarchical state machine model (qhsmtst.qm) from the QP framework by sending events and studying transition sequences.
Open a QM model file, generate code with declare and define directives for a QHSM state machine, and organize the resulting files under src while integrating the QP-nano Arduino library.
Define state machine events with the QM tool, add include guards and MAX_SIG, implement bsp display and exit, and integrate qpn.h in main.cpp to post events to the state machine.
Post events to a hierarchical state machine using the QP Nano APIs, initialize with QHsm_ctor and QHSM_INIT, and understand embedding the QHsm superclass and class attributes in your app.
Add static and non-static class operations, including a constructor and free operations, using me and the this pointer to access attributes. Generate code and use Q_STATE_CAST for state handler casting.
Explore the Q_onAssert callback for assertion failures, including invalid arguments and excessive nesting, and implement it in main.cpp. Print the failing module and location via serial output.
Call QHSM_INIT after the constructor to execute the top-most initial transition. Define Q_DEFINE_THIS_FILE to set this_module, then dispatch serial events with QHSM_DISPATCH using the me pointer in a run-to-completion fashion.
Test an embedded uml state machine, showing how initial transitions and entry/exit actions unfold across nested states, with event handling and guards demonstrated.
Explore shallow and deep history states in UML state machines, including absent history defaulting to s11, and how entry, exit actions and event propagation shape transitions.
Implement a software-based real-time clock without an RTC chip, displaying current time, date, and day of week, with clock setting, alarm notification, and two buttons for set and OK.
demonstrates a clock alarm application built with a hierarchical state machine on arduino, featuring ticking mode, clock set mode, and alarm set mode, with two buttons and an lcd.
Design a hierarchical state machine for an embedded clock app with ticking, clock setting, and alarm setting states, using signals SET, OK, ABRT, ALARM, and TICK, plus time mode 24/12.
Create a qpn model in qm to implement a Clock_Alarm hsm, derive from QHsm, add time attributes, and design a state machine with ticking, clock_setting, alarm_setting, alarm_notify, plus deep history.
Add a main application object and constructor in embedded system design using UML state machines, wiring SM.h, SM.cpp, and platformio setup with signals and initial state.
Explain the atmega328p timer peripheral, focusing on timer1 in 16-bit ctc mode and how 100 ms base is generated with a 256 prescaler and 16 mhz clock.
Configure Timer1 in CTC mode to generate an interrupt every 100 ms, using a 256 prescaler, enabling the OCR1A interrupt, and implement the ISR with TIMER1_COMPA_vect.
Make the current time a static attribute shared by all objects, and implement static class operations get current time and update_curr_time for ISR-driven time updates with MAX_TIME in ClockAlarm_SM.h.
Define the initial transition to set current time and alarm and display the time on the LCD. Implement set_curr_time with a protected critical section using SREG and cli.
Implement the ticking state to display the current time on the lcd by defining an entry action that calls display_curr_time using 24h and 12h formats with helper functions.
Copy the free operations, paste them into SM.cpp as external code, generate, and add prototypes outside the marked sections, preparing for an LCD test in the next lecture.
Implement display_curr_time by disabling the interrupt, reading the current time into a temporary variable, and returning it. Copy this logic to get_curr_time, compile, and prepare for lcd testing.
Send a TICK event to a UML state machine, implement an internal transition and update the display every 50 milliseconds, using TICK and TICK_SIG with QHSM_DISPATCH and testing on hardware.
Configure the clock_setting state in a uml state machine, with internal set transitions and ok signals from the button pad, to edit hour, minute, and second digits.
Develop clock setting in an embedded UML state machine by editing a temporary time: set cursor, blink, increment hour digits, then minutes, with SET/OK transitions and display updates.
Implement the clock setting state part-2 by updating the hour and minute digits with set signals, cycling hours 0 to 2 and minutes 0 to 5, for display.
Implement clock setting and error handling in a UML state machine by cycling time formats (24h, AM, PM) on SET, validating input with is_time_set_error, and displaying blinking errors.
Add a private uint8_t timeout attribute to the clock setting state, define the initial state, and test a 24-hour clock setting flow with error handling, display blinking, and internal transitions.
Update the current time by converting temp_time to 24-hour format when needed, then set the display mode to 12-hour or 24-hour and save.
Implement the Alarm_Setting state by reusing Clock_Setting substates, allowing alarm time changes while showing real-time and a custom alarm symbol, with sub-machine reuse explained.
Implement the alarm_setting state with separate ok handlers and internal transitions, update alarm_time, manage alarm_on_off selection, and perform 24-hour format conversion during clock setting.
Implement an Alarm_Notify state that blinks a message every 500 ms using a timeout; exits after about 10 seconds unless ok is pressed, returning to the history state.
Learn the fundamentals of simple and hierarchical UML state machines in easy steps
The course emphasizes project-based learning, learning by doing.
The goal of this course is to introduce an event-driven programming paradigm using simple and hierarchical state machines.
After going through this course, you will be trained to apply the state machine approach to solve your complex embedded systems projects.
Some of the highlights of this course are as below
you will learn,
1) UML(Unified Modeling Language) state machine semantics like simple/composite states, events, signals, transitions, entry/exit actions, guards, pseudo-states, etc
2) Drawing UML state machines using graphical modeling tools such as Astah and QM™ modeling tool
3) Implementing embedded applications using Hierarchical state machines and Active objects design approach
4) Using QP™ real-time embedded framework and QP™-Nano Arduino library in your embedded projects
5) Active objects
6) Hands-on event-driven project implementation and testing on Arduino UNO board (Please check the preview videos)
Hardware:
If you want to test the code developed on the target hardware, you need the below-mentioned boards and components
1. Arduino UNO(1)
2. 16x2 character LCD (1)
3. Pushbuttons (3)
4. 10KΩ resistors (3)
5 . 220Ω resistor (3)
6. 100KΩ Potentiometer (1)
7. Arduino buzzer (1)
8. Jumper wires-M2M
Software:
Installation procedure for important software are covered in this course
1. Arduino IDE (Free and Open source )
2. Microsoft visual code (Free)
3. PlatformIO VS code extension(Free and Open source )
4. QM™ modeling tool by Quantum Leaps, LLC (Free GPL version)
5. Astah by Change Vision, Inc.(Trial version)
Learning order of FastBit Embedded Brain Academy Courses,
If you are a beginner in the field of embedded systems, then you can take our courses in the below-mentioned order.
This is just a recommendation from the instructor for beginners.
1) Microcontroller Embedded C Programming: absolute beginners(Embedded C)
2) Embedded Systems Programming on ARM Cortex-M3/M4 Processor(ARM Cortex M4 Processor specific)
3) Mastering Microcontroller with Embedded Driver Development(MCU1)
4) Mastering Microcontroller: TIMERS, PWM, CAN, RTC,LOW POWER(MCU2)
5) Mastering Microcontroller: STM32-LTDC, LCD-TFT, LVGL(MCU3)
6) Embedded System Design using UML State Machines(State machine)
7) Mastering RTOS: Hands-on FreeRTOS and STM32Fx with Debugging(RTOS)
8) ARM Cortex M Microcontroller DMA Programming Demystified(DMA)
9) STM32Fx Microcontroller Custom Bootloader Development(Bootloader)
10) Embedded Linux Step by Step using Beaglebone Black(Linux)
11) Linux device driver programming using Beaglebone Black(LDD1)
Other programming courses
1) Master The Rust Programming Language : Beginner To Advanced