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.
584 lines
17 KiB
584 lines
17 KiB
////////////////////////////////////////////////////////////////////////////
|
|
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
|
///-------------------------------------------------------------------------
|
|
/// @file bsp_drv.c
|
|
/// @brief bsp @ driver config
|
|
///-------------------------------------------------------------------------
|
|
/// @version 1.0
|
|
/// @author CC
|
|
/// @date 20180331
|
|
/// @note cc_AS_stc02
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "app_weight.h"
|
|
#include "app_config.h"
|
|
#include "debug_drv.h"
|
|
#include "msp_eeprom.h"
|
|
|
|
#define D_0kg 0
|
|
#define D_20kg 200///0x00c8
|
|
#define D_85kg 850////0x0352
|
|
|
|
/*
|
|
#define D_Rsensor_out_D_0kg 0x18D9
|
|
#define D_Rsensor_out_D_20kg 0x1B8B
|
|
#define D_Rsensor_out_D_85kg 0x244D
|
|
*/
|
|
|
|
#define D_Rsensor_out_D_0kg 0x18D9
|
|
#define D_Rsensor_out_D_20kg 0x1c2c
|
|
#define D_Rsensor_out_D_85kg 0x26f9
|
|
|
|
|
|
|
|
|
|
///#define D_20kg 190
|
|
///cc 2023/04/06--6:41:48 西安方块 传感器 根据传感器调配 程序应该专门数据结构
|
|
|
|
|
|
///cc 2023/04/06--7:50:26 应该是tst_weight.out6的值
|
|
///cc 2023/04/09--8:11:50 adc改为out 因为到了weight这一层 已经不合适用adc,adc的和值 输出out给了weight来做运算
|
|
|
|
TS_weight_SPara_ ts_weight_SPara =
|
|
{
|
|
'W',//0 1 u8 rev1;
|
|
'E',//1 2 u8 rev2;
|
|
D_0kg ,D_Rsensor_out_D_0kg,
|
|
D_20kg,D_Rsensor_out_D_20kg,
|
|
D_85kg,D_Rsensor_out_D_85kg,
|
|
|
|
//2 3 TS_weight_point_ zerows[3]; ///4x3=12 手工清零后的参数, 没有清零或者出错恢复到和出厂设置一样,需要实时保存
|
|
'A',//3 4 u8 rev3;
|
|
' ',//4 5 u8 rev4;
|
|
|
|
};
|
|
TS_TASK_weight_ tst_weight;
|
|
|
|
|
|
#define D_task_WEIGHT_add 12
|
|
#define D_task_WEIGHT_CAL 13
|
|
#define D_task_WEIGHT_get 14
|
|
#define D_task_WEIGHT_zero 15
|
|
///#define D_task_WEIGHT_CAL 124
|
|
|
|
#define D_task_WEIGHT_out 45
|
|
#define D_task_WEIGHT_Sline 11
|
|
#define D_task_WEIGHT_getADC 22
|
|
///#define D_task_WEIGHT_CAL 33
|
|
////#define D_task_WEIGHT_Sline
|
|
|
|
|
|
|
|
void L2_task_weight_init(u8 openclose)
|
|
{
|
|
if(openclose)
|
|
{
|
|
L0_ADS1213_INIT(D_ADS1213_GAIN_128);
|
|
L2_task_adc_init(0);
|
|
L2_task_adc_init(1);
|
|
L2_task_adc_init(2);
|
|
L2_task_adc_init(3);
|
|
|
|
}else
|
|
{
|
|
tst_weight.pSPara = &ts_weight_SPara;
|
|
}
|
|
/*
|
|
L2_task_adc_SAinit(0,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
L2_task_adc_SAinit(1,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
L2_task_adc_SAinit(2,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
L2_task_adc_SAinit(3,&S.sd.ADC_shiftaverage_a,&S.sd.ADC_shiftaverage_b);
|
|
|
|
|
|
|
|
|
|
ts_adc_samples[0].offset = S.sd.offset[0];
|
|
ts_adc_samples[1].offset = S.sd.offset[1];
|
|
ts_adc_samples[2].offset = S.sd.offset[2];
|
|
ts_adc_samples[3].offset = S.sd.offset[3];
|
|
|
|
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
void L3_task_weight_init(void)
|
|
{
|
|
//显示任务初始化
|
|
L1_task_reg_clear(&tst_weight.task);
|
|
L3_task_s_go(tst_weight,D_task_init);
|
|
L2_task_weight_init(1);
|
|
///Lc_buf_from_const_uc(U8 * d, const U8 * s, U16 num)
|
|
///tst_weight.pSPara->ts_WPoint
|
|
}
|
|
|
|
#define D_debug_ch D_Wch2
|
|
///L3_task_weight_handler(&tst_weight);
|
|
void L3_task_weight_handler(TS_TASK_weight_ *s)
|
|
{
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch1]);
|
|
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch2]);
|
|
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch3]);
|
|
|
|
L2_task_adc_sample(&ts_adc_samples[D_Wch4]);
|
|
|
|
TTSS_Task_init():
|
|
L0_waitFree_uartN(0);
|
|
s->slow = 0;
|
|
s->zero = 0;
|
|
s->kgx10_zero = 0;
|
|
printfs(" L3_task_weight_handler ");
|
|
L2_task_go(D_task_WEIGHT_get);
|
|
|
|
TTSS_Task_step(D_task_WEIGHT_get):
|
|
if(1 == ts_adc_samples[D_Wch4].ok)
|
|
{
|
|
ts_adc_samples[0].ok = 0;
|
|
ts_adc_samples[1].ok = 0;
|
|
ts_adc_samples[2].ok = 0;
|
|
ts_adc_samples[3].ok = 0;
|
|
s->slow ++;
|
|
L2_task_go(D_task_WEIGHT_Sline);
|
|
}
|
|
|
|
TTSS_Task_step(D_task_WEIGHT_Sline):
|
|
if (s->slow >= 1)////采样减速
|
|
{s->slow = 0;
|
|
///调用asp——adc中的输出 out3
|
|
/************/
|
|
///cc 2023/04/06--8:9:18 选择使用哪一条滤波线
|
|
ts_adc_samples[0].out5 = ts_adc_samples[0].ts_SAa.out4_shift;
|
|
ts_adc_samples[1].out5 = ts_adc_samples[1].ts_SAa.out4_shift;
|
|
ts_adc_samples[2].out5 = ts_adc_samples[2].ts_SAa.out4_shift;
|
|
ts_adc_samples[3].out5 = ts_adc_samples[3].ts_SAa.out4_shift;
|
|
|
|
L2_task_go(D_task_WEIGHT_getADC);
|
|
}else
|
|
{
|
|
L2_task_go(D_task_WEIGHT_get);
|
|
}
|
|
//L2_task_go(D_task_WEIGHT_getADC);
|
|
|
|
TTSS_Task_step(D_task_WEIGHT_getADC):
|
|
////四个传感器相加后平均
|
|
tst_weight.sum32 = ts_adc_samples[0].out5;
|
|
tst_weight.sum32 += ts_adc_samples[1].out5;
|
|
tst_weight.sum32 += ts_adc_samples[2].out5;
|
|
tst_weight.sum32 += ts_adc_samples[3].out5;
|
|
|
|
// L0_uart1_str("ts_adc_samples[0].out5: ");
|
|
// L0_uart1_ushex(ts_adc_samples[0].out5);
|
|
// L0_uart1_0d0a();
|
|
// L0_uart1_str("ts_adc_samples[1].out5: ");
|
|
// L0_uart1_ushex(ts_adc_samples[1].out5);
|
|
// L0_uart1_0d0a();
|
|
// L0_uart1_str("ts_adc_samples[2].out5: ");
|
|
// L0_uart1_ushex(ts_adc_samples[2].out5);
|
|
// L0_uart1_0d0a();
|
|
// L0_uart1_str("ts_adc_samples[3].out5: ");
|
|
// L0_uart1_ushex(ts_adc_samples[3].out5);
|
|
// L0_uart1_0d0a();
|
|
// L0_uart1_str("tst_weight.sum32: ");
|
|
// L0_uart1_ushex(tst_weight.sum32);
|
|
// L0_uart1_0d0a();
|
|
|
|
tst_weight.out6 = tst_weight.sum32 >> 2;
|
|
|
|
// L0_uart1_str("tst_weight.sum32 >> 2: ");
|
|
// L0_uart1_ushex(tst_weight.out6);
|
|
// L0_uart1_0d0a();
|
|
|
|
L2_task_go(D_task_WEIGHT_CAL);
|
|
|
|
TTSS_Task_step(D_task_WEIGHT_CAL):
|
|
tst_weight.adc32 = tst_weight.out6;
|
|
|
|
// L0_uart1_ushex(tst_weight.adc32);
|
|
// L0_uart1_0d0a();
|
|
|
|
L3_task_weight_cal();
|
|
|
|
// L1_uart1_uc('u');
|
|
// L0_uart1_0d0a();
|
|
// L0_uart1_ushex(tst_weight.adc32);
|
|
// L0_uart1_0d0a();
|
|
|
|
L2_task_go(D_task_WEIGHT_out);
|
|
|
|
TTSS_Task_step(D_task_WEIGHT_out):
|
|
if(tst_weight.kgx10 > tst_weight.kgx10_zero)
|
|
{
|
|
s->kgx10_out = s->kgx10 - s->kgx10_zero;
|
|
}else
|
|
{
|
|
s->kgx10_out = 0 ;
|
|
}
|
|
// L4_weight_print();///需要调试的时候打开!!!!!!!!!!!!!!!
|
|
L2_task_Tdelay_go(D_Tdelay_200ms, D_task_WEIGHT_get);
|
|
/// L2_task_go(D_task_WEIGHT_get);
|
|
|
|
TTSS_Task_step(D_task_WEIGHT_zero):
|
|
L2_task_go(D_task_WEIGHT_get);
|
|
|
|
TTSS_Task_end();
|
|
}
|
|
|
|
|
|
void L3_task_weight_cal(void)
|
|
{
|
|
if(tst_weight.adc32 <= (vU32)S.weight_SPara.ts_WPoint[1].adc)
|
|
{
|
|
if(tst_weight.adc32 <= (vU32)S.weight_SPara.ts_WPoint[0].adc )
|
|
{
|
|
tst_weight.adc32 = (vU32)S.weight_SPara.ts_WPoint[0].adc;
|
|
}
|
|
///0-0-40KG
|
|
tst_weight.t32a = (tst_weight.adc32-(vU32)S.weight_SPara.ts_WPoint[0].adc);////有可能<0
|
|
tst_weight.t32b = (vU32)(S.weight_SPara.ts_WPoint[1].adc-S.weight_SPara.ts_WPoint[0].adc);
|
|
tst_weight.t32a *= (vU32)(S.weight_SPara.ts_WPoint[1].kg - S.weight_SPara.ts_WPoint[0].kg);
|
|
tst_weight.t32a /= tst_weight.t32b;
|
|
|
|
}
|
|
else
|
|
{ ///40KG 80KG
|
|
tst_weight.t32a = (vU32)(tst_weight.adc32-S.weight_SPara.ts_WPoint[1].adc);////有可能大于b
|
|
tst_weight.t32b = (vU32)(S.weight_SPara.ts_WPoint[2].adc-S.weight_SPara.ts_WPoint[1].adc);
|
|
tst_weight.t32a *= (vU32)(S.weight_SPara.ts_WPoint[2].kg-S.weight_SPara.ts_WPoint[1].kg) ;
|
|
tst_weight.t32a /= tst_weight.t32b;
|
|
tst_weight.t32a += (vU32)S.weight_SPara.ts_WPoint[1].kg;
|
|
|
|
}
|
|
tst_weight.kgx10 = (vU16)tst_weight.t32a;
|
|
}
|
|
|
|
/*
|
|
|
|
#define D_0kg 0
|
|
#define D_20kg 200///0x00c8
|
|
#define D_85kg 850////0x0352
|
|
|
|
#define D_Rsensor_out_D_0kg 0x18D9
|
|
#define D_Rsensor_out_D_20kg 0x1B8B
|
|
#define D_Rsensor_out_D_85kg 0x244D
|
|
|
|
*/
|
|
|
|
#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参数来
|
|
///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");
|
|
}
|
|
}
|
|
|
|
#else
|
|
void L3_weight_ONdebug(u8 filter)//// ON listen function
|
|
{
|
|
// printf(" \r\n0->filter=%X ", (int)filter);
|
|
// printf(" \r\n1->filter=%X slaveId=%X cmd=%X len = %d ", (int)pd485->filter,(int)pd485->slaveId, (int)pd485->cmd, (int)ts_Urec[D_UART1].num);
|
|
// D_LED2_REV();
|
|
|
|
// AA 02 10 00 02 A3 B4 33 查询
|
|
// AA 02 20 00 03 00 00 00 6C 校准第0个点 00kg
|
|
// AA 02 20 00 03 01 00 64 6C 校准第1个点 20kg
|
|
// AA 02 20 00 03 02 02 BC 6C 校准第2个点 40kg
|
|
// AA 02 30 00 00 33 清零
|
|
if(filter == pd485->filter)
|
|
{
|
|
// L1_uartD_Arrayhex((u8*)pd,9);
|
|
switch (pd485->cmd)
|
|
{
|
|
case 0x10:
|
|
////读取称重
|
|
D_LED1_REV();
|
|
L4_weight_out();
|
|
D_LED1_REV();
|
|
break;
|
|
|
|
case 0x20:
|
|
///// 校准
|
|
////选择一个砝码,发送0x12指令,然后读取的数据 和砝码的重量使用 20 21 22参数来
|
|
///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
|
|
|
|
//AA 02 20 00 03 pIndex kgx10_0 kgx10_1 ocr 对pIndex(0/1/2)点进行校准,校准值为kgx10
|
|
if(pd485->buf[0] < 3)
|
|
{
|
|
ts_weight_SPara.ts_WPoint[pd485->buf[0]].kg = D_2uc_u16(pd485->buf[1],pd485->buf[2]);
|
|
ts_weight_SPara.ts_WPoint[pd485->buf[0]].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);
|
|
D_LED1_REV();
|
|
L4_WPoint_out();
|
|
D_LED1_REV();
|
|
|
|
//写入IAP
|
|
L3_R_2_S();
|
|
L0_Iap_Program_array(D_EEP_BASE,D_struct2U8(S),D_S_LEN);
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x30:
|
|
/// 清零指令 把当前的重量值作为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);
|
|
|
|
D_LED1_REV();
|
|
L4_kgx10zero_out();
|
|
D_LED1_REV();
|
|
|
|
break;
|
|
|
|
case 0x40:
|
|
///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 0x50: ///读取当前的重量和传感器数值
|
|
///Fe 223344556677 12
|
|
printfs("\r\n ");
|
|
L4_weight_print();
|
|
break;
|
|
|
|
default:
|
|
printfs(" pp error\r\n ");
|
|
break;
|
|
};
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
void L4_weight_print(void)
|
|
{
|
|
L1_uartD_ushex(ts_adc_samples[0].out1_adc);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[1].out1_adc);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[2].out1_adc);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[3].out1_adc);L1_uartD_uc(' ');
|
|
|
|
/* L1_uartD_uc('|');L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[0].out2_offset);L1_uartD_uc(' ');////调整偏移量后的值
|
|
L1_uartD_ushex(ts_adc_samples[1].out2_offset);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[2].out2_offset);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[3].out2_offset);L1_uartD_uc(' ');
|
|
|
|
L1_uartD_ushex(ts_adc_samples[0].out5);L1_uartD_uc(' ');////调整偏移量后的值
|
|
L1_uartD_ushex(ts_adc_samples[1].out5);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[2].out5);L1_uartD_uc(' ');
|
|
L1_uartD_ushex(ts_adc_samples[3].out5);L1_uartD_uc(' ');
|
|
|
|
*/
|
|
|
|
L1_uartD_uc('|');L1_uartD_uc(' ');
|
|
L1_uartD_ushex((vU16)tst_weight.adc32); L1_uartD_uc(' ');///参与运算的值
|
|
printf2(" (%d)%4x ", tst_weight.kgx10,tst_weight.kgx10);
|
|
printf2("out (%d)%4x\r\n", tst_weight.kgx10_out,tst_weight.kgx10_out);
|
|
}
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
TS_weight_out_ ts_weight_out;
|
|
void L4_weight_out(void)
|
|
{
|
|
U8 dnum = 12, total = 18;
|
|
ts_weight_out.filter = 0xAA;
|
|
ts_weight_out.slaveId = 0x02;
|
|
ts_weight_out.cmd = 0x10;
|
|
ts_weight_out.num[0] = (dnum >> 8) & 0xFF;
|
|
ts_weight_out.num[1] = dnum & 0xFF;
|
|
|
|
// L0_uart1_0d0a();
|
|
// L0_uart1_str("ts_adc_samples[0].out1_adc: ");
|
|
// L0_uart1_ushex(ts_adc_samples[0].out1_adc);
|
|
// ts_weight_out.sensor_adc[0]=0x1234;
|
|
|
|
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;//采样值用作校准时使用
|
|
|
|
// L0_uart1_us(ts_weight_out.adc32);
|
|
|
|
// ts_weight_out.adc32= 0x1234;////采样值用作校准时使用
|
|
ts_weight_out.ocr =0x33;
|
|
L1_uartD_Array((u8 *)&ts_weight_out,total);
|
|
}
|
|
|
|
TS_WPoint_out_ ts_wpoint_out;
|
|
void L4_WPoint_out(void)
|
|
{
|
|
U8 dnum = 12, total = 18;
|
|
ts_wpoint_out.filter = 0xAA;
|
|
ts_wpoint_out.slaveId = 0x02;
|
|
ts_wpoint_out.cmd = 0x20;
|
|
ts_wpoint_out.num[0] = (dnum >> 8) & 0xFF;
|
|
ts_wpoint_out.num[1] = dnum & 0xFF;
|
|
Lc_buf_from_const_uc(ts_wpoint_out.wpoint, S.weight_SPara.ts_WPoint , sizeof(S.weight_SPara.ts_WPoint));
|
|
ts_wpoint_out.ocr =0x33;
|
|
L1_uartD_Array((u8 *)&ts_wpoint_out,total);
|
|
}
|
|
|
|
|
|
TS_Kgx10zero_out_ ts_kgx10zero_out;
|
|
void L4_kgx10zero_out(void)
|
|
{
|
|
U8 dnum = 2, total = 8;
|
|
ts_kgx10zero_out.filter = 0xAA;
|
|
ts_kgx10zero_out.slaveId = 0x02;
|
|
ts_kgx10zero_out.cmd = 0x30;
|
|
ts_kgx10zero_out.num[0] = (dnum >> 8) & 0xFF;
|
|
ts_kgx10zero_out.num[1] = dnum & 0xFF;
|
|
ts_kgx10zero_out.kgx10zero[0] = tst_weight.kgx10_zero >> 8 & 0xFF;
|
|
ts_kgx10zero_out.kgx10zero[1] = tst_weight.kgx10_zero >> 0 & 0xFF;
|
|
ts_kgx10zero_out.ocr =0x33;
|
|
L1_uartD_Array((u8 *)&ts_kgx10zero_out,total);
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|