This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IWR1443BOOST: perform algorithm on first peak, not highest

Part Number: IWR1443BOOST

Hi,

As i made clear in other threads I want to perform the high accuracy algorithm on the closest object instead of the highest reflective one. All this done in the high accuracy lab.

What i want to do is alter the algorithm that finds the highest peak, to find the closest peak. I believe that in doing so, i will get my desired results the easiest way, and without having to alter the lab itself a lot.

However i can't understand the algorithms/functions responsible for this. Can i get some detailed information on how i would do this?

so i want to replace the highest peak with closest peak, and run the program normally afterwards.

I believe i have to be in function :

void MmwDemo_peakSearch(MmwDemo_DataPathObj *obj)

which directs me to the following function:

void MmwDemo_configPeakSearch_HWA(MmwDemo_DataPathObj *obj)

does the variable 

paramsetIdx

determine that the highest peak should be returned?

if not, what does?

help is very much appreciated

cheers

  • What piece of code loops over the found objects and determines the highest reflective one, and how do i change this to the closest object?

    cheers
  • Hi Jason,

    For current high accuracy lab, the maximum is detected by using the statistics block of hardware accelerator. Please refer to hardware accelerator user's guide for details on how this is used. www.ti.com/.../swru527a.pdf

    The code to implement is in the datapath.c

    It returns the index of the max peak (see main.c line 1299)

    Thanks and Regards,
    Michelle
  • which function returns the max peak? i assume its a function that loops over all peaks?
  • I know i have to look for peaks in MMW_HWA_1D_OUT_PING. I intend to loop over the bytes as such:


    for (i = 0; i < obj->numRangeBins * sizeof(uint16_t); i++)
    {
    //for every detected object?

    }


    But i do not know how to "read" it , which bytes are important to calculate/read peaks? Please help me out, i am stuck here.

    when i look at the function that searches peaks, all i see is some hardware settings, so i do not know how to loop over the data to calculate peaks, and perform the high accuracy FFT on the peak of my choice

  • Hi Jason,

    In the case of searching peaks on your own, you will not need the HWA statistics blocks. Just use fft default output mode.

    Current data path for ping is:

    ADC data (M0) -> FFT -> M2 (search the rangeHwaParamCfg in data_path.c)

    M2 (depending whether DC signal removal is enabled or range limit is enabled, may be altered)

    M2 -> FFT -> peak index (search peakHwaParamCfg in datapath.c)

    In your case, the peak search is not needed, just check how the code is implemented in the MmwDemo_dcRangeSignatureCompensation or MmwDemo_rangeLimit,

    Search each bin and get the top 3 or 5 peaks. Then use each index to do interpolation.

    Thanks and Regards,

    Michelle

  • Hi Michelle,

    Thank you for your reply.
    I nog longer need several peaks. Only one, the closest object. I want to replace the highest reflective with the closest object, so i do not have to change the rest of the code. As i have already edited some things to get the output i desire. So i JUST want the MmwDemo_DataPathObj *obj to be the closest object.

    how do i put the closest peak back in obj?
  • I am currently looping over MMW_HWA_1D_OUT_PING via pointer fftOut1D, like in other functions.
    where the length of the loop is obj->numRangeBins * sizeof(uint16_t) .
    In this loop i check the value of fftOut1D[i], and put it in a variable if it is currently the smallest value. I also save the index i.

    Can you confirm this is correct until now?

    after this i don't know how to return these stats to the obj, so it can continue to perform the interpolation and continue the program on its own. I want the value in the visualizer to be the closest object.

    I believe only index and value are necessary to return? in which fields?


    cheers

  • Jason,

    Once you identified the closest peak with index, just replace the line 1299 HWA_readStatsReg(dataPathObj->hwaHandle, &(dataPathObj->rangeProcStats), 1);
    and assign the index.

    The main issue I see here is how do you plan to identify which one is the "peak"? so we can get the closest peak. It's determined by an SNR value?

    Thanks and Regards,
    Michelle
  • Hi,

    I actually don't know, i thought that the rangebin was the peak and i just looped over them to find the smallest value? Do you have any suggestions?

    the closest peak would be based on the distance, but i have no clue how to determine this? I kno the high accuracy lab can already see the other objects and the distance of these. So the standard lab is already capable of "seeing" the objects i want.

    What would you suggest? Is my approach valid?

    cheers
  • Jason,

    1D FFT output displays the magnitude vs range. Range is the bin number multiply the resolution. The bin number ranges from 1 to FFT size. Resolution is calculated using the chirp parameters. To find the highest peak, is to find the one with highest magnitude. In mmw demo, multiple peaks are identified using CFAR algorithm where CFAR threshold is defined through the cli command. CFAR checks each bin magnitude and compares it with neighbor bin magnitude, if it's larger than threshold, it's considered as a peak. Although CFAR was not implemented in the high accuracy lab, in your case, you may consider using similar algorithm to search for the closest peak. You can first hardcode the threshold to check how it performs, and if everything works out, you can add the cli command.

    Thanks and Regards,
    Michelle
  • the sensitivity seems to be good enough from the standard high accuracy lab.

    where is this defined?

    when i loop over the values like this:

    for (i = 1; i < obj->numRangeBins * sizeof(uint16_t) -1; i++)
           {
               // check if peak
               if (fftOut1D[i-1] < fftOut1D[i] && fftOut1D[i] > fftOut1D[i+1])
               {   closestBin = fftOut1D[i];
                   closestBinIndx = i;
               }
           }

    what exactly is the value i get? the magnitude? Is this the approach i am supposed to take or am i completely lost?

    can i enter the values found like this:

     obj->rangeProcStats.maxIndex = (uint16_t)  closestBinIndx;
     obj->rangeProcStats.maxValue = (uint32_t) closestBin;
    
    
    

    or is this incorrect?

    cheers

  • Jason,

    fftOut1D[i-1] < fftOut1D[i] && fftOut1D[i] > fftOut1D[i+1] is not enough to tell if it's a peak. Peak has to be a valid signal with SNR. You may get random noise with one value higher than the neighbor bins.

    A proper threshold needs to be set to evaluate if a signal is a peak.

    paramsetIdx is the index for parameter set. Each parameter set performs certain function of HWA. Please refer to HWA user's guide for details on parameter set registers.

    Thanks and Regards,
    Michelle
  • Hi,

    I have checked out the MmwDemo_processCfar() function, but it seems to be hardware settings again, so i cannot use it as an example for my application. Can u perhaps explain what the function is supposed to do?

    checks each bin magnitude, compares with neighbour bin magnitude to determine wether its a peak, and see if if its larger than threshold? Is that all?

    is there any code available for this or only hardware settings?

    cheers
  • Hi Jason,


    As to your question: "checks each bin magnitude, compares with neighbour bin magnitude to determine wether its a peak, and see if if its larger than threshold? Is that all?", the quick answer is no. It's not going to be that simple and you might miss a valid peak. For example, if a big object is taking the range of two bins or more, you might miss that. On the other hand, since you are developing a code that's for your own application. You may have better idea what kind of peaks you usually have. Then you can develop your own algorithm, by setting a threshold and a bunch of if/else statements. It may not be as good as CFAR, but as long as it can work for you. Before diving into coding, you could use ccsdebug to first check what kind of data you get from 1D FFT output. Analyze the data and find the best algorithm.

    If you want to use CFAR to get the peak identified, please refer to HWA user's guide part 2 www.ti.com/.../swru527a.pdf section 2. Let me know if you have any questions.

    Thanks and Regards,
    Michelle
  • Hi,

    In section 2.1 of HWA user's guide part 2 it says:

    The CFAR engine has capability to perform CFARCA
    detection processing (both linear and logarithmic CFAR modes are available) and generate a peak list.

    How do i generate this list and save it somewhere? I assume its a standard function that generates the list. With some tinkering i should be able to use it in my code, correct?

    how do i convert the db value of 12 to the treshold on the fftoutput ? i believe 12 was the value to detect hands.

    cheers

  • Jason,

    Please set up the register (common and parameter-set) for CFAR operation to generate peak list.
    dB is calculated using 20log(magnitude).

    Thanks and Regards,
    Michelle
  • How does the CFAR algorithm work? how does it behave if it finds an object occupying several bins?
  • In cell-averaging CFAR, the processing steps involve computing a threshold for each sample under test
    (cell under test) and deciding whether a peak is detected or not based on whether the cell under test
    crosses that threshold. Additionally, peak grouping may be done, where a peak is declared only if the cell
    under test is greater than its most immediate neighboring cells to its left and right.

    For each cell under test, the computation of threshold is done by averaging the magnitude (or magnitudesquared
    or log-magnitude) of a specified number of noise samples to the left and right of the cell under
    test to determine a ‘surrounding noise average’ and then applying a scale factor (or addition factor in case
    log-magnitude is used) on that surrounding noise average to determine the threshold. Thus, the CFAR-CA
    detector takes one cell at a time, computes the threshold and decides whether a valid peak is present at
    that cell.

    Regards,
    Michelle
  • Hi,

    i get false readings when i check bin number 1, however when i skip bin 0 and 1, i get accurate values, Why is this? should bin number 1 be skipped at all times? I tested several scenario's and bin 0 and 1 seem to be somewhat consistent to give me false readings.

    Also i set the threshold according to the formula :
    threshold = (512 * db) / 6;

    with db being 5 to detect my hands, and for maximum sensitivity. I no longer use the cell averaging algorithm, but detect peaks based on the bin before and after having a lesser value than the current one. Is this sufficient enough for accurate measurements?

    However, i do not know how to handle if an object takes up 2 bins or more, what is the appropriate way to handle this?

    cheers

  • Jason,

    Not sure I understand what you mean by false reading of bin 0 and 1. Do you mean 1D fft output was not giving correct bin 0 and 1? what values are you comparing against? Note that there's high pass filter (analog filter) used for mmwave radar and might repress the near DC objects. Please refer to the SDK user's guide for the high pass filter (check profileCfg).

    As to the objects with multiple bins occupied, you may try claiming the peak is detected as long as the value is above threshold.

    Thanks and Regards,
    Michelle
  • I mean i get an detected object while there is none. usually before 1m. This happens nearly every iteration. But when i loop starting at bin 2 the issue disappears.

    cheers
  • Jason,

    Please make sure you cover all the cases in your function to select the peak, especially the bin at the two ends.

    Thanks and Regards,

    Michelle

  • how do i do that? im confused to what you mean. how do i do that?
  • Jason,

    Just an example, the first bin or the last bin can't be treated the same way as the rest, because it doesn't have neighbor bin on both sides. All corner cases need to be considered when running peak detection algorithm.

    Hope this helps.

    Thanks and Regards,
    Michelle
  • I understand that, how would i handle the first and last bin? only compare on one of the sides? Or is there another solution?
  • It could be discarded since it'll be not accurately due to high pass filter (DC bin) and low path filter (last bins) applied. If you still want to take it into consideration, please compare it with one side neighboring bin.

    Thanks and Regards,
    Michelle
  • Hi Michelle,

    I got it working to find peaks and check the magnitude against my threshold.

    How do i set the bin index when i find an object that occupies several bins?

    for example the signal: 3 4 5 6 6 6 5 4 3
    which index do i give to the MmwDemo_processInterpolation() function?
    the middle 6 i assume? or the first?

    other scenario, same issue: 4 5 6 6 5 4
    in this scenario which bin do i give to the MmwDemo_processInterpolation() function?

    basicly even amount of bins occupied by one object vs odd amount of bins occupied by one object, incase the middle bin is to be used for interpolation.

    or should it be the first (highest) bin? How can i generate this signal best? a thick object? I have been unable to simulate that signal.

    Thank you very much,

    Jason
  • Jason,

    I would choose the middle one, but you may choose different value depends on your test application. In fine peak search, the bin range will be the course fft peak +- 2 bins. Therefore I choose the middle one for higher accuracy. The high accuracy lab is targeted to give the most accurate point for the object and the object was assumed to be big flat surface. And one single point of range is good enough for that. For object with certain depth, the ideal thing is to get a contour but that is not what the high accuracy lab is designed for.

    Thanks and Regards,
    Michelle