Distance measurement issue

Change the code to allow more time to read the data. :slight_smile:
This may be as simple as increasing the timeouts and receive to transmit delay times for the relevant periods. Ideally you’d also restructure the code to only read the CIR data and buffer it, perform the rest of the UWB operations and only then process and output the buffered CIR data.

would it be wrong if i set the initiator to read just the CIR while the responder will shows just distance measureaments?

No, there is no requirement to calculate or display the distance as long as any required replies are sent correctly.

Perfect, another question since i modified the code with your indication to not display Tn values in the Print of the CIR.
Sometimes it happens between all the CIR values that i have this:
CIR_real_values
1
n 7 n o n n I+
CIR_imag_values
14
{“Addr”:“0x0001”,“Status”:“Ok”“D_cm”:54
}

CIR_real_values
-6 54 76 -2 24 -2 19 18 -27 34 39 62 49 42 23 -7 42 40 25 -42 -38 -10 27 4 7 39 25 9 4 35 15 12 3 33 36 42 -13 -39 -14 20 19 32 17 21 5 60 4 3 -6 30 88 37 34 14 -18 5 28 34 18 0 -17 -4 19 29 21 9 29 -6 22 3 12 -1 6 24…
I’m worried about that n 7 n o n n I+
Do you have any suggest?

Do you still have the line:
reporter_instance.print(strcat(CIR_string_real, "\n"), 50);
in the code?
Because if you do that’s printing 50 characters out no matter how long the meaningful data is.

reporter_instance.print("\nCIR_real_values\n", 17);
   int len = 0;
    for (int i = 0; i < CIR_length; i++) {
         int len = snprintf(CIR_string_real,10, "%ld ", (realSample[i]));
        reporter_instance.print(CIR_string_real, len); //A vs OR reporter_instance.print(CIR_string_real, 10)
    }
 reporter_instance.print("\nCIR_imag_values\n", 17);
   len = 0;
    for (int i = 0; i < CIR_length; i++) {
          int len = snprintf(CIR_string_imag,10, "%ld ", (imagSample[i]));
  
      
        reporter_instance.print(CIR_string_imag, len); //Antonello VS oR reporter_instance.print(CIR_string_imag, 10);
    }
 reporter_instance.print("\n", 1);
 

   
    reporter_instance.print("\nCIR_real_values\n", 17);
    

    reporter_instance.print(strcat(CIR_string_real, "\n"), 50);

    reporter_instance.print("\nCIR_imag_values\n", 17);
    reporter_instance.print(strcat(CIR_string_imag, "\n"), 50);
   

should i modify the last lines where i have “,50” as well?
Thank You in advance

Also, since i want to do some post processing on matlab about the CIR values extrapolated, is there a way to display the values better than what i have? Meaning by modyfing the code? Maybe with brackets already

