Просмотр исходного кода

1.修改ms1031寄存器参数来适配DN25与DN15,优化了飞行时间差的波动。
2.修复了在红外通信时导致ms1031卡死的问题(无法计量,瞬时流量显示页面卡死)。

HBR 2 недель назад
Родитель
Сommit
bff6bedd15
5 измененных файлов с 20 добавлено и 18 удалено
  1. 1 1
      Drivers/Board/board.h
  2. 2 2
      Users/main.c
  3. 3 1
      Users/rtc_isr.c
  4. 10 10
      Users/tdc_tof/tdc_ms1030.c
  5. 4 4
      Users/tdc_tof/tof_isr.c

+ 1 - 1
Drivers/Board/board.h

@@ -23,7 +23,7 @@
 
 #define BOOTLOADER_ENABLE // 从0x0000启动运行时,屏蔽该宏
 
-#define APP_DEBUG_PRINT // 调试打印开关
+//#define APP_DEBUG_PRINT // 调试打印开关
 
 // #define DEBUG_LOW_POWER
 //#define DOG_ENABLE // WXL2026-5-12

+ 2 - 2
Users/main.c

@@ -372,7 +372,7 @@ static void tdc_business_thread(void *parameter)
             rtc_run_t *rr;
             get_rtc_run(&rr);
 //#ifdef DEBUG_TDC
-            LOG("Diff=%.6f, AvgDiff=%.6f, T=%.6f, vol=%.6f\n", SerPlot.f.Data[0], SerPlot.f.Data[3], WaterPrmt[0], FlowVol * 0.000001f * 3600);
+//            LOG("Diff=%.6f, AvgDiff=%.6f, T=%.6f, vol=%.6f\n", SerPlot.f.Data[0], SerPlot.f.Data[3], WaterPrmt[0], FlowVol * 0.000001f * 3600);
             // LOG("diff=%.6f, U=%.6f, D=%.6f\n", SerPlot.f.Data[0], SerPlot.f.Data[1], SerPlot.f.Data[2]);
             rt_thread_mdelay(4);
 //#endif
@@ -614,7 +614,7 @@ int32_t main(void)
 
     rtc_thread_create();      // 创建RTC线程
     tdc_thread_create();      // 创建TDC线程
-//    nb_thread_create();       // 创建NB线程
+    nb_thread_create();       // 创建NB线程
     lcd_thread_create();      // 创建LCD线程
     Key_press_timer_create(); // 创建按键时长检测定时器
 

+ 3 - 1
Users/rtc_isr.c

@@ -164,7 +164,9 @@ void RTC_IRQHandler(void)
 		//add by yuewei 20260309 to deal hongwai long data
     if(HONGWAI_LONG_RX_FLAG == 1)return;
 		//LOG("---------------------------------0\n");
-
+    extern uint8_t finsh_txing_flag;     //modify by HBR 20260914 ,·ÀÖ¹ÔÚºìÍâͨÐÅʱ¿¨ËÀms1031    
+    if(finsh_txing_flag==1) return;
+        
 		//return;
 		//us_delay(2000);//!!!!!do not modify!!!!!
 		//rt_thread_delay(5);//!!!!!do not modify!!!!!

+ 10 - 10
Users/tdc_tof/tdc_ms1030.c

@@ -1,13 +1,13 @@
 #include "board.h"
 #include "tdc_tof.h"
 
-#define ANZ_FIRE        12u	//fire发送脉冲数
+#define ANZ_FIRE        26u	//fire发送脉冲数                //modified by HBR 20260911 12->26
 #define DIV_FIRE        3u	//内部时钟产生脉冲的分频
 #define DIV_CLKHS 	    0u	//高速时钟分频
 #define START_CLKHS     2u	//高速启动后测量前晶振启动间隔时间,2(120us),0 = 晶振关闭;1 = 晶振持续开启;2 = 启振延迟时间 120 μs
 #define NEG_START  	    0u	//start通道边缘
 #define NEG_STOP        0u	//stop通道边缘
-#define HITIN           9u	//stop预期脉冲数
+#define HITIN           5u	//stop预期脉冲数                //modified by HBR 20260911 9->5
 #define SEL_TIMO_MB	    3u	//测量范围溢出选择时间限制,3 = 512μs,4 = 1024μs
 #define SEL_TSTO2       3u	//TSTO2 管脚状态设置,3 = 32kHz 输出
 #define SEL_TSTO1       0u	//TSTO1 管脚状态设置,0 = 高速时钟输入
@@ -26,8 +26,8 @@
 #define EN_INT_HIT      0       //END HITS中断触发位,0=关闭中断
 #define EN_INT_ALU      1       //alu中断触发位,1=开启中断
 #define RFEDGE          0       //stop通道边沿敏感性,0 = 上升或下降沿
-#define UP_DELVAL1      200u    //当EN_FIST_WAVE=1时,为第一波顺流屏蔽窗口 BIT12~27,200*0.25=50us
-#define OFFSET          0      //当en_hc=0时, OFFSET电压31~-32mV;0=0mV,1=1mV,...31=31mV,32=-32mV...63=-1mV,60=-4mV
+#define UP_DELVAL1      220u    //当EN_FIST_WAVE=1时,为第一波顺流屏蔽窗口 BIT12~27,200*0.25=50us  //modified by HBR 20260911 200->220
+#define OFFSET          9      //当en_hc=0时, OFFSET电压31~-32mV;0=0mV,1=1mV,...31=31mV,32=-32mV...63=-1mV,60=-4mV //modified by HBR 20260911 0->9
 #define DFLT_WREG1      ((EN_INT_TO<<31)        | \
                         ( EN_INT_HIT<<30)       | \
                         ( EN_INT_ALU<<29)       | \
