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!

Related