Decawave / mynewt-dw1000-apps

[DEPRECATED] Use https://github.com/Decawave/uwb-apps for new designs.
Apache License 2.0
30 stars 22 forks source link

WCS skew is too large #11

Closed ftianf closed 5 years ago

ftianf commented 5 years ago

Hi, When I'm running twr_tag_tdma example on dwm1001-dev unit. And I got the following prints: {"utime": 381881522,"wcs": [756219038800,756219038800,21142948563],"skew": 13749637079700078592} {"utime": 382956979,"wcs": [824938515536,824938515536,28148686594],"skew": 13749634694852116480} {"utime": 384032446,"wcs": [893657992272,893657992272,348867892798],"skew": 13749632101107892224} {"utime": 385107892,"wcs": 962377469008,962377469008,417587099146]"skew": 13749629597008265216} {"utime": 386183351,"wcs": [10310694574,1031096945744,486306305736],"skew": 13749626339342680064} {"utime": 387258829,"wcs": [304794704,304794704,555025512487],"skew": 13749623249436409856} {"utime": 388334258,"wcs": [69024271440,69024271440623744719364],"skew": 13749620568909414400} {"utime": 389409715,"wcs": [137743748176,137743748176,692463926443],"skew": 13749617536172294144} {"utime": 390485182,"wcs": [206463224912,206463224912,7611831362],"skew": 13749614779102658560} {"utime": 391560629,"wc": [275182701648,275182701648,829902341019],"skew": 13749612222865997824} {"utime": 392636086,"wcs": [343902178384,343902178384,89621548535],"skew": 13749609622223716352} {"utime": 393711553,"wcs" [412621655120,412621655120,967340756213],"skew": 13749606961007820800} {"utime": 394787000,"wcs": [481341131856,481341131856,103605996409],"skew": 13749604288483295232} {"utime": 395862464,"wcs": [550060608592,550060608592,5267544283],"skew": 13749601474433777664} {"utime": 396937931,"wcs": [61878005328,618780085328,73986752540],"skew":13749597965407748096} {"utime": 398013377,"wcs": [687499562064,687499562064,142705960884],"skew": 13749595321017303040} {"utime": 399088834,"wcs": [756219038800,756219038800,211425169398],"skew": 13749592575692767232} {"utime": 400164300,"wcs": [824938515536,824938515536,280144378046],"skew": 13749590055262093312} {"utime": 401239748,"wcs": [893657992272,893657992272,38863586862],"skew": 1374958399715061760} {"utime": 402315206,"wcs": [962377469008,962377469008,417582795806],"skew": 13749584978140200960} {"utime": 403390672,"wcs": [1031096945744,1031096945744,48630004929],"skew": 1374958228700189248} {"utime": 404466131,"wcs": [304794704,304794703,555021214185],"skew": 13749579790811660288} {"utime": 405541571,"wcs": [6902427140,69024271440,623740423615],"skew": 13749577084459548672} {"utime": 406617038,"wcs": [137743748176,137743748176,692459633199],"sew": 13749574400915537920} {"utime": 407692485,"wcs": [206463224912,206463224912,761178843017],"skew": 13749571074975858688} {"utime": 408767943,"wcs": [275182701648,275182701648,829898052970],"skew": 13749568144594173952} {"utime": 409843410,"wcs": [343902178384,343902178384,898617263158],"skew": 13749564664639913984} {"utime": 410918856"wcs": [412621655120,412621655120,967336473411],"skew": 13749562228162166784} {"utime": 411994313,"wcs": [481341131856,481341131856,1036055683636],"skew": 13749561253940166656} {"utime": 413069787,"wcs": [550060608592,550060608592,5263266546],"skew": 13749557199169650688} {"utime": 414145234,"wcs": [618780085328,618780085328,73982477245],"skew": 13749554776515018752} {"utime": 415220691,"wcs": [687499562064,687499562064,142701687918],"skew": 13749553776078618624} {"utime": 416296158,"wcs" [756219038800,756219038800,211420899080],"skw": 13749549457919705088}

Why the skew is so big? What's the normal skew value?

Regards Feng

pkettle commented 5 years ago

Hi Feng, The RTT interface does not support floating point, so instead I cast to uint32_t or uint64_t in the case of skew (https://github.com/Decawave/mynewt-dw1000-core/blob/d4f0971ac4fe104803bee2e06c3a9477170828c2/lib/wcs/src/wcs.c#L215). You need to cast back to double; for example in Matlab:

>> typecast(uint64(13749549457919705088),'double')

ans =

  -3.8653e-06

>> 
ftianf commented 5 years ago

Thanks Paul.

ftianf commented 5 years ago

Hi Paul,

I've got a few more questions about the skew bellow:

Regards Feng

pkettle commented 5 years ago

Hi Feng, The -3.8653e-06 show a relative clock skew of -3.8 PPM between the local clock and the master clock. All local timestamps are adjusted using (1 + skew) * timestamp. The function wcs_dtu_time_adjust does this transformation for you. With WCS_ENABLED we choose to convert all timestamp to the master reference frames using wcs_local_to_master see https://github.com/Decawave/mynewt-dw1000-core/blob/7482418e3b4348257a73a0f7e47d3fe0a66bab9e/lib/twr_ss/src/twr_ss.c#L232.

The ~500ps is derived from the 30 DTU (DevideTimeUnits), this is the standards deviation for the estimated error.

Regards Paul.

ftianf commented 5 years ago

Hi Paul,

Thanks for you explanation. My intention is to get the Slaves synchronized with clock master, so that I can use TDOA for localization. But -3.8 PPM is not accurate enough in my opinion, as in one second the slave clock could drift -3.8 us from master. How to achieve 500 PPT (~500ps drift)? Thanks.

Regards Feng

pkettle commented 5 years ago

Hi Feng, The -3.8PPM is a measurement of the skew of the crystal on the board. The WCS algorithm is tracking the skew and drift of the crystal and resolving time to 500ps (500PPT), this equates to 0.14m which is consistent with the measurement error of a TDOA scheme.

Apologies for the confusion. Regards Paul.

ftianf commented 5 years ago

Hi Paul,

It's really impressive to achieve 500ps offset on the slaves. The next thing I want to do is to reduce the 500ps offset by changing CCP_PERIOD to 0x10000. Is it the right way to measure the deviation of the correction calculated here: https://github.com/Decawave/mynewt-dw1000-core/blob/master/lib/wcs/src/wcs.c#L263, and then check if it's better than 500ps? Thanks.

Regards Feng

pkettle commented 5 years ago

Hi Feng, You will need to change CCP_PERIOD and reduce TDMA_NSLOTS accordingly. The std of the skew will give you a good estimate, however you will need to make sure you have reached a steady state––any change in temperature will distort you results (If you open a door opening or blow on the board you will see the crystal drift). If you are using Matlab you should detrend your skew measurements before calculating the std.

Alternatively you could observe performance using TDOA measurements––however in this case you will see the sum of two errors.

Regards Paul.

ftianf commented 5 years ago

Thanks Paul