ESB - net datarate with 2 MBit/s on-air data rate

Hi Håkon,

 this is my follow-up ticket as requested here:  RE: How to achieve NRF52840 ESB Maximum data rate 

You can see my setup in the esb_ptx application in https://github.com/stemschmidt/esb-evaluation.git

I am currently able to transmit the data that I want to transmit, but only with the 4 MBit/s on-air data rate. So I assume I am not using ESB efficiently, but the documentation is really thin.

You can see in the prj.conf that I tried CONFIG_ESB_NEVER_DISABLE_TX=y (which is now commented out) but that failed immediately. 

I also tried to use ESB_TXMODE_MANUAL to control the timing, but that did not work either:

    /** Manual TX mode: Packets are not sent until @ref esb_start_tx
     * is called. This mode can be used to ensure consistent packet timing.
     */
    ESB_TXMODE_MANUAL,

Please let me know if you find any stupid setting or handling in the project.

Best regards

Stefan

  • Hi Stefan,

     

    The overall RF payload will look something like this:

    | 1 byte Preamble | 3 to 5 bytes RF address | Packet control field | payload | CRC |

     

    So if we sum up the total on-air bytes, it will be approx. 5-10 bytes of overhead, depending on your settings.

    The on-air time will then be:

    40 us + 4 us per byte * (66 + 5) = 324 us

    Note that this excludes CPU handling, so the overall timing number will be higher than this.

     

    You have setup 320 us as the timing signal, wanting approx. 3125 payloads of 66 byte user data per second.

    On 2 MBit, I measure approx. 2679 payloads of 66 bytes each per second.

     

    Is a latency of 320 us per received payload a hard requirement for you?

    You can adjust the payload size to "#define NUM_SAMPLES 3*16U" and set prj.conf::CONFIG_ESB_MAX_PAYLOAD_LENGTH=252, which should allow you to send  one RF payload of 194 bytes (2+3*64) every 3*320 us at 2 MBit data rate.

     

    PS:

    I added a 1 sec timer, just to push the byte counter, and moved your semaphore for testing. Here is a patch:

    diff --git a/esb_ptx/src/main.c b/esb_ptx/src/main.c
    index 0942c7a..9802e81 100644
    --- a/esb_ptx/src/main.c
    +++ b/esb_ptx/src/main.c
    @@ -35,7 +35,7 @@ LOG_MODULE_REGISTER(esb_ptx, CONFIG_ESB_PTX_APP_LOG_LEVEL);
     
     #define ESB_RF_CHANNEL 10U
     
    -#define NUM_SAMPLES 16U
    +#define NUM_SAMPLES 3*16U
     typedef struct {
         uint16_t left;
         uint16_t right;
    @@ -48,7 +48,11 @@ typedef struct {
     
     static struct esb_payload tx_payload = {0};
     static void sample_handler(struct k_timer* timer);
    +static void esb_throughput_handler(struct k_timer* timer);
    +
     K_TIMER_DEFINE(sample_timer, sample_handler, NULL);
    +K_TIMER_DEFINE(timer, esb_throughput_handler, NULL);
    +
     static K_SEM_DEFINE(tx_sem, 1, CONFIG_ESB_TX_FIFO_SIZE);
     static int packets_handed_over = 0;
     static int packets_sent = 0;
    @@ -151,7 +155,7 @@ static int esb_initialize(void) {
         /* PTX Mode, only send. */
         esb_config.protocol = ESB_PROTOCOL_ESB_DPL;
         esb_config.mode = ESB_MODE_PTX;
    -    esb_config.bitrate = ESB_BITRATE_4MBPS;
    +    esb_config.bitrate = ESB_BITRATE_2MBPS;
         esb_config.crc = ESB_CRC_OFF;
         esb_config.use_fast_ramp_up = true;
         esb_config.payload_length = sizeof(audio_message_t);
    @@ -195,9 +199,12 @@ static int esb_initialize(void) {
         return 0;
     }
     
    +static uint32_t total_bytes_received;
    +
     void event_handler(struct esb_evt const* event) {
         switch (event->evt_id) {
             case ESB_EVENT_TX_SUCCESS:
    +            total_bytes_received += sizeof(audio_message_t);
                 if (packets_sent % 2) {
                     dk_set_led(PACKET_SENT, 0);
                 } else {
    @@ -212,9 +219,17 @@ void event_handler(struct esb_evt const* event) {
                 LOG_DBG("Packet received");
                 break;
         }
    +    k_sem_give(&tx_sem);
     }
     
    -static void sample_handler(struct k_timer* timer) { k_sem_give(&tx_sem); }
    +static void sample_handler(struct k_timer* timer) {  }
    +static void esb_throughput_handler(struct k_timer* timer)
    +{
    +    static uint32_t prev_byte_ctr;
    +    uint32_t diff_byte_ctr = total_bytes_received - prev_byte_ctr;
    +    printk("%d\n", diff_byte_ctr);
    +    prev_byte_ctr = total_bytes_received;
    +}
     
     int main(void) {
         int rc;
    @@ -251,7 +266,7 @@ int main(void) {
         LOG_INF("Sending test packet");
     
         k_timer_start(&sample_timer, K_USEC(320), K_USEC(320));
    -
    +    k_timer_start(&timer, K_MSEC(1000), K_MSEC(1000));
         while (1) {
             /* Prepare package. */
             for (int i = 0; i < NUM_SAMPLES; i++) {
    

     

    Kind regards,

    Håkon

     

     

Related