This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SensorTag Accelerometer Frequency Problems

hello,
I would like to increase the accelerations sampling rate up to 100Hz, but the values are transferred according BTool are only about 60Hz.

I've made the following changes in SensorTag.c:

#define ACC_DEFAULT_PERIOD  10

(before 1000)

// Minimum connection interval (units of 1.25ms, 80=100ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL     6

 (previously 80)

// Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL     20

 (previously 800)

Now I should receive a notification every 10ms, or not? But I get it every 15-16 ms, sometimes are also more than 30ms between them.

How can I solve this problem?

In addition, I would like to know what is the maximum transmit speed and whether there is a documentary in which I can read it.

I would be really grateful for the help

  • Hi Will,

    You are setting up sensor poll every 10ms, and connection interval to 7.5ms. These are not synchronized so typically you will send data every other connection event (~15ms). 

    I suggest you use 10ms connection interval (define 8 instead of 6) and the use the HCI_EXT_ConnEventNoticeCmd to setup a synchronization with the connection event. Essentially, this command tells the stack to call an application task which you can perform the acceleration sensor read in. Read more on how to implement this command in the Vendor Specific HCI Guide that comes with the BLE stack installer.

    PS. This means that you should remove the periodic reading of the acceleration data. The read will be done after every connection event.

    Best regards

    Joakim

  • I have a similar problem. In fact, I have modified the BLE stack a little and improved its frequency to about 35 HZ, but when I made it faster, I just got several continuous same data, so it just seems to be ''faster'', I do not know why.
    I would be really grateful for the help.

  • Hi Joakim, this suggestion makes a lot of sense and I'd like to incorporate it. But I'm a bit lost as to exactly which files to modify in the SensorTag project. In my fantasy it would be pretty straightforward: 

    1. Receive notification that the connection event has ended, as you suggest. Start reading from the FIFO without blocking. 
    2. When the next connection happens, copy the data into the ble buffer.
    OR 2a, pass the data back to blestack when the FIFO read completes (maybe faster? but maybe not really necessary) and let blestack take it from there. 
    Using the documentation you refer to, there is an example suggesting modifications to simple_peripheral.c. In the sensorTag project that seems to be paralleled by Profiles/peripheral.c. But I am clueless about how to get from there to Board/sensor_mpu9250.c and back.Apology in advance: I'm new to firmware and I am utterly confused by the system of callbacks, clocks, interrupts and other indirections in the Sensortag project.
    Can you give me some guidance? Which files will i need to modify? 
    Thanks! 
    Allan