# DWM1001 spacing of raw distances

Hello,
Im trying to write a location-algorithm for the DWM1001-modules in Matlab. I get the raw-distances from each tag to its 4 anchors over mqtt-messages. First i’m trying do do some statistics. I find there is a spacing in the data. Not every milimeter is measured, there is a space, sometimes 4 mm, sometimes 5 mm. In the data I collected in tests. It averages to something like 4.68 mm. I believe it has to do with the duration of a clock-cycle and some rounding. But for my work and curiosity, does anybody know the exact average-space and the reason?
Thanks horst

… if one devides the speed of light in air by the observed 4.68mm, the result is about the UWB-frequency.
That even makes some sense.

Hi Horst,

just for curiosity, what did you mean with “Not every millimeter is measured, there is a space, sometimes 4 mm, sometimes 5 mm”?

Thanks,
Cheers, TDK

Hello TDK,

I hope a Picture tells more than words:

The Raw-Distances come as integers, so i expected the width of the whitespace to be 1 mm, but they are 4 and 5 mm wide…

cheers horst

Hi Horst,

I am having difficulties to understand the picture. In which units are the axes?

Thanks,
Cheers, TDK

So you are saying that there is a quantization in the distance number that is larger than the output resolution of 1 mm?

This is to be expected.
Internally the DW1000 has a timing resolution of around 15.65 ps. If you multiply that by the speed of light you get a distance resolution of around 4.5 mm.

hi TDK,
sorry, i forgot that. it’s basically the numbers as they come out of the unit.
from what i understand the [Y-axis-values] is ‘mm’ for the distance, and the [X-axis-values] is ’us’ from the time stamps.
to check deviation, i tried to create equal sized ‘bins’ and ran into the question…

cheers horst

thank you for the answer, i thought something like this

1 Like

Hi Horst,
You mentioned you have got the raw-distances from each tag to its 4 anchors over mqtt-messages. We want to do it too. Could you please share how you got these data?
Thank you!
Jeremy

Hi jeremycuo,

I’m not the best coder, so there might be better ways, but I added a few lines of code to the dwm-simple example:

``````void on_dwm_evt(dwm_evt_t *p_evt)
{

uint8_t len;
uint8_t i;
// Current Idc to store in data (2 bytes for id, 4bytes for timestamp)
uint8_t idx = 6;
// TimeStamp
uint32_t tim;

/* New location data */

tim=dwm_systime_us_get();
//IOT
memcpy(data_out+2,&tim,4);

memcpy(data_out+idx,&(p_evt->loc.anchors.dist.cnt),1);
idx = idx + 1;
// console
printf("\nT:%lu (0x%lx)\ti:%u",tim,tim, p_evt->loc.anchors.dist.cnt);

for (i = 0; i < p_evt->loc.anchors.dist.cnt; ++i)
{
idx = idx + 2;
memcpy(data_out+idx,&(p_evt->loc.anchors.dist.dist[i]),4);
idx = idx + 4;

}

dwm_evt_listener_register(
DWM_EVT_BH_INITIALIZED_CHANGED |
DWM_EVT_UWBMAC_JOINED_CHANGED, NULL);

// write just 31!
dwm_usr_data_write(data_out,31,false);

break;
...
``````

this wrote out the tag-timestamp, number of ancors, ancor-address, and distance on terminal and into Iot. (the 2 bytes of ID were written somewhere previously, and kept.)
hope it helps,
hørst

Hi horst,
Got it, we will try it.
Thank you very much for your help!
Jeremy