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.
169 lines
2.9 KiB
169 lines
2.9 KiB
/*
|
|
* paint_gun_action.c
|
|
*
|
|
* Created on: 2025年8月7日
|
|
* Author: xsq
|
|
*/
|
|
#include "paint_gun_action.h"
|
|
#include "Handset_Status_Setting.h"
|
|
#include "msp_strain_gauge.h"
|
|
|
|
#include "fsm_state.h"
|
|
#include "BHBF_ROBOT.h"
|
|
transition_t current_paintgun_state; /*transition_t 成员是 指针的 transition_state_t */
|
|
|
|
transition_state_t paintgun_on_state={PaintGun_ON_Enter,PaintGun_ON_Do,NULL}; /* State 成员,它会被默认初始化为 0 */
|
|
transition_state_t paintgun_off_state={PaintGun_OFF_Enter,PaintGun_OFF_Do,NULL};
|
|
|
|
char Paint_Gun_ButtonReset_Flag = 0; //喷枪开启 1yes
|
|
|
|
/* 喷枪控制 */
|
|
void PaintGun_ON_Do()
|
|
{
|
|
GF_BSP_GPIO_SetIO(PaintGun_IO_CTL, K_ON_PaintGun);//0开
|
|
}
|
|
|
|
void PaintGun_OFF_Do()
|
|
{
|
|
GF_BSP_GPIO_SetIO(PaintGun_IO_CTL, K_OFF_PaintGun);//1关
|
|
}
|
|
|
|
void PaintGun_ON_Enter()
|
|
{
|
|
|
|
}
|
|
void PaintGun_ON_Exit()
|
|
{
|
|
|
|
}
|
|
void PaintGun_OFF_Enter()
|
|
{
|
|
|
|
|
|
}
|
|
void PaintGun_OFF_Exit()
|
|
{
|
|
|
|
}
|
|
|
|
IO_State curr_io_state;
|
|
//手动控制下控制推杆函数
|
|
void PaintGun_Contronl()
|
|
{
|
|
GV.Now_press=strainGaugeValue->Pressure;
|
|
curr_io_state = GetIOState();
|
|
if(GV.PV.Robot_Press_Set==0) //不受任何限制控制推杆
|
|
{
|
|
if(curr_io_state==IO_STATE_RISE)
|
|
{
|
|
strainGaugeValue->MotorControl=1;
|
|
|
|
}
|
|
else if(curr_io_state==IO_STATE_DESCEND)
|
|
{
|
|
strainGaugeValue->MotorControl=2;
|
|
}
|
|
else
|
|
{
|
|
strainGaugeValue->MotorControl=0;
|
|
}
|
|
}
|
|
else //受到限制控制推杆
|
|
{
|
|
if(GV.Now_press>6000) //若压力太大则强制抬起
|
|
{
|
|
strainGaugeValue->MotorControl=1;
|
|
}
|
|
else if(curr_io_state==IO_STATE_RISE) //上升
|
|
{
|
|
strainGaugeValue->MotorControl=1;
|
|
|
|
}
|
|
else if(curr_io_state==IO_STATE_DESCEND) //下降
|
|
{
|
|
if(strainGaugeValue->Pressure<=(GV.PV.Robot_Press_Set*10))
|
|
{
|
|
strainGaugeValue->MotorControl=2;
|
|
}
|
|
else
|
|
{
|
|
strainGaugeValue->MotorControl=0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strainGaugeValue->MotorControl=0;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//自动作业状态下控制推杆函数
|
|
void PaintGun_Contronl_Press()
|
|
{
|
|
GV.Now_press=strainGaugeValue->Pressure;
|
|
curr_io_state = GetIOState();
|
|
if(curr_io_state==IO_STATE_RISE||(GV.Now_press>6000))
|
|
{
|
|
strainGaugeValue->MotorControl=1;
|
|
}
|
|
else if(curr_io_state==IO_STATE_DESCEND)
|
|
{
|
|
|
|
if(strainGaugeValue->Pressure<=(GV.PV.Robot_Press_Set*10))
|
|
{
|
|
strainGaugeValue->MotorControl=2;
|
|
}
|
|
else
|
|
{
|
|
strainGaugeValue->MotorControl=0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strainGaugeValue->MotorControl=0;
|
|
}
|
|
}
|
|
|
|
|
|
int autoing_flag=0;
|
|
int auto_count=0;
|
|
int up_down=1;
|
|
int auto_time=0;
|
|
void tuigan_auto()
|
|
{
|
|
if(autoing_flag==0) //筛选时间
|
|
{
|
|
auto_time=(rand() % 6 + 1)*1000;
|
|
autoing_flag=1;
|
|
if(up_down==1)
|
|
{
|
|
up_down=2;
|
|
}
|
|
else if(up_down==2)
|
|
{
|
|
up_down=1;
|
|
}
|
|
}
|
|
else if(autoing_flag==1) //执行推杆运动
|
|
{
|
|
if(P_MK32->CH11_RD1>0)
|
|
{
|
|
auto_count=auto_count+2;
|
|
if(up_down==1)
|
|
{
|
|
strainGaugeValue->MotorControl=1;
|
|
}
|
|
else if(up_down==2)
|
|
{
|
|
strainGaugeValue->MotorControl=2;
|
|
}
|
|
|
|
if(auto_count>auto_time)
|
|
{
|
|
auto_count=0;
|
|
autoing_flag=0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|