CIR_real_values
31 43 -25 -31 -31 -14 6 45 29 3 -22 -21 6 -2 -18 -72 -50 -29 -13 -45 -25 -27 -16 -9 -9 -33 -3 12 -13 11 18 54 39 37 14 75 11 -4 30 28 21 6 2 6 9 -6 -16 18 47 14 -15 -23 -8 18 14 25 30 7 1 40 43 -13 14 -22 -33 -38 -29 -20 -36 -52 -23 57 83 63 12 -37 -6 9 35 57 51 11 3 -5 6 -22 -40 -6 0 26 -12 -3 22 26 62 7 -18 -35 -4 -25 -14 -4 9 30 63 27 5 23 44 14 3 32 32 5 5 17 28 -17 -36 -13 69 41 9 -41 -37 17 27 -57 -56 -28 -9 0 0 15 8 1 -5 11 -9 -18 8 20 51 7 23 -34 -57 -54 -24 21 54 37 14 -2 8 2 12 -1 -19 -7 -17 5 2 23 38 21 13 -19 25 -39 -12 -33 1 16 -9 -79 -33 13 -52 -39 -32 13 67 57 8 15 34 25 18 -4 26 14 20 35 -1 -14 -39 -27 -22 -15 -39 -2 -17 -12 14 63 0 -23 -46 21 46 11 -14 -4 4 45 34 19 8 -13 -4 -26 18 12 15 47 21 -3 -1 -38 -61 -30 7 18 3 -33 -44 -9 -15 -24 -15 -22 -27 -25 -5 -15 16 -22 -2 -7 32 30 18 5 15 44 50 38 -3 -56 -47 -22 27 13 14 14 -4 27 -17 -7 -10 -12 14 -2 -12 -4 -22 -35 -22 -4 14 8 23 -5 17 -4 -33 3 8 -8 -23 0 -16 -7 14 43 -13 -33 8 13 46 36 5 -11 3 20 -31 -8 -26 -2 6 2 68 56 16 -21 -21 -20 -1 0 12 30 -18 6 29 13 35 -8 -2 -27 -41 -59 -27 13 46 14 9 5 17 -25 -14 4 32 33 32 14 -19 -19 -4 25 40 42 14 -43 -31 -30 -10 -14 3 -17 -26 -40 -27 -11 20 45 54 53 45 46 48 40 3 -7 -8 49 63 5 -34 -86 -43 21 47 21 -50 -52 10 56 29 -20 -19 -4 34 17 -37 -11 1 17 -6 -17 40 49 20 -4 19 7 14 -21 -33 -17 3 7 8 -4 -18 -4 7 3 6 -47 -37 -26 -2 18 26 50 13 -22 -83 -45 -28 -11 -3 -17 -5 -10 -22 -8 -2 11 -8 -17 6 28 30 -24 -13 -18 -14 7 8 36 3 -27 -61 -6 9 -16 -25 -23 -5 39 27 40 12 17 -6 -15 -35 -26 -40 4 71 67 23 2 -12 -8 6 48 -14 -32 -64 -42 -19 -24 10 9 24 59 29 -27 -39 -70 7 56 56 16 -11 12 -6 19 55 35 12 -3 10 38 33 24 20 25 21 1 -42 -52 -22 5 33 -11 -9 -22 -3 28 32 47 27 24 -31 -8 -40 -20 -15 6 31 57 8 44 37 23 -2 -11 32 7 16 -11 -10 -23 -78 -44 -28 -17 -13 -15 25 2 -6 9 -5 23 -30 -48 -51 -27 -14 -2 -11 10 26 21 -9 -52 -32 13 9 19 7 8 -21 -30 0 3 32 10 -13 -9 30 13 14 24 20 -2 56 22 -2 -28 -14 3 46 3 6 -18 -14 10 8 -9 -9 27 32 -24 -48 -20 -30 19 19 26 14 -1 11 27 17 20 27 20 17 21 3 -56 -63 -10 18 42 47 12 -10 -36 -3 43 15 -9 -6 -9 -12 -38 -26 -3 19 11 -14 12 8 7 15 -32 -11 -1 18 4 37 -3 -23 22 28 -21 -69 -73 -67 -34 -19 15 21 39 8 8 -21 -12 -2 1 6 53 -4 13 11 21 -21 47 39 7 -17 -29 19 -5 -20 -12 -8 -35 -14 34 27 -22 21 40 35 6 -41 -5 35 23 11 -34 -20 20 24 15 26 15 -14 21 -3 -5 -30 -16 -16 5 -14 -15 20 -13 60 81 36 -12 17 20 41 30 49 -3 -295 -1117 -1943 -1840 -648 595 884 449 176 227 158 120 462 795 511 -75 -234 -112 -54 -73 -58 38 106 173 221 190 53 -135 -338 -380 -207 27 126 147 135 138 143 138 63 -51 -187 -262 -147 -27 38 57 122 145 59 18 35 68 62 -24 -35 64 68 47 23 12 -12 53 39 -13 -6 20 44 11 19 42 83 63 2 -35 1 63 83 61 -16 -4 -37 -47 -47 15 25 -59 -67 -8 37 37 12 -9 4 28 38 29 -12 -14 7 7 35 14 -29 -46 -2 15 44 -7 20 -6 -29 -33 -44 -9 18 19 29 0 -54 10 7 5 19 -31 -29 10 66 -6 -37 -27 23 67 13 -26 -46 -43 -42 -23 23 33 8 -20 -48 -21 -22 4 -1 -33 5 37 44 22 -10 -1 -32 -47 -15 -4 -20 -6 28 28 
CIR_imag_values
1 12 -20 -32 -54 -57 -52 -29 -7 -11 -35 -20 -34 -22 -23 -20 5 -7 -12 -39 -39 -2 5 9 11 -22 9 -20 -5 -34 -38 -45 -3 7 -29 -23 17 -3 -35 -49 -51 -52 -74 -75 -23 8 18 -23 5 7 -19 -28 -23 -51 -37 15 10 4 2 -2 2 -4 0 29 1 -25 -41 -12 -75 -65 -88 -18 37 59 51 43 16 4 -22 -25 -7 2 17 5 -42 -68 -16 8 3 -15 -6 -16 -28 -18 -3 -30 9 -6 1 2 -15 -11 -3 2 30 -6 -29 5 7 8 -16 -24 -27 15 -13 -24 -32 -16 -25 -34 -34 -3 38 -2 -3 -21 -44 -7 11 -34 -5 -39 -33 -3 -23 -55 -4 7 24 14 -6 18 -13 -35 -15 -12 7 17 52 37 -19 18 -12 -5 -18 -38 -62 -51 -34 -3 26 -24 -31 -29 2 -25 -4 9 -24 -12 12 -12 15 -31 -40 -30 -34 -21 12 -13 10 12 -22 -25 -16 -14 -3 -23 25 22 23 3 31 41 8 -11 -20 -30 -7 -7 33 13 -10 -26 -44 -14 3 3 3 37 5 -1 12 35 30 8 -10 1 -7 -33 -42 -41 17 40 53 49 -30 -49 -21 4 -4 4 3 -17 1 8 29 39 11 15 15 -32 25 -6 21 38 5 30 8 -6 -3 6 18 20 -4 -8 -11 24 7 -4 3 -12 -35 -12 23 -16 -70 -61 -12 -5 20 34 -3 -15 2 -6 -17 -10 32 19 -24 -10 36 10 -10 2 7 21 -3 -26 -11 12 29 27 38 6 -10 -10 -48 12 22 40 5 -65 -36 24 14 26 -24 -34 17 -38 -24 -38 -20 22 7 9 17 50 34 -15 -28 3 27 -3 -30 -6 7 -4 9 4 -25 13 34 11 -6 -15 3 -2 11 3 1 -22 -3 -3 -41 -35 -1 -53 -13 -3 -7 0 -12 -24 -21 51 37 15 -22 33 18 55 34 15 10 -45 -38 -82 -55 -51 -52 -53 -22 43 78 61 9 10 31 25 -2 -15 -3 13 -11 17 18 -23 -47 -60 -8 -48 10 -18 -51 -83 -82 2 -2 -5 17 13 -19 -20 -5 21 -17 14 -14 -21 -4 9 18 34 -1 -42 -50 -27 -42 -22 -20 -27 0 40 26 26 -25 -9 16 46 42 38 28 14 23 16 33 15 35 44 38 -19 -9 -25 -34 1 44 43 31 -12 -24 -12 -24 -30 -18 -18 8 17 31 -6 -25 -38 -1 -26 -42 -38 -6 19 -6 -26 -22 -33 -11 25 -9 -31 -11 -12 19 43 2 2 -62 -25 -19 7 -38 -20 0 -6 -42 -36 0 -2 23 24 28 5 21 26 31 -10 -14 -18 -31 8 14 2 -14 -20 -11 18 23 10 14 -11 -22 6 -9 -7 -11 26 51 37 38 5 -12 -9 1 -24 -33 -13 6 43 29 -17 -33 -32 2 49 42 71 38 22 -6 -29 -37 11 13 36 20 -17 28 19 0 9 3 -5 12 34 61 70 27 21 7 -34 -62 -23 26 20 1 -31 -46 -48 -35 -22 -9 1 56 60 58 22 35 16 -1 -17 7 -28 -60 -51 -32 -41 34 23 43 20 -2 -24 -3 -20 9 25 27 47 36 10 -3 -13 21 -1 18 1 45 2 23 29 -11 14 35 17 -15 -25 -6 -38 -9 -14 10 -44 -41 -25 10 22 -14 -12 -20 15 7 16 -4 20 27 24 1 -2 27 -10 -2 13 30 32 -2 -54 -43 6 23 -5 -28 -8 11 25 21 -22 -39 -27 7 -43 -29 3 23 26 33 32 6 -11 41 5 -6 3 18 -8 14 18 -17 10 -32 -35 -23 -36 7 16 -1 -17 -56 -22 -5 14 2 20 65 51 7 33 3 -19 -9 26 10 -37 -12 -3 34 -6 -30 -2 26 29 14 -17 14 50 14 -15 -10 26 25 -26 -16 -8 -44 -35 -2 1 -18 -12 24 -14 -50 58 598 1288 1546 828 -264 -577 -141 480 558 176 130 823 1656 1432 393 -338 44 757 1009 573 -7 -178 10 272 303 -4 -366 -540 -427 -167 -2 59 95 115 78 -97 -238 -169 -18 82 128 99 62 -44 -61 -100 -116 -173 -116 27 93 101 27 6 18 30 69 36 13 -26 -68 -33 -54 -67 -35 -52 -40 -32 -10 48 -11 -24 -24 -12 -33 -81 -103 -113 -51 -2 16 -5 -12 -58 -54 -36 -27 -41 -63 -77 -50 -37 -69 -63 -1 25 18 -7 -32 -36 -46 -74 -42 -23 -35 -6 -29 -47 0 15 -5 -39 2 -21 -39 -44 -34 -13 -16 6 -23 3 4 -12 8 -18 -14 -18 -19 -9 -14 -25 10 16 18 -65 -42 -23 -11 -33 -48 -25 -8 -28 -41 -68 -67 -51 -43 -32 -16 -26 -35 -25 2 9 -14 -17 -9 -25 

