add: probe motor control PWM

This commit is contained in:
Alexander Kurmis
2023-03-14 20:17:26 +03:00
parent 3803869521
commit 7c6e6a49e5
3 changed files with 36 additions and 26 deletions

View File

@@ -12,6 +12,7 @@
#define BOARD_DESC_LEN (23)
extern TIM_HandleTypeDef htim3;
static const char board_description[BOARD_DESC_LEN] = "RS485 Relay Module v1";
extern uint16_t tranfer_errors_count;
extern uint16_t last_rx_time;
@@ -56,17 +57,9 @@ void loop_iterate()
REL_AUX_OFF;
LED_AUX_OFF;
}
/*
if(motor_pwm>MOTOR_MAX)motor_pwm=MOTOR_MAX;
if(motor_pwm<MOTOR_MIN)motor_pwm=MOTOR_MIN;
if(motor_pwm==0)
//TCCR1A&=~(1<<COM1B1);
else
{
//MOTOR_PWM = motor_pwm;
//TCCR1A|=(1<<COM1B1);
}
*/
/* */
modbus_loop_iterate();
HAL_Delay(1);
}
@@ -151,7 +144,18 @@ uint8_t write_register(uint16_t address, uint16_t value)
switch (address)
{
case 0x2001: relays = value; break;
case 0x2002: motor_pwm = value; break;
case 0x2002: motor_pwm = value;
if(motor_pwm>MOTOR_MAX)motor_pwm=MOTOR_MAX;
if(motor_pwm<MOTOR_MIN)motor_pwm=MOTOR_MIN;
if(motor_pwm==0)
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
else
{
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1, motor_pwm);
HAL_Delay(5);
}
break;
default: ret = 1;
}
return ret;