Main Content

Generate BLE Waveform and Add RF Impairments

Communications Toolbox™ Library for the Bluetooth® Protocol features enable you to add radio frequency (RF) impairments to a Bluetooth low energy (BLE) or Bluetooth basic rate/enhanced data rate (BR/EDR) waveform.

Generate BLE Waveform and Add RF Impairments

Specify the data length. Create a message column vector of the specified data length containing random binary values.

dataLength = 2056;                                                                                                 % In bits
message = randi([0 1],dataLength,1);
symbolRate = 1e6;

Specify the values of the physical layer (PHY) mode, channel index, samples per symbol, and access address.

phyMode = 'LE125K';
chanIdx = 2;
sps = 4;
accAdd = [1 1 1 1 0 1 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 1 ...
    0 1 0 1 1 0 0].';

Generate the BLE waveform.

txWaveform = bleWaveformGenerator(message,'Mode',phyMode,'SamplesPerSymbol',sps,'ChannelIndex',chanIdx,'AccessAddress',accAdd);

Initialize the RF impairments for the specified PHY mode and samples per symbol by using the helperBLEImpairmentsInit function. The helper function returns a structure with phase frequency offset and variable fractional delay fields.

initRFImp = helperBLEImpairmentsInit(phyMode,sps)
initRFImp = struct with fields:
         pfo: [1x1 comm.PhaseFrequencyOffset]
    varDelay: [1x1 dsp.VariableFractionalDelay]

Specify the values of the frequency offset and phase offset.

initRFImp.pfo.FrequencyOffset = 150;                                                       % In Hz
initRFImp.pfo.PhaseOffset = -1;                                                             % In degrees

Specify the values of static timing offset, timing drift, variable timimg offset, and DC offset.

staticTimingOff = 0.15*sps;                                                                                         
timingDrift = 10;                                                                           % In ppm
initRFImp.vdelay = (staticTimingOff:timingDrift:staticTimingOff + timingDrift * (length(txWaveform) - 1))';         
initRFImp.dc = 620;                                                                        

Add RF impairments to the generated BLE waveform by using the helperBLEImpairmentsAddition function.

txImpairedWaveform = helperBLEImpairmentsAddition(txWaveform,initRFImp);

Create a default dsp.SpectrumAnalyzer System object. Then, set the sample rate of the frequency spectrum. Visualize the generated and impaired BLE waveform in the spectrum analyzer.

scope = dsp.SpectrumAnalyzer;
scope.SampleRate = sps*symbolRate;
scope.NumInputPorts = 2;
scope.Title = 'Spectrum of Generated and Impaired BLE Waveform';
scope.ShowLegend = true;
scope.ChannelNames = {'Generated BLE Waveform','Impaired BLE Waveform'};
scope(txWaveform,txImpairedWaveform);

Figure Spectrum Analyzer contains an axes object and other objects of type uiflowcontainer, uimenu, uitoolbar. The axes object with title Spectrum of Generated and Impaired BLE Waveform contains 2 objects of type line. These objects represent Generated BLE Waveform, Impaired BLE Waveform.

Visualize the generated and impaired BLE waveform in time-domain by using the timescope object.

timeScope = timescope('SampleRate',symbolRate*sps,'TimeSpanSource','Auto','ShowLegend',true);
timeScope.Title = 'Generated and Impaired BLE Waveform in Time-Domain';
timeScope.ChannelNames = {'Generated BLE Waveform','Impaired BLE Waveform'};
timeScope(real(txWaveform),real(txImpairedWaveform));

References

[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed September 27, 2020. https://www.bluetooth.com/.

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

Related Topics