Custom RF Protocol (FS1000A/MX-FS-05V) - Losing sync on long payloads. How do you handle continuous clock recovery?
I’m working on an project where I’m trying to build my own custom RF packet framing from scratch. I am not looking to use established libraries like VirtualWire or RadioHead...I know they would solve this instantly, but my goal is to understand how low-level RF synchronization and protocol design actually work under the hood.
Hardware:
- 2x Arduino Nanos (ATmega328P)
- FS1000A (TX) and MX-FS-05V (RX) 315MHz modules
The Goal: I’m transmitting a custom frame structured as: PREAMBLE -> SYNC WORD -> LENGTH -> DATA -> CHECKSUM.
The Issue: My code works perfectly for very short payloads (like "AB" or "HI" even "abcdefghijklmno"). However, when I try to send a longer string (like "abcdefghijklmnopqrstuvwxyz" or a short sentence), the payload gets corrupted and fails the checksum.
My Current Approach: Currently, my receiver does a single timing alignment right after detecting the preamble/sync word: delayMicroseconds(BIT_DELAY / 2); After that, it enters a loop and samples continuously using a fixed bit delay (delayMicroseconds(416) for a ~2400 baud rate).
CODE: TX RX CODE
What I suspect is happening: I believe I am falling on clock drift. Because my TX and RX Arduinos have independent internal clocks, and I’m relying on a fixed delayMicroseconds in software, microscopic timing discrepancies are accumulating. By the time it reads the 30th or 40th bit, the receiver is no longer sampling in the center of the bit and reads garbage. I lack continuous bit synchronization.
Any insights, codes, help, pseudocode, or resources on how to implement would be massively appreciated. Thanks!