M26B初版
This commit is contained in:
parent
7caeaa4dcd
commit
6abc8093ac
File diff suppressed because one or more lines are too long
@ -148,7 +148,10 @@ void setMotorState(uint8_t motorid,uint8_t act)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint8_t getMotorState(uint8_t motorid)
|
||||||
|
{
|
||||||
|
return MotorState[motorid];
|
||||||
|
}
|
||||||
void setMotorTarget(uint8_t motorid,uint16_t target)
|
void setMotorTarget(uint8_t motorid,uint16_t target)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -256,7 +259,7 @@ void MotorMemoryKeyM1Release(void)
|
|||||||
if (flagMotorMemoryKeyStart == 1)
|
if (flagMotorMemoryKeyStart == 1)
|
||||||
{
|
{
|
||||||
flagMotorMemoryKeyStart = 0;
|
flagMotorMemoryKeyStart = 0;
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
buzzer_start();
|
buzzer_start();
|
||||||
if (MotorHardStop1[i]!=0 && MotorHardStop2[i]!=0)
|
if (MotorHardStop1[i]!=0 && MotorHardStop2[i]!=0)
|
||||||
@ -269,7 +272,7 @@ void MotorMemoryKeyM1Release(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
setMotorTarget(i,MemoryLoc[0][i]);
|
setMotorTarget(i,MemoryLoc[0][i]);
|
||||||
}
|
}
|
||||||
@ -287,7 +290,7 @@ void MotorMemoryKeyM2Release(void)
|
|||||||
{
|
{
|
||||||
flagMotorMemoryKeyStart = 0;
|
flagMotorMemoryKeyStart = 0;
|
||||||
buzzer_start();
|
buzzer_start();
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (MotorHardStop1[i]!=0 && MotorHardStop2[i]!=0)
|
if (MotorHardStop1[i]!=0 && MotorHardStop2[i]!=0)
|
||||||
{
|
{
|
||||||
@ -299,7 +302,7 @@ void MotorMemoryKeyM2Release(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
setMotorTarget(i,MemoryLoc[1][i]);
|
setMotorTarget(i,MemoryLoc[1][i]);
|
||||||
}
|
}
|
||||||
@ -570,3 +573,22 @@ void HallDetecte(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setJSMomory(void)
|
||||||
|
{
|
||||||
|
buzzer_start();
|
||||||
|
MemoryLoc[0][3] = MotorHallLoc[MOTOR1];
|
||||||
|
MemoryLoc[1][3] = MotorHallLoc[MOTOR2];
|
||||||
|
MemoryLoc[2][3] = MotorHallLoc[MOTOR3];
|
||||||
|
EEL_SAVE_Counter = 1000;
|
||||||
|
EEL_SAVE_REQUIRE_FLAG = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gotoJSLoc(void)
|
||||||
|
{
|
||||||
|
setMotorTarget(MOTOR1,MemoryLoc[0][3]);
|
||||||
|
setMotorTarget(MOTOR2,MemoryLoc[1][3]);
|
||||||
|
setMotorTarget(MOTOR3,MemoryLoc[2][3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ void TP_act(void);
|
|||||||
|
|
||||||
|
|
||||||
void setMotorState(uint8_t motorid,uint8_t act);
|
void setMotorState(uint8_t motorid,uint8_t act);
|
||||||
|
uint8_t getMotorState(uint8_t motorid);
|
||||||
|
|
||||||
|
|
||||||
void MotorMemoryKeyM1Press(void);
|
void MotorMemoryKeyM1Press(void);
|
||||||
void MotorMemoryKeyM1Release(void);
|
void MotorMemoryKeyM1Release(void);
|
||||||
@ -35,4 +37,7 @@ void MotorMemoryKeyM3Release(void);
|
|||||||
void MotorMemoryKeyMMPress(void);
|
void MotorMemoryKeyMMPress(void);
|
||||||
void MotorMemoryKeyMMRelease(void);
|
void MotorMemoryKeyMMRelease(void);
|
||||||
|
|
||||||
|
void setJSMomory(void);
|
||||||
|
void gotoJSLoc(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,11 +40,21 @@ MotorStateEE_Type *pEE;
|
|||||||
|
|
||||||
void MotorCtrl(void);
|
void MotorCtrl(void);
|
||||||
void HallDetecte(void);
|
void HallDetecte(void);
|
||||||
|
void fw_tp_ctrl(void);
|
||||||
|
void js_ctrl(void);
|
||||||
|
|
||||||
extern uint8_t OC1flag,OC2flag,OC3flag;
|
extern uint8_t OC1flag,OC2flag,OC3flag;
|
||||||
uint8_t TfState,JrState;
|
uint8_t TfState,JrState;
|
||||||
unsigned char keybyte1,keybyte2,keybyte3;
|
unsigned char keybyte1,keybyte2,keybyte3;
|
||||||
|
uint8_t fw_tp_pressed,fw_tp_stop;
|
||||||
|
uint16_t fw_tp_cnt;
|
||||||
|
uint8_t js_pressed;
|
||||||
|
uint16_t js_cnt;
|
||||||
|
|
||||||
|
#define PLAN1 0
|
||||||
|
#define PLAN2 1
|
||||||
|
#define M26B_PLAN PLAN1
|
||||||
|
|
||||||
|
|
||||||
void Apply_task(void)
|
void Apply_task(void)
|
||||||
{
|
{
|
||||||
@ -81,7 +91,8 @@ void Apply_task(void)
|
|||||||
if (Timer_50ms_flag == 1)
|
if (Timer_50ms_flag == 1)
|
||||||
{
|
{
|
||||||
Timer_50ms_flag = 0;
|
Timer_50ms_flag = 0;
|
||||||
|
fw_tp_ctrl();
|
||||||
|
js_ctrl();
|
||||||
}
|
}
|
||||||
if (Timer_1000ms_flag == 1)
|
if (Timer_1000ms_flag == 1)
|
||||||
{
|
{
|
||||||
@ -125,12 +136,14 @@ void KeyPressLogic(uint8_t keyid)
|
|||||||
setMotorState(MOTOR3,ACT_XH);
|
setMotorState(MOTOR3,ACT_XH);
|
||||||
break;
|
break;
|
||||||
case KEYID_JS:
|
case KEYID_JS:
|
||||||
|
js_pressed = 1;
|
||||||
//buzzer_start();
|
//buzzer_start();
|
||||||
//TP_act();
|
//TP_act();
|
||||||
break;
|
break;
|
||||||
case KEYID_TP:
|
case KEYID_TP:
|
||||||
//buzzer_start();
|
//buzzer_start();
|
||||||
FW_act();
|
//FW_act();
|
||||||
|
fw_tp_pressed = 1;
|
||||||
break;
|
break;
|
||||||
case KEYID_JY_SET:
|
case KEYID_JY_SET:
|
||||||
MotorMemoryKeyMMPress();
|
MotorMemoryKeyMMPress();
|
||||||
@ -175,9 +188,10 @@ void KeyReleaseLogic(uint8_t keyid)
|
|||||||
setMotorState(MOTOR3,ACT_NOACT);
|
setMotorState(MOTOR3,ACT_NOACT);
|
||||||
break;
|
break;
|
||||||
case KEYID_JS:
|
case KEYID_JS:
|
||||||
|
js_pressed = 0;
|
||||||
break;
|
break;
|
||||||
case KEYID_TP:
|
case KEYID_TP:
|
||||||
|
fw_tp_pressed = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEYID_JY_SET:
|
case KEYID_JY_SET:
|
||||||
@ -207,6 +221,7 @@ void KeyPro(void)
|
|||||||
{
|
{
|
||||||
KeyPressLogic(keyid);
|
KeyPressLogic(keyid);
|
||||||
StopAutoCal();
|
StopAutoCal();
|
||||||
|
fw_tp_stop = 1;
|
||||||
}
|
}
|
||||||
if (getKeyReleaseFlag(keyid))
|
if (getKeyReleaseFlag(keyid))
|
||||||
{
|
{
|
||||||
@ -327,7 +342,161 @@ void Timer_Pro(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FW_TP_STATE_IDLE 0
|
||||||
|
#define FW_TP_STATE_START 1
|
||||||
|
#define FW_TP_STATE_RUNNING 2
|
||||||
|
#define FW_TP_STATE_STOP 3
|
||||||
|
void fw_tp_ctrl(void)//50ms
|
||||||
|
{
|
||||||
|
static uint8_t fw_tp_state,fw_tp_switch;
|
||||||
|
if (fw_tp_pressed)
|
||||||
|
{
|
||||||
|
fw_tp_cnt++;
|
||||||
|
if (fw_tp_cnt >= 100)//5s
|
||||||
|
{
|
||||||
|
fw_tp_cnt = 0;
|
||||||
|
fw_tp_pressed = 0;
|
||||||
|
fw_tp_state = FW_TP_STATE_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fw_tp_cnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (fw_tp_state)
|
||||||
|
{
|
||||||
|
case FW_TP_STATE_IDLE:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case FW_TP_STATE_START:
|
||||||
|
if (fw_tp_switch)
|
||||||
|
{
|
||||||
|
TP_act();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FW_act();
|
||||||
|
}
|
||||||
|
fw_tp_switch = !fw_tp_switch;
|
||||||
|
fw_tp_stop = 0;
|
||||||
|
break;
|
||||||
|
case FW_TP_STATE_RUNNING:
|
||||||
|
if (fw_tp_stop == 1)
|
||||||
|
{
|
||||||
|
fw_tp_state = FW_TP_STATE_STOP;
|
||||||
|
fw_tp_stop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case FW_TP_STATE_STOP:
|
||||||
|
setMotorState(MOTOR1,ACT_NOACT);
|
||||||
|
setMotorState(MOTOR2,ACT_NOACT);
|
||||||
|
setMotorState(MOTOR3,ACT_NOACT);
|
||||||
|
fw_tp_state = FW_TP_STATE_IDLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define JS_STATE_IDLE 0
|
||||||
|
#define JS_STATE_START 1
|
||||||
|
#define JS_STATE_RUNNING 2
|
||||||
|
#define JS_STATE_STOP 3
|
||||||
|
|
||||||
|
void js_ctrl(void)//50ms
|
||||||
|
{
|
||||||
|
static uint8_t js_state=JS_STATE_IDLE;
|
||||||
|
static uint16_t js_running_cnt;
|
||||||
|
switch (js_state)
|
||||||
|
{
|
||||||
|
case JS_STATE_IDLE:
|
||||||
|
if (js_pressed == 1)
|
||||||
|
{
|
||||||
|
if (js_cnt < 0xFFFF)
|
||||||
|
{
|
||||||
|
js_cnt++;
|
||||||
|
}
|
||||||
|
if (js_cnt >= 60)//3s
|
||||||
|
{
|
||||||
|
js_pressed = 0;
|
||||||
|
//todo
|
||||||
|
#if M26B_PLAN == PLAN2
|
||||||
|
setJSMomory();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (js_cnt <= 20 && js_cnt > 0)
|
||||||
|
{
|
||||||
|
js_state = JS_STATE_START;
|
||||||
|
|
||||||
|
//setMotorState(MOTOR4,ACT_XQ);
|
||||||
|
js_running_cnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
js_cnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case JS_STATE_START:
|
||||||
|
#if M26B_PLAN == PLAN1
|
||||||
|
//setMotorState(MOTOR1,ACT_XQ);
|
||||||
|
setMotorState(MOTOR2,ACT_XQ);
|
||||||
|
setMotorState(MOTOR3,ACT_XH);
|
||||||
|
#else
|
||||||
|
gotoJSLoc();
|
||||||
|
#endif
|
||||||
|
js_state = JS_STATE_RUNNING;
|
||||||
|
js_running_cnt = 0;
|
||||||
|
break;
|
||||||
|
case JS_STATE_RUNNING:
|
||||||
|
#if M26B_PLAN == PLAN1
|
||||||
|
if (getMotorState(MOTOR2) == ACT_NOACT)
|
||||||
|
{
|
||||||
|
setMotorState(MOTOR1,ACT_XQ);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
js_running_cnt++;
|
||||||
|
if (js_running_cnt < 40)//2s
|
||||||
|
{
|
||||||
|
MOTOR4Ctrl(ACT_XQ);
|
||||||
|
}
|
||||||
|
else if (js_running_cnt >= 40 && js_running_cnt < 840)//2-42s
|
||||||
|
{
|
||||||
|
MOTOR4Ctrl(ACT_NOACT);
|
||||||
|
}
|
||||||
|
else if (js_running_cnt >= 840 && js_running_cnt < 880)//42-44s
|
||||||
|
{
|
||||||
|
MOTOR4Ctrl(ACT_XH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MOTOR4Ctrl(ACT_NOACT);
|
||||||
|
js_state = JS_STATE_STOP;
|
||||||
|
}
|
||||||
|
if (js_pressed == 1)
|
||||||
|
{
|
||||||
|
js_state = JS_STATE_STOP;
|
||||||
|
setMotorState(MOTOR1,ACT_NOACT);
|
||||||
|
setMotorState(MOTOR2,ACT_NOACT);
|
||||||
|
setMotorState(MOTOR3,ACT_NOACT);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case JS_STATE_STOP:
|
||||||
|
MOTOR4Ctrl(ACT_NOACT);
|
||||||
|
js_state = JS_STATE_IDLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user