CIR_real_values
28 
 n 7 n o n   n I+
CIR_imag_values
-25 

Sorry for the two many questions and thank you for your time and work helping me.
Kind Regards,
Antonello

   int len = 0;
   reporter_instance.print("\nCIR_real_values = [", 20);
   for (int i = 0; i < CIR_length; i++) {
      if (i==(CIR_length-1)) // last entry
        len = snprintf(CIR_string_real,10, "%ld]\n", (realSample[i]));
      else
        len = snprintf(CIR_string_real,10, "%ld,", (realSample[i]));
      reporter_instance.print(CIR_string_real, len); 
  }

should output
CIR_real_values = [1,2,3,…,1011,1012]
which is probably a little easier for matlab to read.

So basically, instead of this:

reporter_instance.print("\nCIR_real_values\n", 17);
   int len = 0;
    for (int i = 0; i < CIR_length; i++) {
         int len = snprintf(CIR_string_real,10, "%ld ", (realSample[i]));
        
        reporter_instance.print(CIR_string_real, len); //A vs OR reporter_instance.print(CIR_string_real, 10)
    }
 reporter_instance.print("\nCIR_imag_values\n", 17);
   len = 0;
    for (int i = 0; i < CIR_length; i++) {
          int len = snprintf(CIR_string_imag,10, "%ld ", (imagSample[i])); 
       
        reporter_instance.print(CIR_string_imag, len); 
    }
 reporter_instance.print("\n", 1);
 

  
    reporter_instance.print("\nCIR_real_values\n", 17);
  
    reporter_instance.print(strcat(CIR_string_real, "\n"), 50);

    reporter_instance.print("\nCIR_imag_values\n", 17);
    reporter_instance.print(strcat(CIR_string_imag, "\n"), 50);
  
