# Timestamps of Time Difference of Arrival (TDoA)

Hi all,

I am trying to implement synchronization-free TDOA algorithm on DWM1000 modules. I have 3 anchors and 1 tag. Anchors are sending packets in interval of 50ms and tag is receiving all of it.
t = 0 Anchor1 sends
t = 50ms Anchor2 sends
t = 100ms Anchor3 sends …

#define DW1000_TX_TIME ((uint8_t)0x17) // Lens = 10, RO, Transmit Message Time of Sending

Here are the results:
t1: 640225137916
t2: 643692317108
t3: 646875066675

t1: 653260186804
t2: 656727000870
t3: 659909805111

This is how to find TDOA as I read on research:
tdoa_21 = t2 - t1 - tof_12 - Td21

tdoa_21 - tdoa from Anchor1 and Anchor2 at tag
t2, t1 - recorded timestamp of packet received from Anchor2 and Anchor 1 respectively.
tof12 - time of flight from Anchor1 to Anchor 2
(tof_12 = d21 / c, d21 - distance between anchors, c - speed of light)
Td21 - time delay between packets (50ms)

# CODE:

// Anchor locations
Anchor1 = [3.0, 1.0]
Anchor2 = [1.0, 4.0]

cl = 3 * 10 ** 8 // speed of light
time_unit = 15.65 * 10 ** (-12) // DWM time unit
uwb_s = 1.0256 // UWB second

T_d = 50 * 10 ** (-3) // time delay [s]
T_D21 = T_d * 1
T_D31 = T_d * 2

// distance between anchors [m]
d_21 = math.dist(L_anchor, C_anchor)
d_31 = math.dist(R_anchor, C_anchor)

// time of flight [s]
tof_21 = d_21 / cl
tof_31 = d_31 / cl

// measured timestamps
dtu_1 = 640225137916
dtu_2 = 643692317108
dtu_3 = 646875066675

// convert dtu to second
t_1 = (dtu_1 * time_unit) / uwb_s
t_2 = (dtu_2 * time_unit) / uwb_s
t_3 = (dtu_3 * time_unit) / uwb_s

// measured TDOA
tdoa_21 = t_2 - t_1 - tof_21 - T_D21
tdoa_31 = t_3 - t_1 - tof_21 - T_D31

// distance
dd_21 = cl * tdoa_21
dd_31 = cl * tdoa_31
print("L, R: ", L, R)

# Results

tof_21, tof_31 = 1.202e-08, 1.6666666666666667e-08
t_1, t_2, t_3 = 9.769426100219773, 9.822333036993173, 9.870899759617538
tdoa_21, tdoa_31= 0.0029069247534002987, 0.0014736427310985262
dd_21, dd_31 = 872077.4260200897, 442092.8193295578

I expect the tdoa to be in ns (e-9) and distance (dd) to be around 1.
Am I converting the timestamps to seconds right? What I am doing wrong?