Embedded State Machine Programming – QP State Machine Framework

Embedded State Machine Programming - QP State Machine Framework

Content Source: Sun Wukong Seeking Knowledge Basic Terminology of State Machines Current State: Refers to the state currently being occupied. Condition: Also known as “event”, when a condition is met, it will trigger an action or execute a state transition. Action: The action executed after the condition is met. After the action is completed, it … Read more

Essential Learning for Embedded Development | Common Techniques for State Machines

Essential Learning for Embedded Development | Common Techniques for State Machines

Source:Embedded MiscellanyState machines are ubiquitous in embedded software. You might think, what’s so difficult about state machines? Aren’t they just switches? Switch is just the most basic point, and there are many more operations related to state machines that you may not have seen. Below, I will share several implementation methods. 1. Basic Terminology of … Read more

JTAG Debugging – TAP Controller

JTAG Debugging - TAP Controller

Implementing the TAP controller within the SoC, interfacing with the JTAG chip in the JTAG hardware box to receive and process JTAG sequences. Its main structure is as follows:As can be seen, there is a state machine, an Instruction Register (IR), several Data Registers (DR), a Bypass Register, etc.The state machine is controlled by TMS, … Read more

Various Techniques for State Machines in Embedded Systems

Various Techniques for State Machines in Embedded Systems

State machines are ubiquitous in embedded software, and you might say, what is so difficult about state machines? Aren’t they just switches? Switch is merely the most basic point; there are many more operations regarding state machines that you may not have encountered. Below, I will share several implementation methods. 1. Basic Terminology of State … Read more

Quick Troubleshooting Techniques for PLC-based Smart Home Systems Using PLCopen Standards

Quick Troubleshooting Techniques for PLC-based Smart Home Systems Using PLCopen Standards

Yesterday, a colleague called me in a panic, saying: “Wen, help! My PLC-based smart home system is completely down, and the owner is coming for acceptance in half an hour!” Hearing this familiar “fire-fighting” scenario made me smile. Ten years ago, I was in the same boat, where a small issue could drive me crazy … Read more

Creating Your Own Chip (Part 2) – UART Section

Creating Your Own Chip (Part 2) - UART Section

Word count: 1092, reading time approximately 6 minutes Continuing from the last session, today we will implement the functionality of UART, primarily using the hardware description language Verilog. The interface design is actually quite simple. If we distill its essence, it can be divided into three main parts: data acquisition, state machine, and interface timing. … Read more

Research on Control Algorithms of PLC Event-Driven Programming in Building Automation Control

Research on Control Algorithms of PLC Event-Driven Programming in Building Automation Control

Yesterday, I received a request for help from a colleague who said that the intelligent building automation system he was responsible for was always “misbehaving”—the corridor lights would turn on and off unpredictably, and the conference room air conditioning was fluctuating between hot and cold. I immediately recognized that this was the fault of the … Read more

Variable Types and Data Processing in PLC Sequential Control Programming

Variable Types and Data Processing in PLC Sequential Control Programming

Over the years, I have seen too many on-site programs, especially in the area of PLC sequential control, where the choice of variable types is poor, leading to numerous pitfalls. A few days ago, I went to a food factory to troubleshoot, and the program almost drove me crazy. They used a bunch of BOOL … Read more

Essential Microcontroller Programming Skills: A Transformation Guide from Beginner to Expert

Essential Microcontroller Programming Skills: A Transformation Guide from Beginner to Expert

Hello everyone! Today, I want to share not just dry coding rules, but 6 practical skills that can help your microcontroller projects succeed and double your code efficiency. These experiences come from my years of lessons learned from mistakes, specifically addressing the “program runs but is not user-friendly” issues! 1. Project Planning: Draw the Map … Read more

Sharing an Embedded Programming Template

Sharing an Embedded Programming Template

Input Events to State Machine #include "stdio.h" #define EXECUTE_VOID(func) {if((func)!=NULL) (func());} typedef void (*select_machine_t)(void); typedef enum _event_index{ event_index_1 = 0, event_index_2, event_index_3, event_index_end} event_index_e; typedef enum _status_index{ status_index_1 = 0, status_index_2, status_index_end} status_index_e; void machine_1(void);void machine_2(void);void machine_3(void);void machine_4(void); select_machine_t select_machine[event_index_end][status_index_end] = { {machine_1, machine_2}, {NULL, machine_3}, {machine_4, NULL}}; void machine_1(void){ printf("machine_1\r\n");} void machine_2(void){ printf("machine_2\r\n");} void … Read more