update T6 with measured distance for ppc_cfg

This commit is contained in:
Yunhorn 2024-12-19 21:10:34 +08:00
parent 67d0a5736a
commit affb23d5b8
6 changed files with 66 additions and 14 deletions

Binary file not shown.

View File

@ -291,7 +291,7 @@ void STS_SENSOR_Function_Test_Process(void);
void STS_SENSOR_Distance_Test_Process(void);
void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_t count);
void STS_PRESENCE_SENSOR_Distance_Measure_Process(void);
void ppc_cfg_parameter_update(void);
/* USER CODE BEGIN Private defines */
/*
In this example TIM2 input clock (TIM2CLK) is set to APB1 clock (PCLK1),

View File

@ -1084,6 +1084,9 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
case 'S': /* "YZS": Self Function Testing */
STS_SENSOR_Function_Test_Process();
#if defined(STS_T6)
ppc_cfg_parameter_update();
#endif
break;
case 'C': /* "YZC": report LORAWAN CLASS A/B/C */
@ -1122,6 +1125,10 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
#endif
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
#if defined(STS_T6)
ppc_cfg_parameter_update();
#endif
break;
case 'M': /* "YZM": Mask level */
i = 0;
@ -1809,8 +1816,12 @@ void STS_SENSOR_Distance_Test_Process(void)
int status=0;
uint16_t range_distance =0;
status = sts_tof_vl53lx_range_distance(&range_distance);
sts_sensor_install_height = range_distance;
APP_LOG(TS_OFF, VLEVEL_M, "\n STS SENSOR INSTALLATION HEIGHT =%d mm\n\r", (uint16_t)sts_sensor_install_height);
if (status ==0)
{
sts_sensor_install_height = range_distance;
APP_LOG(TS_OFF, VLEVEL_M, "\n STS SENSOR INSTALLATION HEIGHT =%d mm\n\r", (uint16_t)sts_sensor_install_height);
}
#endif
#if defined(VL53L0)
@ -1820,7 +1831,23 @@ void STS_SENSOR_Distance_Test_Process(void)
}
void ppc_cfg_parameter_update(void)
{
ppc_cfg[DOOR_JAM_NOW].profile_name = DOOR_JAM_NOW;
ppc_cfg[DOOR_JAM_NOW].distance_array_size = DISTANCES_ARRAY_SIZE;
ppc_cfg[DOOR_JAM_NOW].max_distance = sts_sensor_install_height;
ppc_cfg[DOOR_JAM_NOW].min_distance = MAX(0,(sts_sensor_install_height-1800));
ppc_cfg[DOOR_JAM_NOW].dist_threshold = MAX(500,sts_sensor_install_height - 500);
ppc_cfg[DOOR_JAM_NOW].rows_of_SPADS = ROWS_OF_SPADS;
ppc_cfg[DOOR_JAM_NOW].timing_budget = 100; // TIMING_BUDGET, in ms possible values [15, 20, 33, 50, 100, 200, 500]
ppc_cfg[DOOR_JAM_NOW].distance_mode = 2; /* 1=short, 2=long, DISTANCE_MODE */
ppc_cfg[DOOR_JAM_NOW].front_zone_center = FRONT_ZONE_CENTER;
ppc_cfg[DOOR_JAM_NOW].back_zone_center = BACK_ZONE_CENTER;
sts_door_jam_profile = DOOR_JAM_NOW;
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Door Jam profile updated to %d with Max/Min/Threshold=%d:%d:%d \r\n",
sts_door_jam_profile, ppc_cfg[DOOR_JAM_NOW].max_distance,ppc_cfg[DOOR_JAM_NOW].min_distance, ppc_cfg[DOOR_JAM_NOW].dist_threshold);
}
void STS_SENSOR_MEMS_Get_ID(uint16_t *devID)
{
#ifdef VL53LX
@ -1853,13 +1880,16 @@ void STS_SENSOR_Function_Test_Process(void)
int status=0;
uint16_t range_distance =0;
status = sts_tof_vl53lx_range_distance(&range_distance);
sts_sensor_install_height = range_distance;
APP_LOG(TS_OFF, VLEVEL_M, "\nSensor Install Height =%4d mm\n", sts_sensor_install_height);
tstbuf[i++] = (uint8_t) (4)&0xff; //length of following data
tstbuf[i++] = (uint8_t) (sensor_id>>8)&0xff;
tstbuf[i++] = (uint8_t) (sensor_id)&0xff;
tstbuf[i++] = (uint8_t) (sts_sensor_install_height>>8)&0xff; // MSB of sensor height
tstbuf[i++] = (uint8_t) (sts_sensor_install_height)&0xff; // LSB of sensor height
if (status ==0)
{
sts_sensor_install_height = range_distance;
APP_LOG(TS_OFF, VLEVEL_M, "\nSensor Install Height =%4d mm\n", sts_sensor_install_height);
tstbuf[i++] = (uint8_t) (4)&0xff; //length of following data
tstbuf[i++] = (uint8_t) (sensor_id>>8)&0xff;
tstbuf[i++] = (uint8_t) (sensor_id)&0xff;
tstbuf[i++] = (uint8_t) (sts_sensor_install_height>>8)&0xff; // MSB of sensor height
tstbuf[i++] = (uint8_t) (sts_sensor_install_height)&0xff; // LSB of sensor height
}
}
#endif

