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

Synchronisation with advertisement

Hello,

Im trying to create a synchronisation method for sensors using BLE. At the moment i can synchronise them within 10ms accuracy, in theory it should be within 2ms and i can not find this 7ms extra delay. This is my current synchronisation method:

At the sensor(using S110) i'm using the 16 bit timer1 with a resolution of 4us. I'm using a compare match to increment a variable(uint16 msec) within the time it overflows in this case 125ms. Just before the radio gets active(radio notification) i'm reading the current timer1 register and put this in another variable(uint16 usec) and set these time values in the manufacturer specific advertise data. So i'm now sure each time before the radio gets active a new value will be advertised. The advertising interval is set to 1s.

Now at the S120 device im scanning 100% so almost each second it will receive the timing of the sensor. I've measured this with the oscilloscope by setting a pin high when sending at sensor and receiving at S120 device. I've seen a variable delay of Δt 2ms this is noticed as the S120 scans on channel 37,38,39 (1ms inbetween these channels). Immediately after i've received the timing value from the sensor I read the timer1 register of the S120 device and calculate the difference between the S120 and sensor(S110). Now at the next compare event of the S120 device i'm setting a new compare register at timer1: normal compare register + difference (i've calculated the min / max of difference and this is within the timers resolution).

Now in theory i would expect to see a constant delay + Δt 2ms from scanning on 3 different channels. In fact i see the Δt differ within 10ms. Is there anything im missing? Hope someone can help me with this. I've attached some pictures showing the sensor and S120 device timer compare interrupt and zooms.

Regards, Pascal

2014-04-25 11.39.06.jpg

2014-04-25 11.39.57.jpg

IMAG0624.jpg

Advertise.jpg

Parents Reply Children
No Data
Related