电机下压
This commit is contained in:
@@ -115,6 +115,7 @@
|
||||
赋码仪读写参数命令添加读写位,解决写参数时少偏移了一位导致的写参数失败的问题
|
||||
2023.6.20
|
||||
赋码失败返回时返回小板的错误码
|
||||
|
||||
2023.6.25
|
||||
电机下压
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-06-20 17:40:53"
|
||||
#define BUILD_DATE "2023-06-25 17:31:20"
|
||||
#define SOFT_VERSION "0.01"
|
||||
|
||||
|
||||
|
@@ -78,7 +78,7 @@ sig_thread thread_creat(int pro)
|
||||
slot_run_def *run=calloc(1,sizeof(slot_run_def));
|
||||
run->run=1;
|
||||
sprintf(name,"sig_mq#%d",count);
|
||||
run->mb=rt_mq_create(name,(sizeof(slot_msg_def)+sizeof(uint32_t)*8),50,RT_IPC_FLAG_FIFO);
|
||||
run->mb=rt_mq_create(name,(sizeof(slot_msg_def)+sizeof(uint32_t)*8),100,RT_IPC_FLAG_FIFO);
|
||||
sprintf(name,"sig_t#%d",count);
|
||||
rt_thread_t rt_t=rt_thread_create(name,slot_run,run,2048,pro,20);
|
||||
rt_thread_startup(rt_t);
|
||||
|
@@ -24,6 +24,8 @@ typedef struct{
|
||||
int count;
|
||||
int max_count;
|
||||
moter_stat stat;
|
||||
void (*fun_in_end)(void *t);
|
||||
void *t;
|
||||
}self_def;
|
||||
|
||||
|
||||
@@ -73,12 +75,42 @@ static void moter_run(void *t)
|
||||
s->stat=STOP;
|
||||
DBG_LOG("moter stoped.");
|
||||
emit moter_end_signal(s);
|
||||
if(s->fun_in_end){
|
||||
s->fun_in_end(s->t);
|
||||
s->fun_in_end=0;
|
||||
s->t=0;
|
||||
}
|
||||
}
|
||||
ev=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD>
|
||||
void moter_down(void (*fun)(void *t),void *t)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
if(fun){
|
||||
s->fun_in_end=fun;
|
||||
s->t=t;
|
||||
}
|
||||
moter_start(0,MOTER_MAX_COUNT-s->count);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD>
|
||||
void moter_up(void (*fun)(void *t),void *t)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
if(fun){
|
||||
s->fun_in_end=fun;
|
||||
s->t=t;
|
||||
}
|
||||
moter_start(0,-s->count-100);
|
||||
}
|
||||
|
||||
|
||||
void moter_start(int fre,int step_count)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
@@ -101,6 +133,7 @@ void moter_start_slot(void *t,int fre,int step_count)
|
||||
if(s->count+step_count>s->max_count)
|
||||
{
|
||||
DBG_WARN("steps count exceeded limit!,max=%d",s->max_count);
|
||||
end_irq(s);
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
|
@@ -16,6 +16,9 @@ void moter_start_slot(void *t,int fre,int step_count);
|
||||
|
||||
void moter_start(int fre,int step_count);
|
||||
|
||||
void moter_down(void (*fun)(void *t),void *t);
|
||||
|
||||
void moter_up(void (*fun)(void *t),void *t);
|
||||
|
||||
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include "handle_for_checker.h"
|
||||
#include "compiler_info.h"
|
||||
#include "dev_backup.h"
|
||||
#include "moter.h"
|
||||
|
||||
|
||||
|
||||
@@ -81,10 +82,29 @@ static void check_end(ucport_def *u,port_mcu *src,void *data,int ack,char *err_s
|
||||
arr_append(a,0);
|
||||
arr_appends(a,w->ack,w->ack_size);
|
||||
emit tran_send_signal(w->u.p,0x31,arr_temp(a));
|
||||
// 把命令字改为0x31用于接收主机应答
|
||||
w->u.cmd=0x31;
|
||||
tran_set_busy(w->u.p,0);
|
||||
}
|
||||
}
|
||||
|
||||
// 电机上升之后解除忙状态
|
||||
static void check_when_moter_up(void *t)
|
||||
{
|
||||
ucport_def *u=t;
|
||||
tran_set_busy(u->p,0);
|
||||
}
|
||||
|
||||
|
||||
static int check_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
|
||||
{
|
||||
if(cmd==0x31)
|
||||
{
|
||||
moter_up(check_when_moter_up,u);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void check_del(ucport_def *u)
|
||||
{
|
||||
@@ -92,6 +112,23 @@ static void check_del(ucport_def *u)
|
||||
}
|
||||
|
||||
|
||||
// 电机下降之后开始检测
|
||||
static void check_when_moter_down(void *t)
|
||||
{
|
||||
ucport_def *u=t;
|
||||
for(int i=0;i<20;i++)
|
||||
{
|
||||
port_mcu *mcu=tran_get_portm(u->p,i);
|
||||
// 这里打开检测
|
||||
if(mcu){
|
||||
port_start(mcu,check_creat(check_scheme()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static ucport_def *check(tran_def *t, uint8_t cmd,array_def *data)
|
||||
{
|
||||
int return_size=(check_scheme()->range_num*2+8+(check_scheme()->range_num+7)/8);
|
||||
@@ -100,18 +137,11 @@ static ucport_def *check(tran_def *t, uint8_t cmd,array_def *data)
|
||||
u->ack_size=return_size*20;
|
||||
u->u.p=t;
|
||||
u->u.del=check_del;
|
||||
u->u.dolater=check_dolater;
|
||||
u->u.doend=check_end;
|
||||
DBG_LOG("check: skip=%d",u->ret_skip);
|
||||
tran_set_busy(t,1);
|
||||
for(int i=0;i<20;i++)
|
||||
{
|
||||
port_mcu *mcu=tran_get_portm(u->u.p,i);
|
||||
// 这里打开检测
|
||||
if(mcu){
|
||||
port_start(mcu,check_creat(check_scheme()));
|
||||
}
|
||||
}
|
||||
|
||||
moter_down(check_when_moter_down,u);
|
||||
array_def *a=arr_creat();
|
||||
arr_append(a,0);
|
||||
emit tran_reply_signal(u->u.p,arr_temp(a));
|
||||
|
Reference in New Issue
Block a user