You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
614 lines
28 KiB
614 lines
28 KiB
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 1
|
|
|
|
|
|
C51 COMPILER V9.54, COMPILATION OF MODULE APP_WEIGHT
|
|
OBJECT MODULE PLACED IN ..\out\app_weight.obj
|
|
COMPILER INVOKED BY: E:\KeilC51\C51\BIN\C51.EXE ..\source\app\app_weight.c LARGE OMF2 OPTIMIZE(0,SIZE) BROWSE ORDER NOIN
|
|
-TPROMOTE INCDIR(..\source\bsp;..\source\msp;..\source\app;..\source\clib;..\source\cpu;..\source\ctask;..\source\tpc;..\
|
|
-source\asp;..\source\debug;..\source\msp\uart;..\source\msp\simiic;..\source\bsp\oled;..\source\bsp\TTSSbsp) DEBUG PRINT
|
|
-(..\out\app_weight.lst) TABS(2) OBJECT(..\out\app_weight.obj)
|
|
|
|
line level source
|
|
|
|
1 ////////////////////////////////////////////////////////////////////////////
|
|
2 ///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
|
3 ///-------------------------------------------------------------------------
|
|
4 /// @file bsp_drv.c
|
|
5 /// @brief bsp @ driver config
|
|
6 ///-------------------------------------------------------------------------
|
|
7 /// @version 1.0
|
|
8 /// @author CC
|
|
9 /// @date 20180331
|
|
10 /// @note cc_AS_stc02
|
|
11 //////////////////////////////////////////////////////////////////////////////
|
|
12
|
|
13 #include "app_weight.h"
|
|
*** WARNING C320 IN LINE 51 OF ..\source\bsp\TTSSbsp\bsp_config.h: "MainFre_22M"
|
|
14 #include "app_config.h"
|
|
15 #include "debug_drv.h"
|
|
16 #include "msp_eeprom.h"
|
|
17
|
|
18 #define D_0kg 0
|
|
19 #define D_20kg 200///0x00c8
|
|
20 #define D_85kg 850////0x0352
|
|
21
|
|
22 /*
|
|
23 #define D_Rsensor_out_D_0kg 0x18D9
|
|
24 #define D_Rsensor_out_D_20kg 0x1B8B
|
|
25 #define D_Rsensor_out_D_85kg 0x244D
|
|
26 */
|
|
27
|
|
28 #define D_Rsensor_out_D_0kg 0x18D9
|
|
29 #define D_Rsensor_out_D_20kg 0x1c2c
|
|
30 #define D_Rsensor_out_D_85kg 0x26f9
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35 ///#define D_20kg 190
|
|
36 ///cc 2023/04/06--6:41:48 西安方块 传感器 根据传感器调配 程序应该专门数据结构
|
|
37
|
|
38
|
|
39 ///cc 2023/04/06--7:50:26 应该是tst_weight.out6的值
|
|
40 ///cc 2023/04/09--8:11:50 adc改为out 因为到了weight这一层 已经不合适用adc,adc的和值
|
|
-输出out给了weight来做运算
|
|
41
|
|
42 TS_weight_SPara_ ts_weight_SPara =
|
|
43 {
|
|
44 'W',//0 1 u8 rev1;
|
|
45 'E',//1 2 u8 rev2;
|
|
46 D_0kg ,D_Rsensor_out_D_0kg,
|
|
47 D_20kg,D_Rsensor_out_D_20kg,
|
|
48 D_85kg,D_Rsensor_out_D_85kg,
|
|
49
|
|
50 //2 3 TS_weight_point_ zerows[3]; ///4x3=12 手工清零后的参数, 没有清零或者出错恢复��
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 2
|
|
|
|
-�和出厂设置一样,需要实时保存
|
|
51 'A',//3 4 u8 rev3;
|
|
52 ' ',//4 5 u8 rev4;
|
|
53
|
|
54 };
|
|
55 TS_TASK_weight_ tst_weight;
|
|
56
|
|
57
|
|
58 #define D_task_WEIGHT_add 12
|
|
59 #define D_task_WEIGHT_CAL 13
|
|
60 #define D_task_WEIGHT_get 14
|
|
61 #define D_task_WEIGHT_zero 15
|
|
62 ///#define D_task_WEIGHT_CAL 124
|
|
63
|
|
64 #define D_task_WEIGHT_out 45
|
|
65 #define D_task_WEIGHT_Sline 11
|
|
66 #define D_task_WEIGHT_getADC 22
|
|
67 ///#define D_task_WEIGHT_CAL 33
|
|
68 ////#define D_task_WEIGHT_Sline
|
|
69
|
|
70
|
|
71
|
|
72 void L2_task_weight_init(u8 openclose)
|
|
73 {
|
|
74 1 if(openclose)
|
|
75 1 {
|
|
76 2 L0_ADS1213_INIT(D_ADS1213_GAIN_128);
|
|
77 2 L2_task_adc_init(0);
|
|
78 2 L2_task_adc_init(1);
|
|
79 2 L2_task_adc_init(2);
|
|
80 2 L2_task_adc_init(3);
|
|
81 2
|
|
82 2 }else
|
|
83 1 {
|
|
84 2 tst_weight.pSPara = &ts_weight_SPara;
|
|
85 2 }
|
|
86 1 /*
|
|
87 1 L2_task_adc_SAinit(0,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
88 1 L2_task_adc_SAinit(1,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
89 1 L2_task_adc_SAinit(2,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
90 1 L2_task_adc_SAinit(3,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
91 1
|
|
92 1
|
|
93 1
|
|
94 1
|
|
95 1 ts_adc_samples[0].offset = S.sd.offset[0];
|
|
96 1 ts_adc_samples[1].offset = S.sd.offset[1];
|
|
97 1 ts_adc_samples[2].offset = S.sd.offset[2];
|
|
98 1 ts_adc_samples[3].offset = S.sd.offset[3];
|
|
99 1
|
|
100 1
|
|
101 1 */
|
|
102 1
|
|
103 1
|
|
104 1 }
|
|
105
|
|
106 void L3_task_weight_init(void)
|
|
107 {
|
|
108 1 //显示任务初始化
|
|
109 1 L1_task_reg_clear(&tst_weight.task);
|
|
110 1 L3_task_s_go(tst_weight,D_task_init);
|
|
111 1 L2_task_weight_init(1);
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 3
|
|
|
|
112 1 ///Lc_buf_from_const_uc(U8 * d, const U8 * s, U16 num)
|
|
113 1 ///tst_weight.pSPara->ts_WPoint
|
|
114 1 }
|
|
115
|
|
116 #define D_debug_ch D_Wch2
|
|
117 ///L3_task_weight_handler(&tst_weight);
|
|
118 void L3_task_weight_handler(TS_TASK_weight_ *s)
|
|
119 {
|
|
120 1 L2_task_adc_sample(&ts_adc_samples[D_Wch1]);
|
|
121 1
|
|
122 1 L2_task_adc_sample(&ts_adc_samples[D_Wch2]);
|
|
123 1
|
|
124 1 L2_task_adc_sample(&ts_adc_samples[D_Wch3]);
|
|
125 1
|
|
126 1 L2_task_adc_sample(&ts_adc_samples[D_Wch4]);
|
|
127 1
|
|
128 1 TTSS_Task_init():
|
|
129 2 L0_waitFree_uartN(0);
|
|
130 2
|
|
131 2 /*
|
|
132 2 printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[0].
|
|
-offset,ts_adc_samples[0].offset);
|
|
133 2 printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[1].
|
|
-offset,ts_adc_samples[1].offset);
|
|
134 2 printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[2].
|
|
-offset,ts_adc_samples[2].offset);
|
|
135 2 printf("\r\nR.sd.zeroout= %d = 0x%4x offset %d = 0x%4x", R.sd.zeroout, R.sd.zeroout,ts_adc_samples[3].
|
|
-offset,ts_adc_samples[3].offset);
|
|
136 2
|
|
137 2 printf('4');
|
|
138 2
|
|
139 2 */
|
|
140 2 s->slow = 0;
|
|
141 2 s->zero = 0;s->kgx10_zero = 0;
|
|
142 2 printfs(" L3_task_weight_handler ");
|
|
143 2
|
|
144 2 L2_task_go(D_task_WEIGHT_get);
|
|
145 2 TTSS_Task_step(D_task_WEIGHT_get):
|
|
146 2 if(1 == ts_adc_samples[D_Wch4].ok)
|
|
147 2 {//
|
|
148 3 ts_adc_samples[0].ok = 0;
|
|
149 3 ts_adc_samples[1].ok = 0;
|
|
150 3 ts_adc_samples[2].ok = 0;
|
|
151 3 ts_adc_samples[3].ok = 0;
|
|
152 3 s->slow ++;
|
|
153 3 // L0_uart0_uc('%');
|
|
154 3 L2_task_go(D_task_WEIGHT_Sline);
|
|
155 3 }
|
|
156 2 TTSS_Task_step(D_task_WEIGHT_Sline):
|
|
157 2 if (s->slow >= 1)////采样减速
|
|
158 2 {s->slow = 0;
|
|
159 3 ///调用asp——adc中的输出 out3
|
|
160 3 /************/
|
|
161 3 ///cc 2023/04/06--8:9:18 选择使用哪一条滤波线
|
|
162 3
|
|
163 3 ts_adc_samples[0].out5 = ts_adc_samples[0].ts_SAa.out4_shift;
|
|
164 3 ts_adc_samples[1].out5 = ts_adc_samples[1].ts_SAa.out4_shift;
|
|
165 3 ts_adc_samples[2].out5 = ts_adc_samples[2].ts_SAa.out4_shift;
|
|
166 3 ts_adc_samples[3].out5 = ts_adc_samples[3].ts_SAa.out4_shift;
|
|
167 3
|
|
168 3 L2_task_go(D_task_WEIGHT_getADC);
|
|
169 3 }else
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 4
|
|
|
|
170 2 {
|
|
171 3 L2_task_go(D_task_WEIGHT_get);
|
|
172 3 }
|
|
173 2 //L2_task_go(D_task_WEIGHT_getADC);
|
|
174 2 TTSS_Task_step(D_task_WEIGHT_getADC):
|
|
175 2
|
|
176 2
|
|
177 2 ////四个传感器相加后平均
|
|
178 2 tst_weight.sum32 = ts_adc_samples[0].out5;
|
|
179 2 tst_weight.sum32 += ts_adc_samples[1].out5;
|
|
180 2 tst_weight.sum32 += ts_adc_samples[2].out5;
|
|
181 2 tst_weight.sum32 += ts_adc_samples[3].out5;
|
|
182 2
|
|
183 2 tst_weight.out6 = tst_weight.sum32 >>2;
|
|
184 2
|
|
185 2 L2_task_go(D_task_WEIGHT_CAL);
|
|
186 2 TTSS_Task_step(D_task_WEIGHT_CAL):
|
|
187 2
|
|
188 2 tst_weight.adc32 = tst_weight.out6;
|
|
189 2
|
|
190 2 L3_task_weight_cal();
|
|
191 2
|
|
192 2 L2_task_go(D_task_WEIGHT_out);
|
|
193 2 TTSS_Task_step(D_task_WEIGHT_out):
|
|
194 2 if(tst_weight.kgx10 > tst_weight.kgx10_zero)
|
|
195 2 {
|
|
196 3 s->kgx10_out = s->kgx10 - s->kgx10_zero;
|
|
197 3 }else
|
|
198 2 {
|
|
199 3 s->kgx10_out = 0 ;
|
|
200 3 }
|
|
201 2 //// D_LED1_REV(); L4_weight_out(); D_LED1_REV();
|
|
202 2
|
|
203 2
|
|
204 2
|
|
205 2 /// L4_weight_print();///需要调试的时候打开!!!!!!!!!!!!!!!
|
|
206 2 L2_task_Tdelay_go(D_Tdelay_200ms, D_task_WEIGHT_get);
|
|
207 2 /// L2_task_go(D_task_WEIGHT_get);
|
|
208 2 TTSS_Task_step(D_task_WEIGHT_zero):
|
|
209 2
|
|
210 2
|
|
211 2 L2_task_go(D_task_WEIGHT_get);
|
|
212 2 TTSS_Task_end();
|
|
213 1 }
|
|
214
|
|
215
|
|
216 void L3_task_weight_cal(void)
|
|
217 {
|
|
218 1 if(tst_weight.adc32 <= (vU32)S.weight_SPara.ts_WPoint[1].adc)
|
|
219 1 {
|
|
220 2 if(tst_weight.adc32 <= (vU32)S.weight_SPara.ts_WPoint[0].adc )
|
|
221 2 {
|
|
222 3 tst_weight.adc32 = (vU32)S.weight_SPara.ts_WPoint[0].adc;
|
|
223 3 }
|
|
224 2 ///0-0-40KG
|
|
225 2 tst_weight.t32a = (tst_weight.adc32-(vU32)S.weight_SPara.ts_WPoint[0].adc);////有可能<0
|
|
226 2 tst_weight.t32b = (vU32)(S.weight_SPara.ts_WPoint[1].adc-S.weight_SPara.ts_WPoint[0].adc);
|
|
227 2 tst_weight.t32a *= (vU32)(S.weight_SPara.ts_WPoint[1].kg - S.weight_SPara.ts_WPoint[0].kg);
|
|
228 2 tst_weight.t32a /= tst_weight.t32b;
|
|
229 2
|
|
230 2 }else
|
|
231 1 { ///40KG 80KG
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 5
|
|
|
|
232 2 tst_weight.t32a = (vU32)(tst_weight.adc32-S.weight_SPara.ts_WPoint[1].adc);////有可能大于b
|
|
233 2 tst_weight.t32b = (vU32)(S.weight_SPara.ts_WPoint[2].adc-S.weight_SPara.ts_WPoint[1].adc);
|
|
234 2 tst_weight.t32a *= (vU32)(S.weight_SPara.ts_WPoint[2].kg-S.weight_SPara.ts_WPoint[1].kg) ;
|
|
235 2 tst_weight.t32a /= tst_weight.t32b;
|
|
236 2 tst_weight.t32a += (vU32)S.weight_SPara.ts_WPoint[1].kg;
|
|
237 2
|
|
238 2 }
|
|
239 1 tst_weight.kgx10 = (vU16)tst_weight.t32a;
|
|
240 1 }
|
|
241
|
|
242 /*
|
|
243
|
|
244 #define D_0kg 0
|
|
245 #define D_20kg 200///0x00c8
|
|
246 #define D_85kg 850////0x0352
|
|
247
|
|
248 #define D_Rsensor_out_D_0kg 0x18D9
|
|
249 #define D_Rsensor_out_D_20kg 0x1B8B
|
|
250 #define D_Rsensor_out_D_85kg 0x244D
|
|
251
|
|
252 */
|
|
253
|
|
254 #if 0
|
|
void L3_weight_ONdebug(u8 filter)//// ON listen function
|
|
{
|
|
if(filter == pd->filter)
|
|
{
|
|
///filter num d1 d2 d3 ....dn
|
|
////FE 08 11 22 33 44 55 66 77 88
|
|
///printf("\r\nDdebug:FD R1 R2 R3 R4 R5 R6 ocr FD->");
|
|
///printf4("22 ch:(%2X)-%2X S %2X=%2X\r\n",(int)pd->R1,(int)pd->R2,(int)pd->R3,(int)pd->ocr);
|
|
L1_uartD_Arrayhex((u8*)pd,9);
|
|
switch (pd->ocr)
|
|
{
|
|
case 0x20:
|
|
////选择一个砝码,发送0x12指令,然后读取的数据 和砝码的重量使用 20 21 22参
|
|
-数来
|
|
///fx R1 R2 R3R4 R5R6 ocr
|
|
///Fe ch 00 2233 4455 20 0x2233 kg= 0x4455 adc
|
|
///Fe 00 00 0000 18D9 20
|
|
///Fe 01 00 00c8 1c2c 20
|
|
///Fe 02 00 0352 26f9 20
|
|
/// 0352 26f9
|
|
///00c8 1c2c
|
|
///Fe 22 33 44 55 21
|
|
///Fe 22 33 44 55 22
|
|
if(pd->R1 < 3)
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg = D_2uc_u16(pd->R3,pd->R4);
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc = D_2uc_u16(pd->R5,pd->R6);
|
|
|
|
printf5("\r\nset %d: %4x(%6d) %4x(%6d)\r\n",(int)pd->R1,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg,ts_weight_SPara.ts_WPoint[pd->R1].kg,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc,ts_weight_SPara.ts_WPoint[pd->R1].adc); {
|
|
|
|
}
|
|
|
|
L3_R_2_S();
|
|
L0_Iap_Program_array(D_EEP_BASE,D_struct2U8(S),D_S_LEN);
|
|
break;
|
|
case 0x35: ///// '5'///
|
|
////选择一个砝码,发送0x12指令,然后读取的数据 和砝码的重量使用 20 21 22参
|
|
-数来
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 6
|
|
|
|
///fx R1 R2 R3R4 R5R6 ocr
|
|
///Fe ch 00 2233 4455 35 kg= 0x2233
|
|
|
|
////校准20kg 输入 Fe 01 00 00 c8 02 00 35
|
|
///Fe 01 00 00 c8 02 00 35 kg= 0x00c8=200d///需要校准的重量的 20kg 200d=0xc8
|
|
///校准20kg 输入 Fe 01 00 00 c8 02 00 35
|
|
|
|
/// Fe 00 00 00 00 01 00 35 校准零点 不需要上电即可
|
|
/// Fe 01 00 00 c8 02 00 35 20kg 放置20kg 然后输入
|
|
/// Fe 02 00 01 d6 03 00 35 47kg 10个3kg砝码实际是27kg+20kg
|
|
////如果需要上位机设置 需要在上位机的串口 加上D4 D代表chuandi
|
|
if(pd->R1 < 3)
|
|
{
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg = D_2uc_u16(pd->R3,pd->R4);
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc = tst_weight.adc32;////使用当前采样值
|
|
|
|
printf5("\r\nset %d: %4x(%6d) %4x(%6d)\r\n",(int)pd->R1,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].kg,ts_weight_SPara.ts_WPoint[pd->R1].kg,
|
|
ts_weight_SPara.ts_WPoint[pd->R1].adc,ts_weight_SPara.ts_WPoint[pd->R1].adc);
|
|
}
|
|
|
|
L3_R_2_S();
|
|
L0_Iap_Program_array(D_EEP_BASE,D_struct2U8(S),D_S_LEN);
|
|
break;
|
|
|
|
case 0x21: /// 清零指令 把当前的重量值作为0点; 可以在pad上配置参数
|
|
////Fe 223344556677 21
|
|
|
|
L4_weight_print();
|
|
tst_weight.kgx10_zero = tst_weight.kgx10;
|
|
printf2("\r\n kgx10_zero= %4x(%4d)",tst_weight.kgx10_zero,tst_weight.kgx10_zero);
|
|
break;
|
|
|
|
case 0x23:
|
|
///Fe 11 22 33 44 55 66 23
|
|
TTSS_run_times(3)
|
|
{
|
|
printf5("\r\n%d: %4x(%4d ) %4x(%6d)\r\n",(int)tst_v.i,
|
|
ts_weight_SPara.ts_WPoint[tst_v.i].kg,ts_weight_SPara.ts_WPoint[tst_v.i].kg,
|
|
ts_weight_SPara.ts_WPoint[tst_v.i].adc,ts_weight_SPara.ts_WPoint[tst_v.i].adc);
|
|
}
|
|
break;
|
|
|
|
case 0x32: ///读取当前的重量和传感器数值
|
|
///Fe 223344556677 12
|
|
printfs("\r\n ");
|
|
L4_weight_print();
|
|
break;
|
|
|
|
case 0x33: ///读取当前的重量和传感器数值 hex
|
|
///Fe 223344556677 12
|
|
D_LED1_REV();
|
|
L4_weight_out();
|
|
D_LED1_REV();
|
|
break;
|
|
|
|
default:
|
|
printfs(" pp error\r\n ");
|
|
break;
|
|
};
|
|
printfs("333");
|
|
}
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 7
|
|
|
|
}
|
|
|
|
#else
|
|
357 void L3_weight_ONdebug(u8 filter)//// ON listen function
|
|
358 {
|
|
359 1 // printf(" \r\n0->filter=%X ", (int)filter);
|
|
360 1 // printf(" \r\n1->filter=%X slaveId=%X cmd=%X len = %d ", (int)pd485->filter,(int)pd485->slaveId, (int)p
|
|
-d485->cmd, (int)ts_Urec[D_UART1].num);
|
|
361 1 // D_LED2_REV();
|
|
362 1 if(filter == pd485->filter)
|
|
363 1 {
|
|
364 2 // L1_uartD_Arrayhex((u8*)pd,9);
|
|
365 2 switch (pd485->cmd)
|
|
366 2 {
|
|
367 3 case 0x10:
|
|
368 3 ////读取称重
|
|
369 3 D_LED1_REV();
|
|
370 3 L4_weight_out();
|
|
371 3 D_LED1_REV();
|
|
372 3 break;
|
|
373 3
|
|
374 3 case 0x20:
|
|
375 3 ///// 校准
|
|
376 3 ////选择一个砝码,发送0x12指令,然后读取的数据 和砝码的重量使用 20 21 22参
|
|
-数来
|
|
377 3 ///fx R1 R2 R3R4 R5R6 ocr
|
|
378 3 ///Fe ch 00 2233 4455 35 kg= 0x2233
|
|
379 3
|
|
380 3 ////校准20kg 输入 Fe 01 00 00 c8 02 00 35
|
|
381 3 ///Fe 01 00 00 c8 02 00 35 kg= 0x00c8=200d///需要校准的重量的 20kg 200d=0xc8
|
|
382 3 ///校准20kg 输入 Fe 01 00 00 c8 02 00 35
|
|
383 3
|
|
384 3 /// Fe 00 00 00 00 01 00 35 校准零点 不需要上电即可
|
|
385 3 /// Fe 01 00 00 c8 02 00 35 20kg 放置20kg 然后输入
|
|
386 3 /// Fe 02 00 01 d6 03 00 35 47kg 10个3kg砝码实际是27kg+20kg
|
|
387 3 ////如果需要上位机设置 需要在上位机的串口 加上D4 D代表chuandi
|
|
388 3
|
|
389 3 //AA 02 20 00 03 pIndex kgx10_0 kgx10_1 ocr 对pIndex(0/1/2)点进行校准,校准值为kgx10
|
|
390 3 if(pd485->buf[0] < 3)
|
|
391 3 {
|
|
392 4 ts_weight_SPara.ts_WPoint[pd485->buf[0]].kg = D_2uc_u16(pd485->buf[1],pd485->buf[2]);
|
|
393 4 ts_weight_SPara.ts_WPoint[pd485->buf[0]].adc = tst_weight.adc32;////使用当前采样值
|
|
394 4
|
|
395 4 // printf5("\r\nset %d: %4x(%6d) %4x(%6d)\r\n",(int)pd->R1,
|
|
396 4 // ts_weight_SPara.ts_WPoint[pd->R1].kg,ts_weight_SPara.ts_WPoint[pd->R1].kg,
|
|
397 4 // ts_weight_SPara.ts_WPoint[pd->R1].adc,ts_weight_SPara.ts_WPoint[pd->R1].adc);
|
|
398 4 D_LED1_REV();
|
|
399 4 L4_WPoint_out();
|
|
400 4 D_LED1_REV();
|
|
401 4
|
|
402 4 //写入IAP
|
|
403 4 L3_R_2_S();
|
|
404 4 L0_Iap_Program_array(D_EEP_BASE,D_struct2U8(S),D_S_LEN);
|
|
405 4 }
|
|
406 3
|
|
407 3 break;
|
|
408 3
|
|
409 3 case 0x30:
|
|
410 3 /// 清零指令 把当前的重量值作为0点; 可以在pad上配置参数
|
|
411 3 ////Fe 223344556677 21
|
|
412 3 //L4_weight_print();
|
|
413 3 tst_weight.kgx10_zero = tst_weight.kgx10;
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 8
|
|
|
|
414 3 //printf2("\r\n kgx10_zero= %4x(%4d)",tst_weight.kgx10_zero,tst_weight.kgx10_zero);
|
|
415 3
|
|
416 3 D_LED1_REV();
|
|
417 3 L4_kgx10zero_out();
|
|
418 3 D_LED1_REV();
|
|
419 3
|
|
420 3 break;
|
|
421 3
|
|
422 3 case 0x40:
|
|
423 3 ///Fe 11 22 33 44 55 66 23
|
|
424 3 TTSS_run_times(3)
|
|
425 3 {
|
|
426 4 printf5("\r\n%d: %4x(%4d ) %4x(%6d)\r\n",(int)tst_v.i,
|
|
428 4 ts_weight_SPara.ts_WPoint[tst_v.i].kg,ts_weight_SPara.ts_WPoint[tst_v.i].kg,
|
|
428 4 ts_weight_SPara.ts_WPoint[tst_v.i].adc,ts_weight_SPara.ts_WPoint[tst_v.i].adc);
|
|
429 4 }
|
|
430 3 break;
|
|
431 3
|
|
432 3 case 0x50: ///读取当前的重量和传感器数值
|
|
433 3 ///Fe 223344556677 12
|
|
434 3 printfs("\r\n ");
|
|
435 3 L4_weight_print();
|
|
436 3 break;
|
|
437 3
|
|
438 3 default:
|
|
439 3 printfs(" pp error\r\n ");
|
|
440 3 break;
|
|
441 3 };
|
|
442 2 }
|
|
443 1 }
|
|
444 #endif
|
|
445
|
|
446
|
|
447 void L4_weight_print(void)
|
|
448 {
|
|
449 1 L1_uartD_ushex(ts_adc_samples[0].out1_adc);L1_uartD_uc(' ');
|
|
450 1 L1_uartD_ushex(ts_adc_samples[1].out1_adc);L1_uartD_uc(' ');
|
|
451 1 L1_uartD_ushex(ts_adc_samples[2].out1_adc);L1_uartD_uc(' ');
|
|
452 1 L1_uartD_ushex(ts_adc_samples[3].out1_adc);L1_uartD_uc(' ');
|
|
453 1
|
|
454 1 /* L1_uartD_uc('|');L1_uartD_uc(' ');
|
|
455 1 L1_uartD_ushex(ts_adc_samples[0].out2_offset);L1_uartD_uc(' ');////调整偏移量后的值
|
|
456 1 L1_uartD_ushex(ts_adc_samples[1].out2_offset);L1_uartD_uc(' ');
|
|
457 1 L1_uartD_ushex(ts_adc_samples[2].out2_offset);L1_uartD_uc(' ');
|
|
458 1 L1_uartD_ushex(ts_adc_samples[3].out2_offset);L1_uartD_uc(' ');
|
|
459 1
|
|
460 1 L1_uartD_ushex(ts_adc_samples[0].out5);L1_uartD_uc(' ');////调整偏移量后的值
|
|
461 1 L1_uartD_ushex(ts_adc_samples[1].out5);L1_uartD_uc(' ');
|
|
462 1 L1_uartD_ushex(ts_adc_samples[2].out5);L1_uartD_uc(' ');
|
|
463 1 L1_uartD_ushex(ts_adc_samples[3].out5);L1_uartD_uc(' ');
|
|
464 1
|
|
465 1 */
|
|
466 1
|
|
467 1 L1_uartD_uc('|');L1_uartD_uc(' ');
|
|
468 1 L1_uartD_ushex((vU16)tst_weight.adc32); L1_uartD_uc(' ');///参与运算的值
|
|
469 1 printf2(" (%d)%4x ", tst_weight.kgx10,tst_weight.kgx10);
|
|
470 1 printf2("out (%d)%4x\r\n", tst_weight.kgx10_out,tst_weight.kgx10_out);
|
|
471 1 }
|
|
472
|
|
473
|
|
474
|
|
475
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 9
|
|
|
|
476 #if 0
|
|
TS_weight_out_ ts_weight_out;
|
|
void L4_weight_out(void)
|
|
{
|
|
ts_weight_out.fx = 0x55;
|
|
ts_weight_out.sensor_adc[0]=ts_adc_samples[0].out1_adc;
|
|
ts_weight_out.sensor_adc[1]=ts_adc_samples[1].out1_adc;
|
|
ts_weight_out.sensor_adc[2]=ts_adc_samples[2].out1_adc;
|
|
ts_weight_out.sensor_adc[3]=ts_adc_samples[3].out1_adc;
|
|
ts_weight_out.kgx10_out = tst_weight.kgx10_out;
|
|
ts_weight_out.adc32= tst_weight.adc32;////采样值用作校准时使用
|
|
ts_weight_out.ocr =0x33;
|
|
#if 0
|
|
ts_weight_out.num = 17;
|
|
#else
|
|
|
|
ts_weight_out.num = 15;
|
|
#endif
|
|
ts_weight_out.out6= tst_weight.out6;
|
|
L1_uartD_Array((u8 *)&ts_weight_out,ts_weight_out.num);
|
|
|
|
|
|
}
|
|
|
|
#else
|
|
501
|
|
502 TS_weight_out_ ts_weight_out;
|
|
503 void L4_weight_out(void)
|
|
504 {
|
|
505 1 U8 dnum = 12, total = 18;
|
|
506 1 ts_weight_out.filter = 0xAA;
|
|
507 1 ts_weight_out.slaveId = 0x02;
|
|
508 1 ts_weight_out.cmd = 0x10;
|
|
509 1 ts_weight_out.num[0] = (dnum >> 8) & 0xFF;
|
|
510 1 ts_weight_out.num[1] = dnum & 0xFF;
|
|
511 1 ts_weight_out.sensor_adc[0]=ts_adc_samples[0].out1_adc;
|
|
512 1 ts_weight_out.sensor_adc[1]=ts_adc_samples[1].out1_adc;
|
|
513 1 ts_weight_out.sensor_adc[2]=ts_adc_samples[2].out1_adc;
|
|
514 1 ts_weight_out.sensor_adc[3]=ts_adc_samples[3].out1_adc;
|
|
515 1 ts_weight_out.kgx10_out = tst_weight.kgx10_out;
|
|
516 1 ts_weight_out.adc32= tst_weight.adc32;////采样值用作校准时使用
|
|
517 1 ts_weight_out.ocr =0x33;
|
|
518 1 L1_uartD_Array((u8 *)&ts_weight_out,total);
|
|
519 1 }
|
|
520
|
|
521 TS_WPoint_out_ ts_wpoint_out;
|
|
522 void L4_WPoint_out(void)
|
|
523 {
|
|
524 1 U8 dnum = 12, total = 18;
|
|
525 1 ts_wpoint_out.filter = 0xAA;
|
|
526 1 ts_wpoint_out.slaveId = 0x02;
|
|
527 1 ts_wpoint_out.cmd = 0x20;
|
|
528 1 ts_wpoint_out.num[0] = (dnum >> 8) & 0xFF;
|
|
529 1 ts_wpoint_out.num[1] = dnum & 0xFF;
|
|
530 1 Lc_buf_from_const_uc(ts_wpoint_out.wpoint, S.weight_SPara.ts_WPoint , sizeof(S.weight_SPara.ts_WPoint));
|
|
*** WARNING C182 IN LINE 530 OF ..\source\app\app_weight.c: pointer to different objects
|
|
*** WARNING C182 IN LINE 530 OF ..\source\app\app_weight.c: pointer to different objects
|
|
531 1 ts_wpoint_out.ocr =0x33;
|
|
532 1 L1_uartD_Array((u8 *)&ts_wpoint_out,total);
|
|
533 1 }
|
|
534
|
|
535
|
|
C51 COMPILER V9.54 APP_WEIGHT 09/06/2024 14:31:09 PAGE 10
|
|
|
|
536 TS_Kgx10zero_out_ ts_kgx10zero_out;
|
|
537 void L4_kgx10zero_out(void)
|
|
538 {
|
|
539 1 U8 dnum = 2, total = 8;
|
|
540 1 ts_kgx10zero_out.filter = 0xAA;
|
|
541 1 ts_kgx10zero_out.slaveId = 0x02;
|
|
542 1 ts_kgx10zero_out.cmd = 0x30;
|
|
543 1 ts_kgx10zero_out.num[0] = (dnum >> 8) & 0xFF;
|
|
544 1 ts_kgx10zero_out.num[1] = dnum & 0xFF;
|
|
545 1 ts_kgx10zero_out.kgx10zero[0] = tst_weight.kgx10_zero >> 8 & 0xFF;
|
|
546 1 ts_kgx10zero_out.kgx10zero[1] = tst_weight.kgx10_zero >> 0 & 0xFF;
|
|
547 1 ts_kgx10zero_out.ocr =0x33;
|
|
548 1 L1_uartD_Array((u8 *)&ts_kgx10zero_out,total);
|
|
549 1 }
|
|
550
|
|
551 #endif
|
|
552
|
|
553
|
|
|
|
|
|
MODULE INFORMATION: STATIC OVERLAYABLE
|
|
CODE SIZE = 2553 ----
|
|
CONSTANT SIZE = 96 ----
|
|
XDATA SIZE = 123 ----
|
|
PDATA SIZE = ---- ----
|
|
DATA SIZE = ---- ----
|
|
IDATA SIZE = ---- ----
|
|
BIT SIZE = ---- ----
|
|
EDATA SIZE = ---- ----
|
|
HDATA SIZE = ---- ----
|
|
XDATA CONST SIZE = ---- ----
|
|
FAR CONST SIZE = ---- ----
|
|
END OF MODULE INFORMATION.
|
|
|
|
|
|
C51 COMPILATION COMPLETE. 3 WARNING(S), 0 ERROR(S)
|
|
|