//

    free(CIR_string_real);
    free(CIR_string_imag); // Deallocate the memory for the string buffer
}

i should write this:

int len = 0;
   reporter_instance.print("\nCIR_real_values = [", 20);
   for (int i = 0; i < CIR_length; i++) {
      if (i==(CIR_length-1)) // last entry
        len = snprintf(CIR_string_real,10, "%ld]\n", (realSample[i]));
      else
        len = snprintf(CIR_string_real,10, "%ld,", (realSample[i]));
      reporter_instance.print(CIR_string_real, len); 
  }
reporter_instance.print("\n", 1);
 

  
    reporter_instance.print("\nCIR_real_values\n", 17);
  
    reporter_instance.print(strcat(CIR_string_real, "\n"), 50);

    reporter_instance.print("\nCIR_imag_values\n", 17);
    reporter_instance.print(strcat(CIR_string_imag, "\n"), 50);
  
//

    free(CIR_string_real);
    free(CIR_string_imag); // Deallocate the memory for the string buffer
}

Roughly. You’d need to repeat a similar loop to print out the imaginary values.

You’ve also got more new lines than needed in there and the second set of prints seem completely redundant since all they do is repeat the last value and then print some random memory contents. But that’s not a big issue since you can simply ignore that part of the output.

Hi Andy i wann thank you for all your help, that was really appriciated since i’m at first arm with this.
I have one last question.
I’m studying the performance of CIR by doing several experiments at different distances. I’ve only done LOS so far but I should also do NLOS. I need help estimating the delay. I show you in the figures below what I get for the CIR at 145 cm and 300 cm and in particular the highest peak that I think is related to packets/ signals received without reflection. What I suppose will happen when I do the same experiments at the same distances but in the NLOS case is that I will have the peaks moved. But what I would like to know is the delay that is observed. From here I should be able to calculate the reflections.
Can you help me?



