TI毫米波雷达(七)——high accurary示例分析(二)

概述

之前分析了IWR6843上的高精度测距程序框架,虽然可以看到大致的系统运行过程,但是总有一种"混乱"的感觉。TI为了展现ARM与DSP协作能力将如此"简单"的一个功能分布在多处理器上,结合BIOS以及semaphore、event、mailbox等机制,导致我们对关键的雷达数据处理过程理解很模糊。

我们再分析一下官方提供的运行于xWR14xx上的高精度测距程序,IWR1443中只有ARM作为主处理器,应该可以为我们排除很多干扰因素。

代码分析

main

  1. 器件初始化:ESM、SOC
  2. 创建任务:MmwDemo_initTask
  3. 启动系统:BIOS_start

MmwDemo_initTask

此函数中实现了完整的系统流程,除了初始化必要的外设外还执行了数据路径初始化、BSS初始化、数据路径使能、创建雷达控制任务、创建命令行、传感器管理初始化、系统中断监听器的注册、创建数据路径任务等。

外设初始化

  1. UART_init
  2. Mailbox_init
  3. GPIO_init

MmwDemo_dataPathInit

  1. ADCBuf_init
  2. MmwDemo_hwaInit
  3. MmwDemo_edmaInit

BSS初始化

  1. MMWave_init
  2. MMWave_sync

MmwDemo_dataPathOpen

注意:这里没有使能EDMA

  1. MmwDemo_hwaOpen
  2. MmwDemo_ADCBufOpen

MmwDemo_mmWaveCtrlTask

循环调用MMWave_execute()。

MmwDemo_CLIInit

初始化命令行工具。

MmwDemo_sensorMgmtInit

创建了相关event handle后,创建任务MmwDemo_sensorMgmtTask,这是一个由事件驱动的控制任务,主要功能则是执行毫米波雷达的配置、打开、关闭控制。

SOC_registerSysIntListener

关联了帧起始中断句柄MmwDemo_frameStartIntHandler(),用于推送相关semaphore。

MmwDemo_dataPathTask

数据处理过程就在此任务中,当获得帧起始semaphore时,等待1D FFT完成。按需进行直流补偿、测距范围限制。查找信号峰值、进行zoom-FFT处理,获得高精度测距结果。发送目标数据,配置HWA和datapath为下一帧处理做准备。

关键部分的zoom-FFT代码(按照之前寻找的信号峰值进行插值处理,每次处理一个峰值)

复制代码
/**
 *  @b Description
 *  @n
 *      Interpolation using complex multiplication module.
 */
void MmwDemo_processInterpolation(MmwDemo_DataPathObj *obj)
{
    int32_t        i, max_ind, interp_factor, coarseIndStart;
    cmplx32ImRe_t *interpOutsAddr;
    float          power, maxP;

    float fpower[3], interpIndx, maxIndexFine, fineFreqEst;


    interp_factor  = (obj->zoomInFFTSize >> (obj->log2RangeBins));
    interpOutsAddr = (cmplx32ImRe_t *)MMW_HWA_INTERP_OUT;

    MmwDemo_configInterp_HWA(obj);
    MmwDemo_dataPathTriggerInterp(obj);
    MmwDemo_dataPathWaitInterp(obj);

    if (obj->rangeProcStats.maxIndex < SAMPLES_TO_ZOOM_IN_ONE_SIDE)
    {
        coarseIndStart = 0;
    }
    else if (obj->rangeProcStats.maxIndex > (obj->numRangeBins - SAMPLES_TO_ZOOM_IN_ONE_SIDE))
    {
        coarseIndStart = obj->numRangeBins - 2 * SAMPLES_TO_ZOOM_IN_ONE_SIDE;
    }
    else
    {
        coarseIndStart = obj->rangeProcStats.maxIndex - SAMPLES_TO_ZOOM_IN_ONE_SIDE;
    }

    maxP = 0.f;
    for (i = 0; i < 2 * SAMPLES_TO_ZOOM_IN_ONE_SIDE * interp_factor; i++)
    {
        power = (float)interpOutsAddr[i].imag * (float)interpOutsAddr[i].imag + (float)interpOutsAddr[i].real * (float)interpOutsAddr[i].real;
        if (power > maxP)
        {
            maxP    = power;
            max_ind = i;
        }
    }
    obj->finePeakIndex = max_ind;

    i         = max_ind - 1;
    fpower[0] = (float)interpOutsAddr[i].imag * (float)interpOutsAddr[i].imag + (float)interpOutsAddr[i].real * (float)interpOutsAddr[i].real;
    i         = max_ind;
    fpower[1] = (float)interpOutsAddr[i].imag * (float)interpOutsAddr[i].imag + (float)interpOutsAddr[i].real * (float)interpOutsAddr[i].real;
    i         = max_ind + 1;
    fpower[2] = (float)interpOutsAddr[i].imag * (float)interpOutsAddr[i].imag + (float)interpOutsAddr[i].real * (float)interpOutsAddr[i].real;

    interpIndx = 0.5f * (fpower[0] - fpower[2]) / (fpower[0] + fpower[2] - 2.f * fpower[1]);

    obj->interpIndex = interpIndx;
    maxIndexFine     = (float)(interp_factor * coarseIndStart + max_ind) + interpIndx;
    fineFreqEst      = maxIndexFine * obj->maxBeatFreq / (interp_factor * obj->numRangeBins);
    obj->rangeEst    = (fineFreqEst * 3.0e8 * obj->chirpRampTime) / (2 * obj->chirpBandwidth);
}

总结

xWR14xx上的高精度测距工程分析完成了,简单明了!

由于使用了HWA,而HWA的FFT大小是有限制的,所以一定程度上限制了此工程的精度。如果需要更高精度的实现,可以在DSP中实现、优化算法。

相关推荐
yasuniko1 小时前
C复习(主要复习)
c语言·数据结构·算法
时光の尘3 小时前
FreeRTOS菜鸟入门(五)·空闲任务与阻塞延时的实现
c语言·stm32·嵌入式硬件·mcu·物联网·freertos
古月居GYH7 小时前
嵌入式C语言高级编程:OOP封装、TDD测试与防御性编程实践
c语言·开发语言·tdd
汤姆_5118 小时前
【c语言】深入理解指针1
c语言·开发语言
Y1anoohh9 小时前
驱动学习专栏--字符设备驱动篇--2_字符设备注册与注销
linux·c语言·驱动开发·学习
Wythzhfrey9 小时前
单片机Day05---静态数码管
c语言·单片机·嵌入式硬件·学习·c#·51单片机
ん贤11 小时前
图论基础理论
c语言·数据结构·c++·算法·图论
夜月yeyue11 小时前
VScode+OpenOCD+HTOS栈回溯在国产mcu芯片上完全调试
c语言·ide·vscode·单片机·嵌入式硬件·编辑器
Yesheldon11 小时前
高速电路中的电感、磁珠的选型及应用
单片机·嵌入式硬件·硬件架构·硬件工程·智能硬件