What are the factors that influence the duration for which distance measurement will occur (Using nrf_dm sample).

Hello, guys,

I am working on distance measurement project using two nRF5340DK (nrf_dm sample application). I found duration for which the distance measurement between two DKs happens is random, so can I please know the factors effect this duration and also can we control this duration in code.

Also, can we control interval time between two distance measurements in code.

Regards,
Madan

  • Hi

    Do you refer to the interval between the distance measurements or the time that the distance measurement itself takes here? The nrf_dm_get_duration_us API should give you the duration of the data collection for a given configuration, and NRF_DM_PROC_EXECUTRE_DURATION_OVERHEAD_US is the duration of a given (not high-precision) algorithm. Other than that the only random part here should be the advertising interval, which (per Bluetooth spec) has a randomized delay between 0 and 10 ms added to the advertising interval itself.

    If you're referring to some other random interval here, please be more specific. What range of measurement interval do you see occurring exactly?

    Best regards,

    Simon

  • Hi Simonr, Thanks for your reply

    I am referring to a situation like:
    when the two devices (nRF DKs) are kept at a closer distance (less than 1m), the duration of the distance ranging is very long and I will get more number of distance measurements, whereas if they are kept apart (greater than 2m) the distance ranging duration is small and we will get two or three distance measurement values, also in this kind of situation the synchronization takes more time compared to shorter distance.

    So Can I please know, what is the reason for this random occurrence? Also please suggest me how to fix them.

    Waiting for response

    Regards,
    Madan

  • Hi

    Can you upload a log file of this occurring so we can take a closer look at what's going on here. Also, how long is the duration of distance measurements approximately at closer distances compared to the other ones? 

    As per the ReadMe of the Distance measurement sample, the best way to adjust the number of measurements performed in a given time depends on the following factors:

    • Advertiser settings
    • Scanner settings
    • Extended size of measurement window "extra_window_time_us"

    "The shorter the advertising interval, the higher the frequency at which the broadcaster sends out advertising packages.

    This leads to a higher probability of synchronization and to a higher number of measurements taken at a given time.
    It also decreases the latency for the first measurement when the device is turned on or comes in reach.
    However, the higher number of packets transmitted also results in higher power consumption.

    The scan interval and scan window parameters determine how often and how long the scanning device will listen for packets.
    Like the short advertising interval, these values also have an impact on power consumption and the ranging frequency of devices.

    After the first measurement, the :kconfig:option:`CONFIG_DM_MIN_TIME_BETWEEN_TIMESLOTS_US` and the :kconfig:option:`CONFIG_DM_TIMESLOT_QUEUE_COUNT_SAME_PEER` Kconfig options define how often the same device is measured again.
    The Kconfig options :kconfig:option:`CONFIG_DM_TIMESLOT_QUEUE_COUNT_SAME_PEER` and :kconfig:option:`CONFIG_DM_TIMESLOT_QUEUE_LENGTH` define how many measurements are scheduled.
    The more measurements are scheduled, the more of them take place, which increases power consumption but gives more frequent rangings.
    If the :kconfig:option:`CONFIG_DM_TIMESLOT_RESCHEDULE` Kconfig option is disabled, the next timeslot for measurement execution will be allocated after the measurement request is added using the :c:func:`dm_request_add` function.

    Extending the measurement window increases the probability of measurement success for coarse synchronization.
    However, it affects the turn-on time of the radio and thus, power consumption.
    At the application runtime, the additional delay of measurement execution is configured using the ``start_delay_us`` parameter of the :c:struct:`dm_request` structure.
    This option helps in adjusting the synchronization.
    The :kconfig:option:`CONFIG_DM_INITIATOR_DELAY_US` Kconfig option defines the initiator delay.
    Increasing the values of these parameters increases the latency and power consumption."

    Best regards,

    Simon

  • CASE 1: Actual distance is 1 meters.
    
    *** Booting nRF Connect SDK v2.9.0-7787b2649840 ***
    *** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
    Starting Distance Measurement example
    I: HW Platform: Nordic Semiconductor (0x0002)
    I: HW Variant: nRF53x (0x0003)
    I: Firmware: Standard Bluetooth controller (0x00) Version 45.41337 Build 3074452168
    I: Identity: C7:A4:6E:3F:86:75 (random)
    I: HCI: version 6.0 (0x0e) revision 0x206b, manufacturer 0x0059
    I: LMP: version 6.0 (0x0e) subver 0x206b
    DM Bluetooth LE Synchronization initialization
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.22 ifft=1.34 phase_slope=1.58 rssi_openspace=1.78 best=1.34
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.27 phase_slope=1.63 rssi_openspace=1.78 best=1.27
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.24 ifft=1.17 phase_slope=1.50 rssi_openspace=1.78 best=1.17
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.43 phase_slope=1.51 rssi_openspace=1.78 best=1.43
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.37 ifft=1.44 phase_slope=1.51 rssi_openspace=2.00 best=1.44
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.44 phase_slope=1.41 rssi_openspace=2.00 best=1.44
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.38 ifft=1.42 phase_slope=1.44 rssi_openspace=2.00 best=1.42
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.33 ifft=1.39 phase_slope=1.51 rssi_openspace=2.00 best=1.39
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.36 phase_slope=1.47 rssi_openspace=2.51 best=1.36
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.38 phase_slope=1.50 rssi_openspace=1.78 best=1.38
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.41 phase_slope=1.47 rssi_openspace=2.00 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.41 phase_slope=1.52 rssi_openspace=2.82 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.35 ifft=1.42 phase_slope=1.50 rssi_openspace=2.00 best=1.42
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.43 phase_slope=1.49 rssi_openspace=2.00 best=1.43
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.37 ifft=1.42 phase_slope=1.48 rssi_openspace=2.00 best=1.42
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.33 ifft=1.40 phase_slope=1.44 rssi_openspace=2.00 best=1.40
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.41 phase_slope=1.54 rssi_openspace=2.00 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.33 ifft=1.46 phase_slope=1.55 rssi_openspace=2.00 best=1.46
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.45 phase_slope=1.54 rssi_openspace=2.00 best=1.45
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.33 ifft=1.42 phase_slope=1.46 rssi_openspace=2.00 best=1.42
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.41 phase_slope=1.51 rssi_openspace=2.24 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.39 phase_slope=1.54 rssi_openspace=1.78 best=1.39
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.38 phase_slope=1.47 rssi_openspace=2.24 best=1.38
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.35 ifft=1.41 phase_slope=1.52 rssi_openspace=2.00 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.34 ifft=1.42 phase_slope=1.51 rssi_openspace=2.24 best=1.42
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=1.38 phase_slope=1.49 rssi_openspace=2.00 best=1.38
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.45 ifft=1.41 phase_slope=1.47 rssi_openspace=2.00 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: crc fail
            Distance estimates: mcpd: high_precision=nan ifft=1.40 phase_slope=1.59 rssi_openspace=2.00 best=1.40
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=0.00 ifft=1.38 phase_slope=1.53 rssi_openspace=2.24 best=1.38
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.34 ifft=1.41 phase_slope=1.49 rssi_openspace=2.00 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.31 ifft=1.40 phase_slope=1.51 rssi_openspace=1.78 best=1.40
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.34 ifft=1.41 phase_slope=1.50 rssi_openspace=2.24 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.35 ifft=1.43 phase_slope=1.52 rssi_openspace=2.00 best=1.43
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.33 ifft=1.41 phase_slope=1.51 rssi_openspace=2.24 best=1.41
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=1.35 ifft=1.42 phase_slope=1.51 rssi_openspace=2.24 best=1.42
    
    CASE 2: Actual distance is 5 meters.
    
    *** Booting nRF Connect SDK v2.9.0-7787b2649840 ***
    *** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
    Starting Distance Measurement example
    I: HW Platform: Nordic Semiconductor (0x0002)
    I: HW Variant: nRF53x (0x0003)
    I: Firmware: Standard Bluetooth controller (0x00) Version 45.41337 Build 3074452168
    I: Identity: C7:A4:6E:3F:86:75 (random)
    I: HCI: version 6.0 (0x0e) revision 0x206b, manufacturer 0x0059
    I: LMP: version 6.0 (0x0e) subver 0x206b
    DM Bluetooth LE Synchronization initialization
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=6.55 phase_slope=7.85 rssi_openspace=10.00 best=6.55
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=6.82 phase_slope=8.82 rssi_openspace=12.59 best=6.82
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=5.57 phase_slope=7.64 rssi_openspace=11.22 best=5.57
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=5.27 phase_slope=7.36 rssi_openspace=7.08 best=5.27
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=6.15 phase_slope=7.98 rssi_openspace=10.00 best=6.15
    
    CASE 3: Actual distance is 8 meters:
    
    *** Booting nRF Connect SDK v2.9.0-7787b2649840 ***
    *** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
    Starting Distance Measurement example
    I: HW Platform: Nordic Semiconductor (0x0002)
    I: HW Variant: nRF53x (0x0003)
    I: Firmware: Standard Bluetooth controller (0x00) Version 45.41337 Build 3074452168
    I: Identity: C7:A4:6E:3F:86:75 (random)
    I: HCI: version 6.0 (0x0e) revision 0x206b, manufacturer 0x0059
    I: LMP: version 6.0 (0x0e) subver 0x206b
    DM Bluetooth LE Synchronization initialization
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=8.20 phase_slope=10.49 rssi_openspace=12.59 best=8.20
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=9.67 phase_slope=10.71 rssi_openspace=14.13 best=9.67
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=4.98 phase_slope=9.35 rssi_openspace=39.81 best=4.98
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=8.79 phase_slope=10.75 rssi_openspace=14.13 best=8.79
    
    Measurement result:
            Addr: D5:3D:F8:47:36:BB (random)
            Quality: ok
            Distance estimates: mcpd: high_precision=nan ifft=8.20 phase_slope=11.28 rssi_openspace=12.59 best=8.20
    



    I have attached the log information above. In above log I have considered three cases (1m, 5m, 8m) and below pasted the respective number of distance values estimated.

    Note: I have done the distance measurement in office environment.

    1.Could you please explain the reason for the varying number of distance values depending on the distance? Additionally, is it possible to make this number uniform, or is it left to the developer’s decision to determine the number of values?


    Thanks,

    Regards,
    Madan 

  • Hi

    Okay, so for 1 and 5 meters I'd say these numbers look close to what can be expected, while there is one result that looks to be very off on the 8m measurement, which likely chucks up to packet loss or interference from another source. I think there are two things you can do to increase the accuracy of these measurements.

    1. Enable High-precision calculation. As per the documentation, set the CONFIG_DM_HIGH_PRECISION_CALC Kconfig option to enable high precision calculation. Note that this is more power and RAM hungry but should increase the precision and error margin noticably.

    2. Since all your measurements are somewhat off, try to perform zero-distance calibration. The offset depends on the radio design, antenna, and PCB layout, so when using this sample you need to compensate this offset by doing a manual calibration. "To determine the offset value, place the devices at a reference distance of 60 cm from each other and collect a batch of measurement data. The difference between the average measurement value and the actual distance can be used as an estimate of the offset."

    Best regards,

    Simon

Related