This commit is contained in:
sunbeam 2024-06-02 21:12:07 +08:00
parent 0dc7cc42dc
commit bd4a10c25f
3 changed files with 21 additions and 111 deletions

File diff suppressed because one or more lines are too long

View File

@ -127,7 +127,7 @@ void MotorValueInit(void)
MotorHallLoc[i] = 0x8000; MotorHallLoc[i] = 0x8000;
MotorErr[i] = 0; MotorErr[i] = 0;
} }
//ReadMotorMemory(); ReadMotorMemory();
} }
void setMotorState(uint8_t motorid,uint8_t act) void setMotorState(uint8_t motorid,uint8_t act)
@ -187,20 +187,20 @@ void AutoCalCtrl(void)
case AUTOCAL_STOP: case AUTOCAL_STOP:
MotorArr1state = AUTOCAL_STOP; MotorArr1state = AUTOCAL_STOP;
MotorArr2state = AUTOCAL_STOP; MotorArr2state = AUTOCAL_STOP;
MotorArr3state = AUTOCAL_STOP; //MotorArr3state = AUTOCAL_STOP;
return; return;
case AUTOCAL_START: case AUTOCAL_START:
MotorArr1state = 1; MotorArr1state = 1;
MotorArr2state = 1; MotorArr2state = 1;
MotorArr3state = 1; //MotorArr3state = 1;
setMotorState(MOTOR1,ACT_XQ); setMotorState(MOTOR1,ACT_XQ);
setMotorState(MOTOR3,ACT_XQ); setMotorState(MOTOR3,ACT_XQ);
setMotorState(MOTOR5,ACT_XQ); //setMotorState(MOTOR5,ACT_XQ);
autocalcounter[0] = 0; autocalcounter[0] = 0;
autocalcounter[1] = 0; autocalcounter[1] = 0;
autocalcounter[2] = 0; //autocalcounter[2] = 0;
AutoCalState++; AutoCalState++;
for (i = 0; i < 6; i++) for (i = 0; i < 4; i++)
{ {
MotorHardStop1[i] = 0; MotorHardStop1[i] = 0;
MotorHardStop2[i] = 0; MotorHardStop2[i] = 0;
@ -412,96 +412,7 @@ void AutoCalCtrl(void)
default: default:
break; break;
} }
switch (MotorArr3state)
{
case 1://motor5 xq
autocalcounter[2]++;
if (MotorHardStop1[MOTOR5] != 0)
{
MotorArr3state++;
wait3 = 0;
setMotorState(MOTOR5,ACT_NOACT);
}
if (autocalcounter[2] > 3000 || MotorErr[MOTOR5] != 0)
{
MotorArr3state = 4;
wait3 = 0;
setMotorState(MOTOR5,ACT_NOACT);
}
break;
case 2://wait
wait3++;
if (wait3 > 50)
{
MotorArr3state++;
setMotorState(MOTOR5,ACT_XH);
autocalcounter[2] = 0;
}
break;
case 3://motor5 xh
autocalcounter[2]++;
if (MotorHardStop2[MOTOR5] != 0)
{
MotorArr3state++;
wait3 = 0;
setMotorState(MOTOR5,ACT_NOACT);
}
if (autocalcounter[2] > 3000 || MotorErr[MOTOR5] != 0)
{
MotorArr3state = 4;
wait3 = 0;
setMotorState(MOTOR5,ACT_NOACT);
}
break;
case 4://wait
wait3++;
if (wait3 > 50)
{
MotorArr3state++;
setMotorState(MOTOR6,ACT_XQ);
autocalcounter[2] = 0;
}
break;
case 5://motor6 xq
autocalcounter[2]++;
if (MotorHardStop1[MOTOR6] != 0)
{
MotorArr3state++;
wait3 = 0;
setMotorState(MOTOR6,ACT_NOACT);
}
if (autocalcounter[2] > 3000 || MotorErr[MOTOR6] != 0)
{
MotorArr3state = 0;
setMotorState(MOTOR6,ACT_NOACT);
}
break;
case 6://wait
wait3++;
if (wait3 > 50)
{
MotorArr3state++;
setMotorState(MOTOR6,ACT_XH);
autocalcounter[2] = 0;
}
break;
case 7:
autocalcounter[2]++;
if (MotorHardStop2[MOTOR6] != 0)
{
MotorArr3state=0;
wait3 = 0;
setMotorState(MOTOR6,ACT_NOACT);
}
if (autocalcounter[2] > 3000 || MotorErr[MOTOR6] != 0)
{
MotorArr3state = 0;
setMotorState(MOTOR6,ACT_NOACT);
}
break;
default:
break;
}
} }
uint8_t flagMotorMemoryKeyStart,flagMotorMemoryKeyLongPress,flagKEYM1press; uint8_t flagMotorMemoryKeyStart,flagMotorMemoryKeyLongPress,flagKEYM1press;
uint16_t countMotorMemoryKeyStart; uint16_t countMotorMemoryKeyStart;
@ -633,7 +544,7 @@ void MotorMemoryKeyM3Release(void)
void MotorCtrl(void)//10ms void MotorCtrl(void)//10ms
{ {
uint8_t i; uint8_t i;
//WriteMotorMemory(); //TODO WriteMotorMemory(); //TODO
AutoCalCtrl(); AutoCalCtrl();
if (flagMotorMemoryKeyStart == 1) if (flagMotorMemoryKeyStart == 1)
{ {
@ -768,11 +679,11 @@ void CurrentDetecte(void)
static uint16_t OC_Count1=0,OC_Count2=0,OC_Count3 = 0; static uint16_t OC_Count1=0,OC_Count2=0,OC_Count3 = 0;
current1 = getAdval(ADCH_RLY1); current1 = getAdval(ADCH_RLY2);
current2 = getAdval(ADCH_RLY2); current2 = getAdval(ADCH_RLY1);
if (current1 > 80U && OC1flag == 0) if (current1 > 30U && OC1flag == 0)
{ {
OC_Count1++; OC_Count1++;
if (OC_Count1 >= 100) if (OC_Count1 >= 100)
@ -786,7 +697,7 @@ void CurrentDetecte(void)
OC_Count1 = 0; OC_Count1 = 0;
} }
if (current2 > 80U && OC2flag == 0) if (current2 > 30U && OC2flag == 0)
{ {
OC_Count2++; OC_Count2++;
if (OC_Count2 >= 100) if (OC_Count2 >= 100)

View File

@ -41,7 +41,7 @@ MotorStateEE_Type *pEE;
void MotorCtrl(void); void MotorCtrl(void);
void HallDetecte(void); void HallDetecte(void);
void TfJr_CtrlTask(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;
@ -76,7 +76,7 @@ void Apply_task(void)
if (Timer_20ms_flag == 1) if (Timer_20ms_flag == 1)
{ {
Timer_20ms_flag = 0; Timer_20ms_flag = 0;
//R_WDT_Restart(); R_WDT_Restart();
} }
if (Timer_50ms_flag == 1) if (Timer_50ms_flag == 1)
{ {
@ -218,7 +218,7 @@ void EEL_READ(void)
{ {
uint16_t checksum; uint16_t checksum;
uint8_t *src,*des,i; uint8_t *src,*des,i;
//ReadFlashData(EEL_BUF, 0x000F1000, sizeof(MotorStateEE)); ReadFlashData(EEL_BUF, 0x000F1000, sizeof(MotorStateEE));
pEE = (MotorStateEE_Type *)EEL_BUF; pEE = (MotorStateEE_Type *)EEL_BUF;
checksum = pEE->kbsoft1 + pEE->kbsoft2 + pEE->kbnow + pEE->zysoft1 + pEE->zysoft2 + pEE->zynow; checksum = pEE->kbsoft1 + pEE->kbsoft2 + pEE->kbnow + pEE->zysoft1 + pEE->zysoft2 + pEE->zynow;
if (pEE ->start == 0x55AA && pEE->stop == 0xAA55 && checksum == pEE->checksum) if (pEE ->start == 0x55AA && pEE->stop == 0xAA55 && checksum == pEE->checksum)