DWM1000 range varies too much

Hello,

I designed some PCBs with ATMEGA328P-PU and DWM1000 module. I am trying now to get the range between a tag and an anchor but when i run in Arduino the programs from dw1000 library, my range varies from -300 to 300.

03:07:31.307 -> from: FFFFF549 Range: -242.71 m RX power: -71.64 dBm
03:07:31.409 -> from: FFFFF549 Range: -56.41 m RX power: -58.12 dBm
03:07:31.511 -> from: FFFFF549 Range: -187.84 m RX power: -57.84 dBm
03:07:31.613 -> from: FFFFF549 Range: -286.01 m RX power: -58.92 dBm
03:07:31.715 -> from: FFFFF549 Range: 296.58 m RX power: -57.81 dBm
03:07:31.849 -> from: FFFFF549 Range: -83.67 m RX power: -57.84 dBm
03:07:31.917 -> from: FFFFF549 Range: 112.36 m RX power: -58.33 dBm
03:07:32.018 -> from: FFFFF549 Range: 320.41 m RX power: -57.69 dBm
03:07:32.121 -> from: FFFFF549 Range: 165.28 m RX power: -58.23 dBm
03:07:32.222 -> from: FFFFF549 Range: -140.41 m RX power: -62.76 dBm
03:07:32.324 -> from: FFFFF549 Range: 129.47 m RX power: -57.73 dBm
03:07:32.458 -> from: FFFFF549 Range: -131.71 m RX power: -58.07 dBm
03:07:32.526 -> from: FFFFF549 Range: 196.95 m RX power: -58.75 dBm
03:07:32.661 -> from: FFFFF549 Range: 47.89 m RX power: -59.11 dBm
03:07:32.729 -> from: FFFFF549 Range: 116.06 m RX power: -58.19 dBm
03:07:32.965 -> from: FFFFF549 Range: -217.70 m RX power: -57.78 dBm

These are the ranges i’ve obtained just right now, when my TAG and Anchor are just 0.5 meters apart. I uploaded the others programs with transmision signales and they worked. Any ideas?
I heard about antenna calibration, I read the sheet, but I dont know what that consist in. If that is what I need to do, can someone explain me what should I do?

Antenna calibration problems will give a constant offset, it won’t give random noise like this.

You said you tried other programs and they worked. That would indicate that there is a problem in your ranging algorithm. Some timing is either being measured incorrectly or is being assumed to be constant when it isn’t.
+/-300 m of variation in range relates to +/- 1 ms of time error somewhere.

And how can I solve this? I assume that this error is from the internal clock.

Did you load UCODE ?

No, the only code I uploaded on the microcontroller is from the dw1000 library, in Arduino. I dont know how to work with UCODE.

This is the library I’m using, without any modifications:

Edit: I forgot to mention, firstly i used the function DW1000.MODE_LONGDATA_RANGE_ACCURACY. After, I changed the function with DW1000.MODE_LONGDATA_RANGE_LOWPOWER, and the range seemed to stabilise:

|13:48:34.234 → from: 751F| Range: -19.10 m| RX power: -57.88 dBm|
|13:48:34.374 → from: 751F| Range: -36.89 m| RX power: -59.58 dBm|
|13:48:34.468 → from: 751F| Range: -41.14 m| RX power: -58.85 dBm|
|13:48:34.561 → from: 751F| Range: -30.32 m| RX power: -59.33 dBm|
|13:48:34.655 → from: 751F| Range: -8.86 m| RX power: -58.60 dBm|
|13:48:34.750 → from: 751F| Range: 17.98 m| RX power: -58.25 dBm|
|13:48:34.891 → from: 751F| Range: 52.57 m| RX power: -59.52 dBm|
|13:48:34.985 → from: 751F| Range: 16.75 m| RX power: -58.78 dBm|
|13:48:35.078 → from: 751F| Range: 6.81 m| RX power: -59.03 dBm|
|13:48:35.172 → from: 751F| Range: 7.69 m| RX power: -59.54 dBm|
|13:48:35.312 → from: 751F| Range: 20.23 m| RX power: -60.17 dBm|
|13:48:35.406 → from: 751F| Range: 45.56 m| RX power: -59.65 dBm|
|13:48:35.500 → from: 751F| Range: 68.89 m| RX power: -59.57 dBm|
|13:48:35.593 → from: 751F| Range: 94.14 m| RX power: -60.34 dBm|
|13:48:35.734 → from: 751F| Range: 121.58 m| RX power: -60.44 dBm|
|13:48:35.875 → from: 751F| Range: 66.75 m| RX power: -60.23 dBm|
|13:48:35.969 → from: 751F| Range: 45.39 m| RX power: -60.72 dBm|
|13:48:36.062 → from: 751F| Range: 24.35 m| RX power: -60.37 dBm|
|13:48:36.156 → from: 751F| Range: -0.65 m| RX power: -60.68 dBm|

thotro/arduino-dw1000
There are builtin program for anchor and tag available in this library just upload the same code provided in the library do not manipulate anything and check you connection of dw1000 and controller it will work fine