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

BLE sensor speed

Hi there. I'm making a sensor system which is intended to measure an ADC value, and send it using the Heart Rate Sensor template. To make this, I've rebuilt the ble_app_hrs to send an ADC value instead of the simulated values it generates. I've set the following parameters:

#define HEART_RATE_MEAS_INTERVAL         APP_TIMER_TICKS(1, APP_TIMER_PRESCALER)
#define SENSOR_CONTACT_DETECTED_INTERVAL APP_TIMER_TICKS(1, APP_TIMER_PRESCALER)
#define MIN_CONN_INTERVAL                MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL                MSEC_TO_UNITS(8.75, UNIT_1_25_MS)
#define SLAVE_LATENCY                    0

, since these seems to be the fastest possible. Then I've set

heart_rate = adc_sample;
err_code = ble_hrs_heart_rate_measurement_send(&m_hrs, heart_rate);

in the heart_rate_meas_timeout_handler.

I then connected a sine wave generator to the ADC input, connected the collector board (a PSoC 4) to a DAC (MCP4921) with a 1 MHz SPI exchange rate, and measured the DAC output. This DAC has previously supported up to 300 kHz in another related project. This is what I get on the DAC output when I set the sine wave generator to 10 Hz and 100 Hz respectively:

http://prnt.sc/de19as

http://prnt.sc/de19r2

The 10 Hz signal looks more or less fine, but the 100 Hz one does not. Earlier on I had the APP_TIMER_TICKS set much higher than 1 and had poor results, so this did seem to be the limiting factor. Is there a way to eliminate the need for these timers entirely, and just set the immediate ADC value as soon as it's ready? When I tried putting the ble send command into the looped power_manage function, nothing seemed to be happening!

Hope I've explained the problem properly, thanks!

Parents
  • I didn't have an ADC event handler in the previous code, but I added

    NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH); NVIC_EnableIRQ(ADC_IRQn);

    in the adc_config function, and then added

    void ADC_IRQHandler(void)
    {
          int32_t         err_code;
    	  uint16_t        heart_rate;
    	
        nrf_adc_conversion_event_clean();
        adc_sample = nrf_adc_result_get();
    		heart_rate = adc_sample;
    
        err_code = ble_hrs_heart_rate_measurement_send(&m_hrs, heart_rate);
        if ((err_code != NRF_SUCCESS) &&
            (err_code != NRF_ERROR_INVALID_STATE) &&
            (err_code != BLE_ERROR_NO_TX_PACKETS) &&
            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
            )
        {
            APP_ERROR_HANDLER(err_code);
        }
    }
    

    as a new handler. I removed all timers and timer handlers. I then ran the code, and didn't get any data out; the collector didn't even connect to the sensor. What is wrong?

Reply
  • I didn't have an ADC event handler in the previous code, but I added

    NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH); NVIC_EnableIRQ(ADC_IRQn);

    in the adc_config function, and then added

    void ADC_IRQHandler(void)
    {
          int32_t         err_code;
    	  uint16_t        heart_rate;
    	
        nrf_adc_conversion_event_clean();
        adc_sample = nrf_adc_result_get();
    		heart_rate = adc_sample;
    
        err_code = ble_hrs_heart_rate_measurement_send(&m_hrs, heart_rate);
        if ((err_code != NRF_SUCCESS) &&
            (err_code != NRF_ERROR_INVALID_STATE) &&
            (err_code != BLE_ERROR_NO_TX_PACKETS) &&
            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
            )
        {
            APP_ERROR_HANDLER(err_code);
        }
    }
    

    as a new handler. I removed all timers and timer handlers. I then ran the code, and didn't get any data out; the collector didn't even connect to the sensor. What is wrong?

Children
No Data
Related