State-Machine Based Decimation Filter for LiDAR UART Streaming

G
Gian Fajardo, SPaRA Research

A state machine for reading a continuous stream of 5-byte UART messages from a LiDAR scanner into an embedded system — in real time, with configurable decimation. Rather than capturing everything and filtering later, this design processes bytes as they arrive and skips every Mth message on the fly. Five states handle the full lifecycle: idle, pattern detection, offset alignment, recording, and skipping. Built for embedded systems engineers, robotics researchers, and anyone working with sensor data pipelines where memory is constrained and throughput matters.

How to create a State-Machine Based Decimation Filter for LiDAR UART Streaming

To create a state-machine based decimation filter for LiDAR UART streaming, follow these steps:

01.
Define your states before your transitions
List every mode the system can be in: HOLD (idle), FIND_PATTERN (sync detection), ADD_OFFSET (byte alignment), RECORD (capture), SKIP (discard). Each state has exactly one job.
02.
Assign a limit to each state
Every state runs until a counter reaches a state-specific limit — WAIT_INDEX for HOLD, FIND_INDEX for FIND_PATTERN, offset for ADD_OFFSET, MSG_LENGTH for RECORD, SKIP_INDEX for SKIP. Document these as notes on each state node.
03.
Model the init transition
Start from [*] and arrow into HOLD — this represents system initialization and makes the entry point explicit.
04.
Use a choice node for branching logic
After FIND_PATTERN detects a candidate pattern, there are two possible next states depending on whether an offset correction is needed. A <<choice>> node makes this branch readable without cluttering the state definitions.
05.
Close the decimation loop
RECORD → SKIP → RECORD is the core cycle. The counter inside each state determines how many bytes get captured vs. discarded, implementing the 1-in-M message decimation.
06.
Add the buffer-full exit
SKIP → HOLD fires when interm_buffer_counter > PROCESS_BUFFER_SIZE — the system has filled its output buffer and resets to wait for the next read cycle. Model this as a guarded transition with the condition labeled on the arrow.
07.
Use notes to carry implementation details
State diagrams communicate structure, not values. Use note left of and note right of to attach the specific limit constants to each state without cluttering the transition arrows.

Share with others

Tags

Embedded SystemsState MachineLiDARUARTReal-Time, RoboticsSignal ProcessingState DiagramHPC

You might also like

View all

Workflow Diagram

Map how work actually moves through your team. This template shows how ideas are scored, communicated, researched, prioritized, and either promoted to the roadmap or parked — with explicit decision points and feedback loops. It helps teams stay aligned on next steps, understand why decisions were made, and onboard new members without endless meetings.
M
Mermaid

Circular Org Chart Template (Mind Map)

Show your team structure without the hierarchy. This template puts a leader or team at the center, with members arranged around them — great for flat organizations, small teams, committees, project pods, or advisory boards. It’s fast to edit, easy to share, and stays readable even as roles change.
M
Mermaid

ERD Blogging System

Design the database backbone of a content platform. This template maps all the data relationships needed for a blogging system — from users creating posts, to comments and categories organizing content, to tags and file attachments enriching articles. It helps teams build scalable content systems, plan migrations, or understand existing blog platforms without getting lost in complex queries.
M
Mermaid

Order Management Sequence

Trace an order from customer submission through production and billing, with full NetSuite integration. Shows how a web portal, a physical traveler document, and an ERP system coordinate across roles — customer, order support, production manager, shop floor lead, and billing. Useful for solution architects, ops teams, and anyone implementing or auditing an order management workflow.
R
Renso Höllhumer, Solutions Architect