Main Content

Generate and Visualize Bluetooth LE Channel Sounding PHY Waveform

Generate and visualize a Bluetooth LE CS PHY waveform by using this CS procedure.

Channel Sounding Tutorial Workflow.png

Using this example, you can:

  1. Generate a CS PHY waveform at the Initiator.

  2. Add propagation delay and additive white Gaussian noise (AWGN) to the generated CS PHY waveform.

  3. Receive the noisy waveform at the Reflector, and generate a response waveform.

  4. Add propagation delay and AWGN to the generated response waveform.

  5. Receive the noisy response waveform at the Initiator.

  6. Visualize the time-domain CS PHY waveforms at the Initiator and Reflector.

Configure CS PHY and Simulation Parameters

Specify the noise power spectral density (Eb/No), samples per symbol, and the speed of light.

EbNo = 30;                                     % In dB
sps = 8;                                   
lightSpeedConst = physconst("LightSpeed");     % In m/s

Specify the PHY transmission mode.

phyMode = "LE1M";

Specify the operating mode for CS PHY waveform generation.

stepMode = 0;

Specify the type of optional sequence in the CS SYNC packet format.

sequenceType = "Sounding Sequence";

Specify the optional sounding sequence length.

sequenceLength = 32;       % In bits

Specify the duration of the CS tone.

toneDuration = 20;         % In microseconds

Specify the distance between the Initiator and the Reflector devices.

distance = randi([2 80],1,1);                 % In meters

Compute the waveform propagation time between the Initiator and Reflector devices.

propagationTime = distance/lightSpeedConst;   % In seconds

Calculate the sampling frequency (in Hz) of the generated waveform.

sampleRate = sps*1e6*(1 + 1*(phyMode=="LE2M")); % In Hz

Set the signal-to-noise ratio (SNR).

snr = EbNo - 10*log10(sps);

Create and configure a Bluetooth LE CS configuration object for the Initiator.

cfgObjectI = bleCSConfig(Mode=phyMode, ...
    SamplesPerSymbol=sps, ...
    DeviceRole="Initiator", ...
    SequenceLength=sequenceLength, ...
    SequenceType=sequenceType, ...
    StepMode=stepMode, ...
    ToneDuration=toneDuration);

Create and configure a Bluetooth LE CS configuration object for the Reflector.

cfgObjectR = bleCSConfig(Mode=phyMode, ...
    SamplesPerSymbol=sps, ...
    DeviceRole="Reflector", ...
    SequenceLength=sequenceLength, ...
    SequenceType=sequenceType, ...
    StepMode=stepMode, ...
    ToneDuration=toneDuration);

Create a variable fractional delay object by using the dsp.VariableFractionalDelay (DSP System Toolbox) System object™.

timeDelay = dsp.VariableFractionalDelay;

Specify the number of samples to delay, based on the distance between the Initiator and Reflector devices.

samplesToDelay = propagationTime*sampleRate;

Set the configuration to display the time-domain CS PHY waveform.

timeDomainScope = timescope(SampleRate=sampleRate, ...
    ChannelNames={'Initiator','Reflector'}, ...
    LayoutDimensions=[2 1]);
timeDomainScope.YLimits=[-1.25 1.25];
timeDomainScope.Title = "Initiator View";
timeDomainScope.ActiveDisplay = 2;
timeDomainScope.YLimits=[-1.25 1.25];
timeDomainScope.Title = "Reflector View";

Set the configuration to display the frequency spectrum of the generated CS PHY waveform.

frequencyScope = spectrumAnalyzer(SampleRate=sampleRate);

Simulate and Visualize CS PHY Waveforms

Generate the Bluetooth LE CS PHY waveform at the Initiator.

waveformInitI = bleCSWaveform(cfgObjectI);

Compute the length of the generated Bluetooth LE CS waveform.

packetLength = length(waveformInitI)
packetLength = 
352

Plot the Bluetooth LE CS waveform at the Initiator.

frequencyScope(waveformInitI)
release(frequencyScope)

Add propagation delay to the generated waveform.

delayWaveformI = timeDelay([waveformInitI; zeros(ceil(samplesToDelay),1)],samplesToDelay);

Specify the time-domain waveform at the Initiator.

initiatorView = [waveformInitI; zeros(ceil(samplesToDelay),1)];

Add AWGN to the delayed waveform.

noisyWaveformI = awgn(delayWaveformI,snr,"measured");

Specify the time-domain waveform at the Reflector.

reflectorView = noisyWaveformI;

Display the time-domain view of the CS PHY waveform at the Initiator and the Reflector.

timeDomainScope(initiatorView,reflectorView)
release(timeDomainScope)

The Reflector, upon receiving the CS waveform, completes the current task and then begins transmitting a response waveform (which might involve calculating processing delay).

Specify the idle wait time the Reflector must observe before initiating its response. Set the idle wait time of the Reflector by determining the number of frames it should wait.

idleFrames = randsrc(1,1,1:4);

Specify the number of idle samples of the Reflector in integer multiples of the received waveform.

idleSamples = idleFrames*packetLength;

Generate and plot the Bluetooth LE CS response waveform at the Reflector.

waveformInitR = bleCSWaveform(cfgObjectR);
frequencyScope(waveformInitR)
release(frequencyScope)

Specify the time-domain waveform at the Reflector.

reflectorView = [reflectorView; zeros(idleSamples,1); waveformInitR; zeros(ceil(samplesToDelay),1)];

Add propagation delay to the generated response waveform.

delayWaveformR = timeDelay([waveformInitR; zeros(ceil(samplesToDelay),1)],samplesToDelay);

Add AWGN to the delayed waveform.

noisyWaveformR = awgn(delayWaveformR,snr,"measured");

Specify the time-domain waveform at the Initiator.

initiatorView = [initiatorView; zeros(idleSamples,1); noisyWaveformR];

Display the time-domain view of the CS PHY waveform at the Initiator and the Reflector.

timeDomainScope(initiatorView,reflectorView)
release(timeDomainScope)

References

[1] Bluetooth® Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed June 22, 2023. https://www.bluetooth.com/.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.

[3] Bluetooth Technology Website. “Channel Sounding.” Accessed April 30, 2024. https://www.bluetooth.com/specifications/specs/channel-sounding-cr-pr/.

See Also

Functions

Objects

Related Topics