mirror of
https://gitea.ecohim.ru:3000/RS485_Relay/RS485_Relay2_fw.git
synced 2025-08-06 16:07:17 +03:00
add: probe motor control PWM
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
#define REL_MAIN_BIT (1u<<0)
|
||||
#define REL_AUX_BIT (1u<<1)
|
||||
|
||||
#define MOTOR_MIN 0
|
||||
#define MOTOR_MAX 255
|
||||
|
||||
|
||||
void loop_iterate();
|
||||
void timer1_ovf_isr(void);
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user