View File

@ -28,13 +28,14 @@ extern volatile uint8_t sts_lamp_bar_color;
/* TIMING_BUDGET, in ms possible values [15, 20, 50, 100, 200, 500] */
/* DISTANCE_THRESHOLD = MAX - ASSUME_CHILD_HEIGHT(800mm) */
volatile sts_ppc_cfg_type_t ppc_cfg[6] = {
volatile sts_ppc_cfg_type_t ppc_cfg[10] = {
{DOOR_SIDE_1300,10, 1300,0, 1200,8,33, DISTANCE_MODE_SHORT,175,231},
{DOOR_JAM_1600, 10, 1600,0, 1300,8,33, DISTANCE_MODE_SHORT,175,231},
{DOOR_JAM_2400, 10, 2400,400, 1900,8,50, DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_3000, 10, 3000,1200, 2500,8,100,DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_3500, 10, 3500,1700, 3000,8,100,DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_4000, 10, 4000,2200, 3500,8,200,DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_NOW, 10, 2200, 400, 1800,8,50,DISTANCE_MODE_LONG,175,231},
};
volatile sts_zone_center_by_rows_of_spads_t zone_center[4]={
{4, 151, 247},
@ -658,7 +659,12 @@ void STS_TOF_VL53LX_PresenceDetection_Process_Start(void)
//APP_LOG(TS_OFF, VLEVEL_M,"############### TOF VL53LX_ PRESENCE DETECTION SUB-PROCESS \r\n");
{
status = sts_tof_vl53lx_presence_detection_start();
int status = sts_tof_vl53lx_presence_detection_start();
if (status == -1)
{
sts_tof_vl53lx_presence_detection_init();
return ;
}
if (sts_tof_presence_state ==1)
{
LED_GREEN_OFF;

View File

@ -37,14 +37,23 @@
#define LEFT 0
#define RIGHT 1
#if 0
#define DOOR_SIDE_1300 0
#define DOOR_JAM_1600 1
#define DOOR_JAM_2400 2
#define DOOR_JAM_3000 3
#define DOOR_JAM_3500 4
#define DOOR_JAM_4000 5
#endif
enum door_jam_order {
DOOR_SIDE_1300=0,
DOOR_JAM_1600,
DOOR_JAM_2400,
DOOR_JAM_3000,
DOOR_JAM_3500,
DOOR_JAM_4000,
DOOR_JAM_NOW
};
// define here the profile for your case.
@ -60,6 +69,7 @@
#define tbms_200 200
#define tbms_500 500
#if 0
//PPC_PROFILE DOOR_JAM_2400
#if PPC_PROFILE == DOOR_JAM_2400
#define PROFILE_STRING "DOOR_JAM_2400"
@ -83,6 +93,7 @@
#define TIMING_BUDGET 33 //33 // was 20 ms, I found 33 ms has better succes rate with lower reflectance target
#define DISTANCE_MODE DISTANCE_MODE_LONG
#endif
#endif
#if ROWS_OF_SPADS == 4
#define FRONT_ZONE_CENTER 151
@ -98,6 +109,11 @@
#define BACK_ZONE_CENTER 199
#endif
// assume ROWS_OF_SPADS == 8
#define FRONT_ZONE_CENTER 175 // was 167, see UM2555 on st.com, centre = 175 has better return signal rate for the ROI #1
#define BACK_ZONE_CENTER 231
#define DISTANCES_ARRAY_SIZE 10 // nb of samples
#define ROWS_OF_SPADS 8 // 8x16 SPADs ROI
/* Exported functions --------------------------------------------------------*/
enum distance_mode {
DISTANCE_MODE_SIDE=0,