gestione ciclo

This commit is contained in:
andrea
2026-04-14 11:52:48 +02:00
parent a300a1f44d
commit e2accf6ffa
102 changed files with 359942 additions and 48904 deletions

View File

@@ -135,3 +135,110 @@ void SetMot(uint8_t mot,uint8_t dir,uint16_t pwmval){
}
}
void SetMotPerc(uint8_t mot,uint8_t dir,uint8_t perc){
uint16_t pwmval;
uint32_t tempval;
tempval=perc;
tempval*=16384;
tempval/=100;
pwmval=(uint16_t)tempval;
switch(mot){
case 1:
if(dir==FW){
if(pwmval==0){
StopMot(timMot1,FWMot1);
HAL_GPIO_WritePin(INH1_GPIO_Port, INH1_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot1, FWMot1)){
SetMotPwm(timMot1,FWMot1,pwmval);
}else{
HAL_GPIO_WritePin(INH1_GPIO_Port, INH1_Pin, GPIO_PIN_SET);
StartMot(timMot1,FWMot1,pwmval);
}
}else{
if(pwmval==0){
StopMot(timMot1,BWMot1);
HAL_GPIO_WritePin(INH1_GPIO_Port, INH1_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot1, BWMot1)){
SetMotPwm(timMot1,BWMot1,pwmval);
}else{
HAL_GPIO_WritePin(INH1_GPIO_Port, INH1_Pin, GPIO_PIN_SET);
StartMot(timMot1,BWMot1,pwmval);
}
}
break;
case 2:
if(dir==FW){
if(pwmval==0){
StopMot(timMot2,FWMot2);
HAL_GPIO_WritePin(INH2_GPIO_Port, INH2_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot2, FWMot2)){
SetMotPwm(timMot2,FWMot2,pwmval);
}else{
HAL_GPIO_WritePin(INH2_GPIO_Port, INH2_Pin, GPIO_PIN_SET);
StartMot(timMot2,FWMot2,pwmval);
}
}else{
if(pwmval==0){
StopMot(timMot2,BWMot2);
HAL_GPIO_WritePin(INH2_GPIO_Port, INH2_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot2, BWMot2)){
SetMotPwm(timMot2,BWMot2,pwmval);
}else{
HAL_GPIO_WritePin(INH2_GPIO_Port, INH2_Pin, GPIO_PIN_SET);
StartMot(timMot2,BWMot2,pwmval);
}
}
break;
case 3:
if(dir==FW){
if(pwmval==0){
StopMot(timMot3,FWMot3);
HAL_GPIO_WritePin(INH3_GPIO_Port, INH3_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot3, FWMot3)){
SetMotPwm(timMot3,FWMot3,pwmval);
}else{
HAL_GPIO_WritePin(INH3_GPIO_Port, INH3_Pin, GPIO_PIN_SET);
StartMot(timMot3,FWMot3,pwmval);
}
}else{
if(pwmval==0){
StopMot(timMot3,BWMot3);
HAL_GPIO_WritePin(INH3_GPIO_Port, INH3_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot3, BWMot3)){
SetMotPwm(timMot3,BWMot3,pwmval);
}else{
HAL_GPIO_WritePin(INH3_GPIO_Port, INH3_Pin, GPIO_PIN_SET);
StartMot(timMot3,BWMot3,pwmval);
}
}
break;
case 4:
if(dir==FW){
if(pwmval==0){
StopMot(timMot4,FWMot4);
HAL_GPIO_WritePin(INH4_GPIO_Port, INH4_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot4, FWMot4)){
SetMotPwm(timMot4,FWMot4,pwmval);
}else{
HAL_GPIO_WritePin(INH4_GPIO_Port, INH4_Pin, GPIO_PIN_SET);
StartMot(timMot4,FWMot4,pwmval);
}
}else{
if(pwmval==0){
StopMot(timMot4,BWMot4);
HAL_GPIO_WritePin(INH4_GPIO_Port, INH4_Pin, GPIO_PIN_RESET);
}else if(IsPwmRunning(timMot4, BWMot4)){
SetMotPwm(timMot4,BWMot4,pwmval);
}else{
HAL_GPIO_WritePin(INH4_GPIO_Port, INH4_Pin, GPIO_PIN_SET);
StartMot(timMot4,BWMot4,pwmval);
}
}
break;
default:
break;
}
}