Thank You in advance.
kind Regards,
Antonello

The theoretically ideal CIR would be an impulse response, a single high value with all other values 0.
Obviously you’ll never get the theoretical result in the real world but if you look at the CIR in the middle of a field with the antennas several meters above the ground you can actually get fairly close to it.

The highest peak is simply the strongest signal. The direct signal is always the first peak. By definition reflections have traveled further than the direct signal which means they will arrive later.

In your second picture the first peak is the direct signal, the second peak ~15 samples later would represent a reflection that arrived at the receiver around 8 ns later (From memory it’s ~0.5ns per sample). This implies a reflection path that is around 2.5 m longer than the direct path (c = 30 cm per ns, 8*0.3 = 2.4 m).

In a NLOS situation it depends what the obstruction is. If it’s a solid metal sheet then the signal is completely blocked and no direct signal will be seen. If it’s something like wood then the direct signal will be attenuated but still detected. This will give a far smaller first peak often a lot smaller than the reflections. But as long as the first peak is above the detection threshold then you can still range based on it.

The first peak will normally still be around index 740.

So basically it is normal that if i did a NLOS experiment with a person as obstruction the first pick is:

In your second picture the first peak is the direct signal, the second peak ~15 samples later would represent a reflection that arrived at the receiver around 8 ns later (From memory it’s ~0.5ns per sample). This implies a reflection path that is around 2.5 m longer than the direct path (c = 30 cm per ns, 80.3 = 2.4 m).
How do you manage this calculation, cause i didn’t found anything in the Development guide.
Also what does implies "This implies a reflection path that is around 2.5 m longer than the direct path (c = 30 cm per ns, 8
0.3 = 2.4 m)."?
I made another experiment with wood between the boards, which are placed at 3 m of distance.

You could get that. An obstruction will generally reduce the ramp rate at the start of the pulse and decrease the direct path peak. But beyond that the effects are very variable depending on exactly what’s going on. It may end up looking like the first peak has been spread out.
Despite what all the diagrams and simple explanations say you don’t have a direct signal and a single reflection. You have a direct signal and hundreds or thousands of reflected / refracted signals all mixed together.

If the second peak is 15 samples behind the first peak then it arrived 7.5 ns later. (I’m eyeballing the chart, it looks to be around that, maybe a 16 samples)
Since it’s the same signal traveling between the same antennas that delay must be due to it traveling a longer distance.
Distance = Speed * time = 3e8 * 7.5e-9 = 2.25
So the second peak traveled 2.25 meters further.

For a strong reflection the simplest cause is a wall behind or to the side of the antennas. If it’s behind then it’s going to be half the extra delay away. If it’s to the side then you can use Pythagoras to calculate the distance the wall would need to be based on the antenna separation. You will also get a reflection off the ground but unless you’re very high that path is normally going to add less than 2 meters of extra distance so I discounted that.

On your second image in the latest post the direct signal is certainly that first peak. If I had to make a guess I’d say the direct signal through the wood arrived at 741. The peak at 744 is the direct signal bouncing off the ceiling and bypassing the wood that way, the signal at 750 has bounced off the wall and gone around the wood.

Is the ceiling about 1.3 meters above your antennas?
744-741 = 3 samples = ~1m of extra path so 4m rather than 3.
Looking at the path from the antenna to the reflection source: sqrt(1.3^2 + 1.5^2) = 2

So a surface 1.3 meters to the side, above or below your antennas would provide a path that would cause a reflection about 3 samples after the direct path.

I’m not sure what the point of plotting a low pass filtered version of the CIR is.

Hi Andy sorry for the delay, anyway i did a more precise experiments, similar to the previous one, so basically i have wood as obstruction.
the two boards are 3 m (measured) from each other and the antennas are about 240cm from the ceiling, while the “wood obstruction” is in t


he middle and higher than where the boards are located.

744-741 = 3 samples = ~1m of extra path so 4m rather than 3.
Looking at the path from the antenna to the reflection source: sqrt(1.3^2 + 1.5^2) = 2. What 1.5 is reffered to? and what does implies that i have 1 more meter of extra path? DO you think that is consistent as result?
Thanks Again Andy.
kind regard.

I’m only considering half the path and assuming things are symmetrical around that. If the antennas are 3 m apart and the signal is reflecting off a surface that is roughly parallel to the antenna to antenna path then the signal is reflecting off that surface at a distance of 3/2 meters away in the direction between the antennas plus the antenna to surface distance away in the direction orthogonal to that.