@@ -36,7 +36,7 @@
                         ( OFFSET<< 0))
 											
 #define EN_FIRST_WAVE   1u	//BIT31, 为1时后面的定义有效
-#define EDGE_FW         0u	//第一波边缘敏感性,0 = 上升沿
+#define EDGE_FW         0u	//第一波边缘敏感性,0 = 上升沿 
 #define DELREL1         6u	//第1个stop接收第几个回波周期
 #define DELREL2         8u	//第2个stop接收第几个回波周期
 #define DELREL3         10u	//第3个stop接收第几个回波周期
@@ -109,13 +109,13 @@
                         ( PHASE_FIRENUM<<6)     | \
                         ( ANZ_PHASE<<0))      
 
-#define DOWN_DELVAL1    200u    //当EN_FIST_WAVE=1时,为第一波逆流屏蔽窗口 BIT12~27,200*0.25=50us
+#define DOWN_DELVAL1    220u    //当EN_FIST_WAVE=1时,为第一波逆流屏蔽窗口 BIT12~27,200*0.25=50us  //modified by HBR 20260911 200->220
 #define SEL_SRC_CLK     0       //选择高速时钟输入源,0:高速晶振产生时钟
 #define EN_HC           0       //比较器调节步长,0:1mV,1:2mV
 #define CURR32K         0       //32kHz 晶振功耗设置,0:低功耗
 #define DIS_Vref        1       //基准电压输出控制,0:开启基准输出, 1:关闭基准输出
 #define ADJ_LDO_ROUGH   0       //内部 LDO 输出粗调,0:1.8V 档位, 1:1.5V 档位       
-#define ADJ_LDO_FINE    0       //内部 LDO 输出细调, 0-7:细调 LDO 输出电压
+#define ADJ_LDO_FINE    4       //内部 LDO 输出细调, 0-7:细调 LDO 输出电压   //modified by HBR 20260911 0->4
 #define DFLT_WREG6      ((DOWN_DELVAL1<<12)     | \
                         ( SEL_SRC_CLK<<7)       | \
                         ( EN_HC<<6)             | \
@@ -282,7 +282,7 @@ void tdc_read_tof(uint32_t cfg)
         //tdc_spi_wr_code(0x70);
     }
 
-    if ((TdcStatus&0x03F0) != 0x0090u)    //modified by yuewei 260813 0x06F0 -> 0x03F0, to match ms1031 
+    if ((TdcStatus&0x03F0) != 0x0050u)    //modified by HBR 20260911 0x0090u -> 0x0050u 
     {   
         tof_flag |= TOF_FLAG_BLANK_PIPE;
         tdc_spi_wr_code(0x70);
@@ -296,10 +296,10 @@ void tdc_read_tof(uint32_t cfg)
         TdcDPwHw = TdcUPwHw;   
 
         // TOF_UP_HITs
-        TdcUToF[0] = tdc_spi_rd_d32(0xb8)*(1.0f/8);  // average of all
+        TdcUToF[0] = tdc_spi_rd_d32(0xb8)*(1.0f/4); //modified by HBR 20260911 8->4
 
         // TOF_DOWN_HITs
-        TdcDToF[0] = tdc_spi_rd_d32(0xc8)*(1.0f/8);  // average of all
+        TdcDToF[0] = tdc_spi_rd_d32(0xc8)*(1.0f/4); //modified by HBR 20260911 8->4
 
         tdc_spi_wr_code(0x70);
         //modified by yuewei 260813 end

+ 4 - 4
Users/tdc_tof/tof_isr.c

@@ -6,8 +6,8 @@
 #define TOF_PWFW_DIFF ((uint16_t)(0x1620u * 25 / 100))
 #define TOF_PWFW_LOW ((uint16_t)(0x1620u * 40 / 100))
 #define TOF_PWFW_HIGH ((uint16_t)(0x1620u * 50 / 100))
-#define TOF_OFST_LOW (10)
-#define TOF_OFST_HIGH (26)
+#define TOF_OFST_LOW (9)  //modefiy //modified by HBR 20260911 10->9
+#define TOF_OFST_HIGH (27) //modefiy //modified by HBR 20260911 26->27
 
 uint8_t TdcFwOfst = (TOF_OFST_LOW + TOF_OFST_HIGH) / 2;
 
@@ -322,8 +322,8 @@ void read_tof_and_convert_to_flow(void)
             // DiffToF = DiffToF * DIFF_TOFF_FILTER_ALPHA + (1 - DIFF_TOFF_FILTER_ALPHA) * DiffToF_LAST;
 
             // DiffToF = tof_filter(DiffToF);//20260429
-//            DiffToF = tof_filter_input_poll(ch, DiffToF);
-            // LOG("ch%d, U=%.6f, D=%.6f\n", ch, UToFAvg, DToFAvg);
+            DiffToF = tof_filter_input_poll(ch, DiffToF);
+//             LOG("ch%d, U=%.6f, D=%.6f\n", ch, UToFAvg, DToFAvg);
             // LOG("int_cnt=%d, step=%d, ch=%d, DiffToF=%.6f\n\n", int_cnt, get_tdc_int_step(), ch, DiffToF);
         }
         // 本次飞行时间和赋值给上次飞行时间和