Skip to content

关于利用ESP32-S3进行双向测距开发的疑问 (AEGHB-1094) #227

Open
@Dircwzf

Description

@Dircwzf

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate.
  • Provided a clear description of your suggestion.
  • Included any relevant context or examples.

Issue or Suggestion Description

Image
如图所示,我想利用两块开发板,两者没有进行时钟同步,进行双向测距。设备A首先发送信号,记录发射完成的本地时间t1,设备B收到信号后记录粗略本地时间t2,并记录信道状态信息csi2用于估计延时delay_t2,接收完成的精确时间为t2+delat_t2,间隔固定时间deltaT后发送信息并记录发射完成的本地时间t3,设备A在收到信号后记录粗略本地时间t4,并记录csi4用于估计延时delay_t4,接收完成的精确时间为t4+delat_t4。
飞行时间ToF = ((t4+delay_t4-t1)-(t3-t2-delay_t2))/ 2,AB距离为Range = ToF*光速

static void wifi_csi_rx_cb(void *ctx, wifi_csi_info_t *info) {
    if (!info || memcmp(info->mac, MAC_B, 6)) return;

    if (exp_counter >= EXPERIMENT_COUNT) return;

    // 记录时间戳和CSI数据
    csi_packet[exp_counter].t4 = info->rx_ctrl.timestamp;
    csi_packet[exp_counter].csi4_len = info->len > CSI_DATA_LEN ? CSI_DATA_LEN : info->len;
    // 缓存CSI4数据
    memcpy(csi_packet[exp_counter].csi4, info->buf, info->len > CSI_DATA_LEN ? CSI_DATA_LEN : `info->len);
}
while (exp_counter < EXPERIMENT_COUNT) {
        // 记录发送时间t1并发送信号
        csi_packet[exp_counter].t1 = esp_timer_get_time();
        uint8_t trigger = 0xFF;
        esp_now_send(MAC_B, &trigger, 1);
        
        vTaskDelay(pdMS_TO_TICKS(2000)); 
 }

我接收时信号时记录时间是用的rx_ctrl中的timestamp,发射信号时的时间记录用的是esp_timer_get_time()。
但是时钟精度并不高,esp-idf中有定义硬件时钟GPtimer,硬件时钟最高分辨率只能达到时钟源频率的一半,我如何让Xtensa LX 7一直保持最高时钟频率240MHz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions