Ranging

Description

The ranging application presents a basic usage of the SPARK Ranging Core. This application example demonstrates how to design wireless links using the Wireless Core for ranging. It creates a synchronized bidirectional link between 2 devices that exchange information used for distance measurement.

Nomenclature

In all SDK example applications, the adopted convention is that a radio can have one of two roles: a Node role or Coordinator role. With SPARK’s Wireless Core, the Node devices must synchronize their internal clocks to the Coordinator device therefore ensuring that all devices on the network are synchronized to the same time schedule.

In the context of ranging applications, the terminology is quite different, where they refer to Initiators and Responders. The Initiator sends out a ranging request and the Responder replies. Therefore, the Coordinator role is assigned to the Initiator device and the Node role to the Responder device.

Behavior

This example is designed to operate with a single pair of SPARK Evaluation Kits (EVK). One of the devices is configured as Coordinator and the other one as Node. The wireless transmissions use only one timeslot where the Coordinator device transmits and the Node device receives. In the same timeslot, the Node also sends an auto-reply packet upon successful reception of a packet from the Coordinator, making the link “bidirectional”. This auto-reply packet contains, within a header, the fine-grained timing information required for ranging distance calculations.

Note

The Node’s auto-replies are not acknowledged by the Coordinator, thus are always counted as “Sent And Not ACK’d” in the Node’s statistics.

The following diagram illustrates the general structure of the schedule used in this application.

Ranging schedule

Figure 8: Ranging application schedule.

The payload consists of the string “SPARK!” on both devices. Upon receiving a configurable number of auto-reply packets, the Coordinator processes and prints the distance (cm) separating it from the Node alongside statistics on a serial interface. To see the application’s output, simply connect and configure a terminal emulator software to the device’s serial port on a PC.

Coordinator Device

  • LED0 toggles every time a packet is successfully transmitted to the Node (almost always ON because of the high packet rate).

  • LED1 toggles every time an auto-reply is successfully received from the Node (almost always ON because of the high packet rate).

Interface

Name

Description

SW1

Reset Stats

Reset the TX and RX statistics.

SW2

Calibrate

Calibrate the distance measurement.

LED0

Transmission Success

Toggle LED when a wireless transmission is successful.

LED1

Reception Success

Toggle LED when a wireless reception is successful.

LED2

N/A

N/A

Node Device

  • LED0 toggles every time an auto-reply is transmitted to the Coordinator (almost always ON because of the high packet rate).

  • LED1 toggles every time a packet is successfully received from the Coordinator (almost always ON because of the high packet rate).

Interface

Name

Description

SW1

Reset Stats

Reset the TX and RX statistics.

SW2

N/A

N/A

LED0

Transmission Occured

Toggle LED when a wireless transmission is sent.

LED1

Reception Success

Toggle LED when a wireless reception is successful.

LED2

N/A

N/A

Antenna Orientation and Line-of-Sight

For precise measurements, ensure that the antenna orientation of both the Coordinator and Node devices align with the same polarization.

Furthermore, it is necessary for the devices to maintain a direct line-of-sight. Without a direct line-of-sight, the distance measurement could be that of the reflected path instead of the direct path.

Calibration Procedure

A calibration must be performed to ensure proper ranging values. The calibration is carried out at a predefined distance which serves as a reference. The following steps describe the procedure.

  1. Place the Coordinator and Node devices exactly 50 cm apart.

  2. Verify that antenna orientation and line-of-sight are respected.

  3. Press SW2 on the Coordinator to complete calibration.

Configuration

Output Power Configuration

There are two recommended output power configurations (pulse settings) for the ranging application. The user must choose between:

  • LOW_OUTPUT_POWER_MODE: For short range measurements (ideal for indoor usage).

  • HIGH_OUTPUT_POWER_MODE: For long range measurements (ideal for outdoor usage).

By default, the first mode is selected by adding the LOW_OUTPUT_POWER_MODE preprocessor definition in each devices swc_cfg_*.h file.

Terminal

Host terminal configuration should be as follows:

  • Speed (baud): 115200

  • Data bits: 8

  • Stop bit: 1

  • Parity: None

  • Flow control: None

The following figure shows the serial interface output of this application.

Serial interface output example

Figure 9: Ranging application serial interface output.