Bluetooth Modeling in MATLAB
Overview
Today’s engineers are wrestling with analyzing and verifying Bluetooth systems, at both the chip and the system level. In this webinar, we will explore MATLAB-based examples and reference designs to help you simulate and analyze the Bluetooth Low Energy (LE) and Bluetooth Classic PHY layer. You will learn how to perform waveform generation and visualization, signal recovery and analysis in the presence of RF impairments, and end-to-end simulation. Also, you will learn to perform Bluetooth/WLAN coexistence analyses with a variety of fidelity levels.
Highlights
With the examples presented in the webinar, you can:
- Perform end-to-end link simulation for all Bluetooth waveform types, in the presence of RF imperfections
- Analyze Bluetooth/WLAN coexistence and interference
- Perform positioning operations with angle-of-departure (AoD) and angle-of-arrival (AoA) estimation
- Model, simulate, and analyze Bluetooth LE and Bluetooth Mesh networks
- Perform transmitter and receiver verification tests according to the Bluetooth specifications
- Model, simulate, and analyze the Bluetooth Classic protocol stack
- Model Bluetooth LE channel selection algorithms, Bluetooth Classic frequency hopping algorithms, and Bluetooth LE device connection procedures
- Model the effectiveness of LE Audio
- Learn about the new Bluetooth® Toolbox
About the Presenter
Mike McLernon is an advocate for communications and software-defined radio products at MathWorks. Since joining MathWorks in 2001, he has overseen the development of PHY layer modeling and SDR connectivity capabilities in Communications Toolbox. He has worked in the communications field for over 30 years in both the satellite and wireless industries. Mike received his BSEE from the University of Virginia and his MEEE from Rensselaer Polytechnic Institute.
Recorded: 23 Mar 2022
Hello, my name is Mike McLernon. I'm a technical marketing engineer at MathWorks. I've been at MathWorks for the last 20 years, developing and advocating for our many wireless software products. I've been deeply involved with Bluetooth since 2018. Today, I'll be sharing with you about simulating Bluetooth systems in MATLAB using the new MathWorks Bluetooth Toolbox.
Here are the areas we'll be covering today. They cover a broad swath of Bluetooth design concerns from point-to-point link communications, to localization accuracy, to the system-wide performance of networks with, and without, interference. So let's get started.
So what are some of the design challenges faced by Bluetooth engineers? Let's talk about a few of them. First, Bluetooth transceivers are in millions of devices. Phones, speakers, sensor networks. For all of the chips and modules being developed, a tester or testing rig must verify that the transceiver chips meet the Bluetooth specs.
For that, you need to accurately model Bluetooth waveforms. To add more color to the picture, Bluetooth links must be robust to suboptimal conditions. Any Bluetooth receiver will be subject to RF impairments like phase noise, amplifier nonlinearities, and IQ imbalances. A design engineer needs to be able to model those effects.
Second, Bluetooth must coexist with Wi-Fi, which is as equally ubiquitous as Bluetooth. Both the Bluetooth system engineer and a Wi-Fi system engineer needs to determine how his or her system will perform in the presence of interference from the other system. Here again, accurate physical layer and protocol layer modeling is essential to the task.
Again, adding more detail, Bluetooth typically avoids Wi-Fi interference by using adaptive frequency hopping, or AFH. These AFH algorithms can be implemented in many ways. So an engineer needs to model the frequency hopping in the context of a larger system, and be able to easily tweak the algorithm.
Third, with the arrival of Bluetooth 5.1 and 5.2, important new capabilities appeared in the standard. Mesh networking enabled Bluetooth to handle smart building applications like networked industrial lighting, localization techniques like angle of arrival or AoA, and angle of departure, or AoD, enabled highly accurate positioning.
And LE audio improved the quality of Bluetooth audio, and enabled new use cases for hearing aids, multi-streaming, and broadcasting. Systems that implement mesh, AoA, and LE audio must be modeled in software to assess performance before a commitment to hardware is made. So why is Bluetooth modeling in MATLAB important?
Because MATLAB facilitates easy design exploration at the link and network levels. Because MATLAB makes an implementation transparent to an engineer. Because MATLAB enables easy coexistence modeling between Bluetooth and Wi-Fi. Because MATLAB provides visualization capabilities that give insight into system performance.
Bluetooth Toolbox meets these challenges in the following ways. It enables standards-based golden reference waveform generation, that can be used to test transceiver chips. These waveforms can be visualized in the time, frequency, and constellation domains. It also provides end-to-end, point-to-point link simulations examples for all the variants of Bluetooth.
These variants include Bluetooth classic, or basic rate and extended data rate, and Bluetooth Low Energy, or LE. The link simulations model realistic RF environments that really exercise a receiver design, and the reference receiver designs compensate for those impairing RF effects.
Bluetooth Toolbox also addresses real world receiver design with its signal recovery and analysis examples. It enables over-the-air transmissions, and reception by working in concert with software defined radios, or SDRs. These SDRs don't mimic RF effects, they are the RF effects.
As for analysis, the Toolbox provides multiple test examples that enable transmitter and receiver evaluation, according to the specification set out by the Bluetooth special interest group, or SIG. The SIG is the Bluetooth standards body, and those test examples adhere to the test procedures specified by the SIG.
The Toolbox further enables Bluetooth analysis by addressing Bluetooth and WLAN coexistence. Since both those systems operate in the 2.4 gigahertz unlicensed frequency band, they can easily interfere with one another, and assessing the performance of one system in the presence of the other is a critical concern.
The Toolbox models that coexistence with the great level of detail, providing confidence in the results. The Toolbox also enables you to assess the Standard's capability to locate a Bluetooth node in 2 or 3D-space with multiple examples on localization. These examples are highly interactive, and allow for parametric sweeping of many design choices.
Finally, Bluetooth Toolbox enables you to simulate networks, not just links. Whether those networks employ piconets, Bluetooth mesh, or LE audio, the Toolbox simulates them all and gives you insight into how they perform in a variety of conditions.
Some Bluetooth Toolbox benefits include fully tested and documented functions, and examples that support up to release 5.3 of the standard. As the standard evolves, we are committed to tracking it and keeping the Toolbox up to date with it. Also features in examples that model and simulate multiple protocol layers, like the PHY, the link layer, and the L2CAP.
Although most of the toolbox's focus is on layer 1 and layer 2, you will find an example or two that model all the way up to the application layer. Beyond that, the Toolbox offers full open MATLAB source code for all of its functionality. The code can be easily searched, debugged, and extended. The video on the right shows how easy it is to navigate between functions in a shipping example. The open MATLAB code accelerates your understanding of the standard and your ability to experiment with it.
In addition, the Toolbox offers extensive documentation in several dimensions. If you need some tutorial information to understand the protocol stack, or Bluetooth mesh, or the packet structure, or angulation-based positioning techniques, go to the doc. The tutorials are extensive and easy to understand.
Also, the documentation carefully describes each function or object in the Toolbox with examples showing how to use each one. And the Toolbox doc offers numerous system-level examples that enable you to model in-building networks and mesh routing behavior, among other things. Also, if you want to share your Bluetooth Toolbox application with a colleague who doesn't have the Toolbox, you can use MATLAB Compiler to create a deployable executable, that does not need MATLAB to run.
And finally, if you want to run a lengthy bit error rate simulation and you need to accelerate it, you can use MATLAB Coder to generate C code from the Toolbox MATLAB code. The generated code will often give you an appreciable speed up.
So let's dive more deeply into waveform generation and end-to-end link simulation. These capabilities focus on Bluetooth's physical layer. Regarding waveform generation, Bluetooth Toolbox offers a complete spanning set of all possible waveforms. Both Bluetooth classic and low energy are covered.
All possible modulation and coding schemes are modeled, and you can also populate the Bluetooth packets with the bits that you want to cover all possible scenarios. Once you generate those waveforms, you can visualize them in the frequency domain as here, or the time domain, or with constellations in IQ space.
Along with the transmitter side of the link, the Toolbox offers reference receiver designs that can be used to calculate bit error rate and packet error rate of any Bluetooth link. These links can be simulated with a variety of RF effects that model actual hardware behaviors.
In addition to the effects listed in the first bullet, you can simulate memoryless amplifier nonlinearities, or nonlinearities with memory. And if you need to compensate for those nonlinearities with digital predistortion, you can do that too.
Unlike 5G WLAN, the Bluetooth standard does not specify a channel model that is unique to Bluetooth. However, the Range Calculator on Bluetooth.com does mention some path-loss models used to calculate expected Bluetooth device ranges for home, office, factory, and outdoor environments. These models are incorporated into examples in the Toolbox so that you can do some range calculations of your own.
Let's move on to design verification and signal recovery and analysis. These practical receiver examples, which address both classic Bluetooth and LE, help you with your receiver design verification use case. The examples provide a reference receiver design that achieves acceptable BERs and PERs.
However, if you have a better carrier frequency offset correction algorithm, or timing synchronizer loop, then you can replace the code in the examples with your own. Then, using the BER and PER results, you can assess the effect of your design change. And as we've said earlier, these designs can be exercised by realistic channel and hardware conditions.
Model multiple flavors of path loss, add imperfect local oscillators, insert an amplifier with a highly nonlinear AM to AM and AM to PM characteristic. You get to choose how finely you want to model your system.
The Bluetooth standard specifies several dozen physical layer tests that every Bluetooth device must pass in order to be qualified by the standards body or SIG. These tests cover both the transmitter and the receiver. The transmitter tests address performance characteristics like power control, spectral occupancy, and modulation purity. The receiver tests cover areas like sensitivity, BER in the presence of interference, dynamic range, and phase coherency for AoA and AoD calculations.
The Toolbox offers examples that replicate the test conditions specified by a subset of these SIG specified tests. The slide lists the categories that are currently covered. The examples can be used as a pre-conformance mode in the early stages of transceiver chip design. Although MathWorks does not plan to certify Bluetooth devices as being standard compliant, we can help you along that path by providing you with a test suite that you can adapt for your own purposes.
Now, the best way to prove that a transceiver design works is to try it over the air. If your software receiver can successfully demodulate bits from your hardware tuner and down converter, then your confidence in that software receiver grows. Bluetooth Toolbox includes LE and classic Bluetooth transceiver examples that use the PLUTO SDR radio, to both transmit and receive.
These inexpensive radios, which have an RF range up to 6 gigahertz, enable hardware testing where the signal experiences actual channel impairments, not simulated ones. MathWorks provides radio IO support for the PLUTO SDR through a hardware support package. You can download the support package for free.
Now let's move on to the very important use-case of modeling coexistence, typically between Bluetooth and WLAN. Bluetooth WLAN coexistence is a phenomenon that requires modeling at both the physical layer, and the MAC layer. And for now, let's talk about non-collaborative coexistence, which occurs when one device transmits Bluetooth, and a different device transmits WLAN.
Physical layer modeling is needed to simulate the RF waveforms colliding in the ether, and then affecting receiver synchronization, bit decoding, and BER performance. MAC layer modeling is needed to simulate the avoidance tactics that Bluetooth must take to escape getting compromised by the WLAN signal.
These avoidance tactics take the form of adaptive frequency hopping, or AFH. Bluetooth, which always performs frequency hopping, senses the quality of each of the 79 frequencies over which it hops. If it senses that the quality of a channel is poor, then it will not hop to that channel as it goes through its hopping sequence.
Over time, the AFH algorithm can enable the Bluetooth signal to completely avoid the much wider bandwidth WLAN signal, as you see happening in the spectrogram. Bluetooth Toolbox enables you, through extensible examples, to compare channel selection algorithms, or even to create your own.
It also enables you to create a multi-mode Bluetooth piconet that requires a scheduler for the central node to allocate transmit time for each of the peripheral nodes. Then you can impair the piconet with WLAN interference, and evaluate quality of service metrics like latency, and packet delivery ratio, in the presence of the interference. You can then alter and assess different schedulers to find which one has the best QoS.
Continuing on the coexistence theme, the Toolbox enables you to finally model the WLAN interference. Construct standard compliant 802.11 packets, then add error control coding, and OFDM modulation, and send the packets at random intervals to mimic the asynchronous, bursty nature of a WLAN signal. Once you create, configure, and run your Bluetooth and WLAN networks, you can calculate numerous statistics on that network, like BER, per channel success rate, overall package delivery ratio, and throughput. And it's straightforward to assess network performance with and without interference.
So let's move over to MATLAB now and actually run an example that performs a coexistence analysis between Bluetooth and WLAN. So as the title indicates, this is a non-collaborative situation. So you've got one device emitting Bluetooth, and another device emitting WLAN. So this is actually pictured quite nicely in this picture.
So you've got a central, a peripheral, and WLAN interference. Very simple network, but it illustrates the effects very, very nicely. So let's go ahead and start running the code. First thing we're going to do is configure the scenario. So one thing to note here, is that the positions of the Bluetooth nodes are actually specified. So this is a spatially aware simulation so that it knows how to handle path loss. So that's very, very helpful. Very realistic. So let's continue on.
Then we add application traffic. So basically, this is just an on off traffic situation, but it specifies when data is being transmitted and when it is not. But it's important to note that this is specified at the MAC layer and not at the PHY layer. So we specify the application traffic as simple on off, then we add WLAN interference. We note that this is true right here, and it is actually going to be taken from a baseband file. So it's previously been generated from WLAN Toolbox, so this helps to accelerate the simulation.
Now we want to schedule the channel classification. So remember, the channel is classified at a rate that is far less than, say, the frequency hopping rate that goes on within the simulation. So as the central classifies those channels, then it starts to avoid those problematic interference ridden frequencies. So we go ahead and schedule that classification, and then we just start running the simulation.
And here you see, in the bars that look like half sine waves, those are representing Bluetooth channels. And the signal indicated by the dark green, that's where the Bluetooth is being transmitted, and the red indicates where channels have been noted as being bad. So this will progress for a little while, and we will go ahead and fast forward it. And now we see with the simulation complete, all those green half sine waves indicate good channels to transmit on. The reddish channels, which are right below the dark blue WLAN occupied frequencies, those are all colored red because those are bad frequencies to transmit on.
So the central has successfully sensed and classified all of the good and the bad channels. And then if we continue on towards these plots here, they are very, very telling. So this first one shows the packet-loss ratio across different transmission epics. So you see that the loss ratio decreases every time because the central node is getting a better and better idea of which are the good channels, which are the bad channels. Until finally, it knows pretty well what to avoid. What frequencies to avoid.
And this lower plot essentially tells the same story through another way, where here the y-axis is throughput in kilobits per second. And you can see the aggregate throughput of the network grows every time that channel is sent. So you can see the AFH, the adaptive frequency hopping mechanism, is working very, very well.
Let's move on to localization or positioning. Bluetooth is one of many wireless standards that now boasts localization capabilities. Other terrestrial wireless systems like 5G, 802.11, and ultra wideband, or UWB, offer positioning features. The unique element of Bluetooth in this arena though, is the ubiquity and low cost of Bluetooth devices.
An exciting development in Bluetooth 5.1 is the introduction of high-fidelity localization features. First ratified in early 2019, these features utilize AoA and AoD to estimate a node position to well-below a meter of accuracy. This is done with triangulation techniques as shown in the slide. These localization features enable myriad use cases, indicating where people are in an airport or a shopping mall, asset tracking through an assembly line, and event even path planning for a robot.
They use special Bluetooth nodes called locators to send or receive signals for that localization processing. The Toolbox waveform generator and ideal receiver includes the extra bits of data required to perform this AoA and AoD processing. Specifically, it models the constant tone extension, a brief sine wave that's used to establish phase differences between transmit or receive antenna array elements.
So let's look more closely at how Bluetooth Toolbox has addressed localization modeling. These graphics show the techniques used to calculate AoA and AoD. For AoA, the locator receiver requires multiple antenna array elements. For AoD, the locator transmitter requires multiple antenna array elements.
As mentioned before, these AoA and AoD capabilities require that the Bluetooth LE waveform itself, uses an additional field in its packet structure, called the constant tone extension or CTE. This field transmits a pure tone whose wavelength is known. As the equations on the slide indicate, the wavelength lambda, the known distance d between antenna elements, and the measured phase difference psi between elements can be used to calculate theta or AoD, and beta or AoD. Functions and objects in the Toolbox enable you to define transmitter or receiver antenna arrays to populate the CTE field with usable data, and to process that receive CTE data to estimate AoA and AoD.
If you set up your simulation with your antenna array at the transmitter, use AoD to calculate position. If the array is at the receiver, use AoA. If multiple locator nodes are available for location processing, use triangulation techniques. If only one locator node is available, use a distance estimate based on received signal strength in conjunction with an AoD estimate.
With the localization examples provided by Bluetooth Toolbox, you can assess predicted location accuracy as a function of received SNR and the number of locators available. For the very common use case of tracking a moving object, you can use an example to assess the improvement provided by data fusion with estimates from a Kalman filter. The Kalman filter is a well known linear estimator for dynamic system behavior, and has been used in guidance and tracking applications for decades.
So let's go to MATLAB again, and this time run a localization example. This is going to be Bluetooth LE direction finding and tracking. So we're going to be using triangulation techniques to recover the position of a node, moving in this case in 2D-space. And so this picture actually shows very well what's going to be happening.
So we'll be using the technique on the right, which is we're going to have multiple locators, and then we're going to use angle of arrival in order to get angulation techniques to find the node to be located. So let's go ahead and start running this.
So we want to specify the simulation parameters. We're going to have the motion model to be 2D constant velocity. Again, AoA. Our physical mode in for LE is going to be one megabit per second. We're using a ray so we have to specify an element spacing in terms of lambda, the wavelength. And then we also need to specify an EbNo. So this EbNo of 25 dB is rather high, but this is something that you can experiment with as you run the example.
So let's go ahead and continue. So now you see the block diagram of the system at large. So you've got, at the very top level, transmitter channel receiver, and then angle and distance estimation, and then color-coded the transmitter channel and receiver. You see all the impairments that the channel imposes on the system. That is a fair amount. So you can tweak those to your heart's content.
And since we're using AoA, we'll use antenna switching at the receiver, and then perform all of the synchronization and demodulation operations to finally get that CRC detector and do location processing. So we're going to go ahead and run that as well. So now we're getting to the simulation part, and this is simply the textual and code implementation of the block diagram that we just looked at.
So we'll go ahead and run this. So we generate the PDU. We use AoA, and our channel imposes a frequency offset, a timing offset, a DC offset, and a path loss. And then our receiver performs all of these dmod functions in all the code that you see here. And then we'll just visualize the results.
And we see here the node is moving through 2D space. The locator nodes that are being used are lighting up in yellow. And you see that as the node to be located gets out of certain locators close distance, they turn back to blue, meaning that they're not being used anymore. And so we can also take a look at the accuracy of this positioning error and we see that in this vector here, that the rough average positioning error is only about 0.2 meters. So that's very, very good. And that's useful for many, many different applications.
Let's now cover the broader topic of network modeling. When you perform co-existence modeling, or localization, you implicitly perform network modeling, but this subject deserves treatment all its own. Let's dive in. The first step in Bluetooth network modeling is to populate the packets with header information from each layer. Towards that end, the Toolbox enables you to generate Bluetooth LE link layer, logical link control and adaptation protocol, generic access profile, and the attribute protocol layer, protocol data units, or PDUs.
You can also decode those same PDUs at the receive end. Also, while the Toolbox focuses on the lower layers of the stack, you can also model all the way up to one specific profile in the application layer, the heart rate profile. The example that performs this modeling uses the generic attribute protocol layer, or GAP, in a client server scenario.
When you want to generate traffic, you can create multiple kinds of connections. Synchronous connection-oriented, or SCO, and asynchronous connection-oriented, or ACL. The SCO connection is a circuit switch connection that reserves slots between a central node and a specific peripheral node. The ACL connection provides a packet switch connection between the central node and all active peripheral nodes participating in the piconet. ACL supports both asynchronous and isochronous services.
The Bluetooth SIG introduced mesh network specifications in Bluetooth 5.1 in 2019. Mesh networks are peer-to-peer networks that operate without the central peripheral architecture that Bluetooth had always specified until that time. System designers use Bluetooth mesh for applications such as building automation, sensor networks, industrial lighting, and smart homes. Designers use Bluetooth mesh because of its low energy consumption, coverage area extension through multi-hop communication, high system reliability through redundant message routes, and low network latencies.
With the Toolbox, you can explore mesh behavior using extensible examples. These examples enable you to configure a mesh network, and specify which nodes are power-limited, and which ones are not. You can also specify the nodes that participate in managed flooding, which enables network reliability when other individual nodes fail. You can calculate energy usage in mesh nodes, which can be critically important when these networks are meant to operate unattended for years.
Use these examples to calculate statistics on packet delivery ratio in latency, and determine which nodes in the network are the critical ones. Finally, you can use powerful MATLAB graphics to visualize the behavior of a mesh network as it evolves, as packets progress from source nodes to destination nodes.
When a Bluetooth network associates multiple peripheral nodes with one central node, the central must schedule its communications with each peripheral. Bluetooth Toolbox enables you to model a round-robin scheduler for this application, or to define your own. Through an extensible example, you can model multiple types of traffic to examine their effect on network performance.
The example supports SCO circuit switch packets, and ACL asynchronous or isochronous packets. When you run the simulation, collect statistics that measure quality of service. Statistics like packet error rate, throughput, and latency. You can simulate conditions with or without interference, and with or without RF impairments.
One of the important aspects of network modeling is that it's really helpful for the simulator to be spatially aware. In the Bluetooth use case, which is primarily indoor, that means the simulation should know how many walls or floors the signal penetrates. It should be able to calculate signal power losses through the air, and through those walls.
Bluetooth Toolbox enables you to create and configure just such an indoor scenario as the graphic on the slide indicates. Once again, the Toolbox accomplishes this with an extensible example. Then for an LE audio use case, you can configure broadcast isochronous group or big parameters.
The big parameters define how many synchronized links are established between centimeter node and up to 31 peripheral nodes. Once you create the indoor scenario, you can simulate the network with or without WLAN coexistence. The WLAN interference will occasionally collide with Bluetooth packets and force re-transmissions.
This will affect the system latency and packet delivery ratio, which you can measure and visualize via a heatmap. This is quite useful to assess LE system design for the audio application. And even though the example defines a path loss model, you can create your own custom model to better reflect the environment that you care about.
Packet capture, or PCAP files, and PCAP next generation, or PCAPNG files, are often used for bit level network analysis. These files can be read by third-party software packages to determine whether all the bit fields are properly populated. Bluetooth Toolbox enables you to write Bluetooth LE packet data at the link layer to those PCAP and PCAPNG files. This could be very useful if you captured a Bluetooth waveform over the air with an SDR device, then wanted to ensure that number one, the receiver decoded all the physical layer bits correctly, and number two, the MAC headers are correct.
Let's recap what we've discussed so far. First, Bluetooth Toolbox enables you to perform full physical layer modeling of Bluetooth waveforms. It covers all the waveform variants, and allows you to perform sophisticated linked simulation by incorporating a wide variety of channel effects and RF impairments.
Second, you can model Bluetooth coexistence with WLAN systems. With the proliferation of Bluetooth and Wi-Fi enabled devices, interference possibilities are very common and they need to be analyzed. Bluetooth Toolbox, in conjunction with WLAN Toolbox, can perform this analysis by modeling both at the bit level and the protocol level. And you can use powerful MATLAB graphics to gain insights on what is happening with the waveform and the bits.
Third, you can model networks with a high degree of fidelity and perform multi-user simulations that account for imperfect channels, adaptive frequency hopping, and scheduling algorithms. Model both piconets that use the traditional central peripheral network topology, and peer-to-peer mesh networks that put a premium on reliability and energy savings.
Fourth, you can perform all these analyses and simulations with open MATLAB code. You can inspect the code, debug through the code, and even extend the code to suit your particular application. Bluetooth Toolbox lets you focus on design and verification.
To learn more, you can navigate your browser to MathWorks.com/products/bluetooth to find a fuller description of the Toolbox. You can watch the Bluetooth Toolbox videos, one of which gives a brief overview of the product, and one that describes the applications and MATLAB implementations of Bluetooth Low Energy. For a broader look at the wireless solutions provided by MathWorks dealing with technologies like 5G and WLAN, simulation techniques that span digital, RF, and antenna components, and hardware implementations of the models you create, please see mathworks.com/solutions/wirless-communications. Thank you.