TI中文支持网
TI专业的中文技术问题搜集分享网站

TDC7201-ZAX-EVM: 如果MSP430和TDC7201结合实现激光测距,那采用的嵌入式程序是否为下面的示例代码? 来源为TDC7201自带的Firmware\TDC720xEVM_Firmware_Source-v2.07\code\demo_apps

Part Number:TDC7201-ZAX-EVMOther Parts Discussed in Thread:TDC7201, MSP430F5529,

代码文件名为tdc720x_calculation.c

#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "TI_TDC720x.h"  
#include "TI_MSP430.h"
#include "TI_MSP430_hardware_board.h"
#include "TI_MSP430_spi.h"
#include "timer_queue.h"
#include "tdc720x_calculation.h"
#include "uart_commn.h"

//******************************************************************************
extern uint8_t TDC720x_reg_local_copy[];
// default onboard clk in ns
float tdc_clk_period = 125.0;
float start2stop[MAX_STOPS];
uint8_t outString[128];
int32_t meas_result_regrs[MEAS_RESULT_REG_NUM];
float norm_lsb;
float ccnt;
float mreg[13];
float Time1,Time2,Time3,Time4,Time5,Time6;
float Clk_count1,Clk_count2,Clk_count3,Clk_count4,Clk_count5;
float Calibration1,Calibration2;
float st2sp[5];
float nlsb;
//------------------------------------------------------------------------------
void TDC720x_calc(uint8_t *buf, uint8_t dev)
{TDC720x_build_mreg(buf);TDC720x_start2stopn(dev);print_start2stopn();

}
//******************************************************************************
void print_start2stopn(void)
{uint8_t i;
#if 0float tmp;for(i=0; i < MEAS_RESULT_REG_NUM; i++){tmp = (float) meas_result_regrs[i];sprintf((char *)outString, "mreg[%d]: %4.6f", i, tmp);putsUART((unsigned char *)outString,strlen((char *)outString));if (((i+1) % 3) == 0){sprintf((char *)outString, " \r\n");putsUART((unsigned char *)outString,strlen((char *)outString));}}sprintf((char *)outString, " \r\n");putsUART((unsigned char *)outString,strlen((char *)outString));sprintf((char *)outString, "norm_lsb: %4.6f  ", norm_lsb);putsUART((unsigned char *)outString,strlen((char *)outString));sprintf((char *)outString, "cal_count: %4.6f \r\n", ccnt);putsUART((unsigned char *)outString,strlen((char *)outString));  
#endiffor (i=0;i<MAX_STOPS;i++){sprintf((char *)outString, "Start_to_Stop[%d]: %4.6f", i+1, start2stop[i]);putsUART((unsigned char *)outString,strlen((char *)outString));}sprintf((char *)outString, " \r\n");putsUART((unsigned char *)outString,strlen((char *)outString));  
}
//计算飞行时间
void TDC720x_start2stopn(uint8_t dev)
{uint8_t n;TDC720x_normlsb(dev);mreg[0]  = Time1;mreg[1] = Clk_count1; mreg[2] = Time2;mreg[3]  = Clk_count2; mreg[4] = Time3;mreg[5] = Clk_count3;mreg[6]  = Time4;mreg[7] = Clk_count4; mreg[8] = Time5;mreg[9]  = Clk_count5; mreg[10] = Time6;mreg[11] = Calibration1;mreg[12] = Calibration2;st2sp[0] = nlsb * (Time1 - Time2) + tdc_clk_period * Clk_count1;st2sp[1] = nlsb * (Time1 - Time3) + tdc_clk_period * Clk_count2;st2sp[2] = nlsb * (Time1 - Time4) + tdc_clk_period * Clk_count3;st2sp[3] = nlsb * (Time1 - Time5) + tdc_clk_period * Clk_count4;st2sp[4] = nlsb * (Time1 - Time6) + tdc_clk_period * Clk_count5;// 最多5个stopfor(n=0; n < MAX_STOPS; n++)start2stop[n] = norm_lsb * (meas_result_regrs[0] - meas_result_regrs[2*(n+1)]) +tdc_clk_period * meas_result_regrs[2*(n+1)-1];

}

