State-Machine Based Decimation Filter for LiDAR UART Streaming
G
Gian Fajardo, SPaRA ResearchA 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.
You might also like
View all View all templatesPerformance Metrics XY Chart
Track metrics over time with bars, lines, or both to spot trends and patterns instantly. This template plots data points across a time axis, making it easy to see progress, compare periods, and identify performance changes. Perfect for progress tracking, performance reports, training logs, analytics dashboards, or any time-series data visualization.
M
Mermaid
CI/CD Pipeline Diagram
Ship with confidence. This template shows how code moves from a commit to customers —through source control, automated builds, testing, staging, and production — with clear hand-offs and helpful notifications along the way. Your whole team can read at a glance, whether you’re designing a new pipeline, documenting an existing one, or spotting where your deployment process could flow better.
M
Mermaid
Fibonacci Communication Development Model
A theoretical framework mapping the Fibonacci sequence backwards onto the evolution of communication – from an infant's first silence through language acquisition, social scaling, and civilizational complexity. Six subgraphs layer the model: core principles, linguistic development stages, trans-scalar social dynamics, civilizational lifecycle, diagnostic protocols, safeguarding rules, and ultimate insights. Built for researchers, systems thinkers, and educators exploring how communication patterns replicate across scales.
J
Jef Singh
P2P Process Flow (detailed)
Map the full Procure-to-Pay lifecycle across four swimlanes: from purchase requisition through goods receipt and supplier invoice to final payment. Built for finance and operations teams who need to document, audit, or onboard staff to procurement workflows. Each decision point and approval gate is explicit, so there's no ambiguity about who owns what.
A