Ratio Packets: Part 1 - A New Clock Synchronization Independent Protocol Over 1 Wire.

Ratio Packets:  Part 1 - A New Clock Synchronization Independent Protocol Over 1 Wire.

Before introducing the ratio-packet concept a quick review of some common protocols can show how almost all rely on clock synchronization, fixed bit rates and some type of shared synchronization.  A ratio-packet attempts to eliminate the sync entirely relying on mathematical embedded ratios to determine the start / stop and data transfers.  In other words the timing clock of the packet is embedded in the bits itself which vary in timing rate.

UART (Universal Asynchronous Receiver Transmitter)

SPI (Serial Peripheral Interface - 4 Pins for communication - )

  • Master passes clock syncing over a dedicated wire (SCLK)
  • Communication is serial and single-direction (MOSI - MOSI / MISO - MISO)

I2C (I2C Protocol)

  • SCL (Clock) is shared.
  • Bus topology with addressing over a single wire.
  • The best of both UART and SPI.
  • 4 wires are required.

RatioPacket (Advantages)

  • Device Clock independent.
  • Expected to work at speeds of approximately 50 Khz for slower devices and 1Mhz for faster devices.
  • Store-and-Forward Routing with route learning allowing for device cascading.
  • Can be setup for serial and or parallel transmission.
  • Designed for multiple different devices to communicate to each other (Raspberry Pi / Arduino / ESP8266 etc.)
  • Relies on 'King bits' which have a mathematical ratio of 1.7x that of a normal transmission bit (independent of transmitter or receiver clock rates)
  • Devices use the ratio changes to it's own internal clock counters to determine the current information set.
  • Devices in a overheated state / devices which have lost their own internal clocks can still communicate with devices working at completely different clock rates.  Devices however must maintain enough clock speed to measure ratio bits (king bits).
  • For highest adoption the ratiopacket protocol will be opensource.
  • Three components make up a ratio packet.

A. Timing Ratio and Timing Reservation Leader Bits

B.  Source / Destination / Packet Type / Payload Bits

C. Timing Ratio Closing Bit(s).

Signalling and Sampling:

  • Ratio packet does not require sampling between bits, instead:

1 = Transition Received (high-to-low, or low-to-high)

0 = No Transition Received

A. (TRTR Leader Bits) Timing Ratio and Timing Reservation Leader Bits

Because this is a completely new type of packeting it will be explained in detail.

  • The TRTR leader bits will always transmit as a a series of 1's - (transition recieved).
  • King bits deliberately have a timing ratio that will be 1.7 times that of a standard bit.  Because they are at a mathmatical ratio independent of the standard bit they indicate the start / end of a transmission.  
  • Standard bits will expect to reside at timing intervals that are 0.588 that of the TRTR King bits. This will inform the receiver the size of a standard bit and the timing expected  (clock speed is now embedded by the ratio).  
  • Clock synchronization and timings are now not required on a secondary conductor, and the receiver relies on receiving transitions at either the king bit ratio or standard bit ratio and mathematically deriving what it is looking at.

In this example two king bits precede two standard bits which indicate a reservation of 32 bit packet follows.

Understanding The Packet Cycle

Before we go any farther we will explain a transmission cycle. We have two state-machines (in this case a Raspberry Pi at 800 Mhz and a 16Mhz Arduino).  The participating state machines must have a high enough clock rate to accurately measure the ratio.  The arduino does not know at what speed it will receive a incoming packet and the transmitter may arbitrarily lower it's clock speed.

A. Transmitting Raspberry Pi picks a standard packet clock rate of 50 Khz (20 uSecs for standard bits and 34 uSecs for King bits.)  At  800 Mhz, and using the correctly set asm block it requires 1.25 nanoseconds / instruction. Therefore if a nop loop executes in 1 clock cycle we have:

  • 20 uSecs = nop loop counter 16000.
  • 34 uSecs = nop loop counter 27200.

The raspberry pi then implements and latches out using the above nop counters.

The arduino at a much lower  16 Mhz clock and 'busy' measuring A/D or some arbitrary task receives a transition interrupt. At that interrupt block code it then begins monitoring it's internal counter loop that has 1 cycle accuracy. Therefore the counter loop frequency resolution is only 16 Mhz.

  • 20 uSecs = counter interval at 320
  • 34 uSecs = counter interval at 544

The arduino will measure each bit transition against it's internal counter and wait for a decreased  packet length  indicating the size of the incoming packet.  When it receives a second king bit it then has the expected structure and size of the incoming packet.  Two king bits are sent as a redundancy allowance in case of busy devices.

A Full Packet Example

  • King bits (2) indicate start of transmission
  • Standard Bit (1) indicate that a 16-bit payload follows
  • King bit (1) indicates end of TRTR leader
  • Bits (0-4) Destination Address (32 devices addressed)
  • Bits (5-9) Source Address (32 devices addressed)
  • Bits (A-D) Packet Type
  • Bits (E - end) Payload.
  • King Bit Sign off and release of channel

4 King bits * 34 uSecs + 17 bits * 20 uSecs = 276 uSec. Allowing a respectable 5200 PPS (Packets-Per-Second) at 50 Khz.  

This protocol implementation opens up a lot of possibilities that have never possibly been considered before. Consider:

  • Frequency Banding.  Slow devices can now work simultaneously beside faster devices on the same wire.  Two arduinos can transmit packets at 16.8 Kbit while simultaneously two faster raspberry pi's can transmit at 1 Mbit - on the same wire.  Devices can simply ignore king bits that do not fit a set band counter.
  • Device Addressing at the micro-level.  Arduino's are now addressable and can cascade route packets.
  • The single standard bit in the TRTR header informs all receivers the size of the following packet.

Because 14 bits are reserved for source address / destination address and packet type a 16-bit packet will only allow for 2 bit payload.  It is up to the coding implementation of how this is managed.  This timing broadcast is extremely important as it is used in congestion and packet collision avoidance.

Eventually it would be expected to potentially route TCP/IP over the ratio-packet protocol.

Part II - Rasberry Pi Bit Signalling Structure.

In the next section we will begin bulding the code blocks required starting with a standard raspberry pi.

Linux Rocks Every Day