hi Andy could you help me once again understanding where do I have redundancy or error in writing and so in printing the CIR values?

 reporter_instance.print("\nCIR_real_values = [", 20);
   int len = 0;
     for (int i = 0; i < CIR_length; i++) {
           int len = snprintf(CIR_string_real,10, "%ld ", (realSample[i])); 
        
        reporter_instance.print(CIR_string_real, len); 
  }
    reporter_instance.print("]\n", 2); 

    
 
 reporter_instance.print("\nCIR_imag_values = [", 20); 
     for (int i = 0; i < CIR_length; i++) {
          int len = snprintf(CIR_string_imag,10, "%ld ", (imagSample[i])); 
       reporter_instance.print(CIR_string_imag, len);
    }
 reporter_instance.print("]\n", 2); 

    
    reporter_instance.print("\nCIR_real_values\n", 17);
   

    reporter_instance.print(strcat(CIR_string_real, "\n"), 50);

    reporter_instance.print("\nCIR_imag_values\n", 17);
    reporter_instance.print(strcat(CIR_string_imag, "\n"), 50);
   

    free(CIR_string_real);
    free(CIR_string_imag); // Deallocate the memory for the string buffer
}



Thank you in advance.
Antonello

Looking back at your code you allocate huge buffers large enough to hold lots of text but then print out the values one at a time. So you can reduce the memory usage by around 9kBytes.
Also you currently never free CIR_string_real_sv or CIR_string_imag_sv so you are leaking memory.

Remove the lines

char* CIR_string_real;
char* CIR_string_real_sv;
char* CIR_string_imag_sv;
char* CIR_string_imag;
//char* teststring;
CIR_string_real = (char*)malloc(5000);
CIR_string_imag = (char*)malloc(5000); // Allocate memory for the string buffer
CIR_string_real_sv = (char*)malloc(10);
CIR_string_imag_sv = (char*)malloc(10); // Allocate memory for the string buffer

change the lines

reporter_instance.print("\nCIR_real_values = [", 20);
   int len = 0;
     for (int i = 0; i < CIR_length; i++) {
           int len = snprintf(CIR_string_real,10, "%ld ", (realSample[i])); 
        
        reporter_instance.print(CIR_string_real, len); 
  }
    reporter_instance.print("]\n", 2); 

    
 
 reporter_instance.print("\nCIR_imag_values = [", 20); 
     for (int i = 0; i < CIR_length; i++) {
          int len = snprintf(CIR_string_imag,10, "%ld ", (imagSample[i])); 
       reporter_instance.print(CIR_string_imag, len);
    }
 reporter_instance.print("]\n", 2);

to being

  char tmp[16];
  int len;
  reporter_instance.print("\nCIR_real_values = [", 20);
  len = snprintf(tmp,16, "%ld", (realSample[0])); 
  reporter_instance.print(tmp, len); 
  for (int i = 1; i < CIR_length; i++) {
     len = snprintf(tmp,16, " %ld", (realSample[i])); 
     reporter_instance.print(tmp, len); 
  }
  reporter_instance.print("]\n", 2); 

  reporter_instance.print("\nCIR_imag_values = [", 20);
  len = snprintf(tmp,16, "%ld", (imagSample[0])); 
  reporter_instance.print(tmp, len); 
  for (int i = 1; i < CIR_length; i++) {
     len = snprintf(tmp,16, " %ld", (imagSample[i])); 
     reporter_instance.print(tmp, len); 
  }
  reporter_instance.print("]\n", 2); 

remove the lines

    reporter_instance.print("\nCIR_real_values\n", 17);
    reporter_instance.print(strcat(CIR_string_real, "\n"), 50);

    reporter_instance.print("\nCIR_imag_values\n", 17);
    reporter_instance.print(strcat(CIR_string_imag, "\n"), 50); 

    free(CIR_string_real);
    free(CIR_string_imag); // Deallocate the memory for the string buffer

That should tidy up the output, run faster and use less memory.
If you want the output comma separated rather than space separated then change the " %ld" to “,%ld” inside the two for loops.

Ok perfect, thank you.
I wanted to ask a more logistic question. until now I did twr between 1 initiator and 1 responder. But 1 initiator to more is it possible? while the initiator is connected to a laptop, do all the receivers need to be at the same time connected to a laptop or tablet in order to receive distance and CIR measurements?
Thank you again