//校准得到的归一化LSB值
void TDC720x_normlsb(uint8_t dev)
{uint8_t tdcbyte, cal2cy;// read config2 register - use local saved datatdcbyte = (TI_TDC720x_SPIByteReadReg(TI_TDC720x_CONFIG2_REG, dev) & CAL2MASK)>>CAL2SHFT;switch (tdcbyte){case 0:cal2cy = 2;break;case 1:cal2cy = 10;break;case 2:cal2cy = 20;break;case 3:cal2cy = 40;default:cal2cy = 10;}ccnt = (float) (meas_result_regrs[12]-meas_result_regrs[11])/(cal2cy-1);norm_lsb = tdc_clk_period / ccnt;  
}
//******************************************************************************
void TDC720x_build_mreg(uint8_t *buf)
{uint8_t i;mreg[0]  = Time1;mreg[1] = Clk_count1; mreg[2] = Time2;mreg[3]  = Clk_count2; mreg[4] = Time3;mreg[5] = Clk_count3;mreg[6]  = Time4;mreg[7] = Clk_count4; mreg[8] = Time5;mreg[9]  = Clk_count5; mreg[10] = Time6;mreg[11] = Calibration1;mreg[12] = Calibration2;for(i=0; i < MEAS_RESULT_REG_NUM; i++){meas_result_regrs[i] = (((uint32_t) buf[3*i]) << 16) +(((uint32_t) buf[(3*i)+1]) << 8) +(((uint32_t) buf[(3*i)+2]));}
}

Vivian Gao:

您好

是的。

这个帖子里面也有回复过。

e2e.ti.com/…/tdc7201-zax-evm-looking-for-tdc7201-example-firmware

,

?? ?:

mreg[0]= Time1;mreg[1] = Clk_count1; mreg[2] = Time2;mreg[3]= Clk_count2; mreg[4] = Time3;mreg[5] = Clk_count3;mreg[6]= Time4;mreg[7] = Clk_count4; mreg[8] = Time5;mreg[9]= Clk_count5; mreg[10] = Time6;mreg[11] = Calibration1;mreg[12] = Calibration2;

您好,示例代码中的Time1~Time6及等式右边的这些变量是在TDC7201收到激光发射信号和回波信号后就能直接得到吗?需要自己再修改代码定义并计算这些参数吗?

,

Vivian Gao:

您好

已经在您另一个帖子中回复。

(+) MSP430F5529: 使用MSP430和TDC7201-ZAX-EVM结合进行激光测距,运行MSP430自带的例子程序会报如下错误: – MSP 低功耗微控制器论坛 – MSP 低功耗微控制器 – E2ETm 设计支持 (ti.com)

,

?? ?:

您好,这边想知道如果按照使用说明给TDC7201一路激光发射信号,一路激光回收信号,而不给MSP430输入嵌入式程序,直接通过TDC7201自带的用户GUI界面,是否能在界面上显示飞行时间?

,

?? ?:

还有个问题,如果想实现激光测距那自带的Firmware中的示例程序是每个都能用到吗,还是说用哪个程序就往MSP430里烧录该程序?

,

?? ?:

这边还有个问题就是在测量飞行时间时如何完成不同时序信号的同步?另外图中由MSP430的两路给TDC7201提供的START和COMMON START各是什么信号,具体的硬件连接上MSP430连哪两路输出,TDC7201应该连哪几路输入?

,

?? ?:

因为我看到论坛上有个帖子说买回来的TDC7201和MSP430F5529 LaunchPad直接操作GUI界面就可以,不需要对MSP430F5529 LaunchPad进行编程即可完成测距?

,

Vivian Gao:

TDC7201EVM 通过J1 和J2与MSP430 LaunchPad连接,MSP430 LaunchPad通过USB线连接到PC上。再详细的电路,看评估板的原理图。

按照TDC7201-ZAX-EVM User’s Guide进行操作即可,MSP430 Launch Pad这个板子是不需要配置的,固件按照手册中说的去选择。

https://www.ti.com.cn/cn/lit/ug/snau198a/snau198a.pdf

其他问题请重新发帖。

赞(0)
未经允许不得转载:TI中文支持网 » TDC7201-ZAX-EVM: 如果MSP430和TDC7201结合实现激光测距,那采用的嵌入式程序是否为下面的示例代码? 来源为TDC7201自带的Firmware\TDC720xEVM_Firmware_Source-v2.07\code\demo_apps
分享到: 更多 (0)

© 2024 TI中文支持网   网站地图 鲁ICP备2022002796号-1