This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reducing latency - BLE nano as MIDI controller

Hi All, I am building a wireless MIDI controller using the BLE nano v2.0 from RedBearLab. MIDI is a protocol to control software musical instrument, therefore latency needs to be <10ms and at the moment it ranges roughly between 20 and 100ms.

I am using UART service to send data between the BLE peripheral and the central device (my laptop). The way I test the latency is by sending a single number or character from the ble module (using the serial monitor) to a connection utility using UART (I am using the Bluefruit Connect from Adafruit).

I use Arduino IDE to upload the firmware on the board and I have already tried to decrease the connection interval to reduce the latency. It has improved with this modification, but is not short enough yet.

#define MIN_CONN_INTERVAL MSEC_TO_UNITS(1, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(1, UNIT_1_25_MS)

static Gap::ConnectionParams_t conn_params = {
  .minConnectionInterval = MIN_CONN_INTERVAL,
  .maxConnectionInterval = MAX_CONN_INTERVAL,
  .slaveLatency = 0,
  .connectionSupervisionTimeout = 10000
};

I noticed that sometimes the latency is short and sometimes is longer and that makes me assume there is a sort of period which controls how often packets gets sent, but I am not totally sure.

Do you know what other parameters or settings I can change in order to solve the issue?

I want to point out that I have already done this with the Adafruit Feather 32u4 with very short latency, therefore is definitively possible, but I need to use a smaller board.

Thanks in advance for any help!

  • It could be that your laptop just decides on some connection parameters, but that your feather automatically starts a new connection parameter update process requesting faster parameters while your RedBearLab just accepts the initial configuration. Some sniffer traces could help to prove this. Or you can look at your RedBearLab code and try to figure out whether that does this automatically too.

  • Hi Martin,

    I wanted to give an update on this as I changed strategy a bit.

    Basically I am trying to use the HID service to trigger sound. At the moment is okay as we are just testing usability.

    I am using Keil Univision and I have successfully uploaded the HID Nordic Example on the BLE nano and the latency now is much much better than before. However it is still noticeable.

    As you may have understood, I am not an expert user of these tools, so I wanted to ask if there are parameters in the HID example that I can change or even parts of the code that I can eliminate to make the communication faster.

    Thanks for any advice!

  • Hi,

    So I guess you need low latency, and not necessarily high throughput, right? Then the most vital parameter to tweak is the connection interval. The lower the better. Are you able to provide some sniffer traces? It would be interesting to see exactly which parameters are used and the differences between your two modules. You can use a spare Nordic development kit and our Sniffer solution

Related