mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
continuous improvement (#19897)
- servo fix on movement during operation. position did not behave as expected if position change before stop - enhanced minimum change on stepper shutter depending on motordelay
This commit is contained in:
parent
ba4d031cc6
commit
2e95f45458
@ -674,17 +674,21 @@ void ShutterInit(void)
|
|||||||
Shutter[i].tilt_target_pos = Shutter[i].tilt_real_pos = ShutterSettings.shutter_tilt_pos[i];
|
Shutter[i].tilt_target_pos = Shutter[i].tilt_real_pos = ShutterSettings.shutter_tilt_pos[i];
|
||||||
Shutter[i].tilt_velocity = Shutter[i].tilt_config[2] > 0 ? ((Shutter[i].tilt_config[1] - Shutter[i].tilt_config[0]) / Shutter[i].tilt_config[2]) + 1 : 1;
|
Shutter[i].tilt_velocity = Shutter[i].tilt_config[2] > 0 ? ((Shutter[i].tilt_config[1] - Shutter[i].tilt_config[0]) / Shutter[i].tilt_config[2]) + 1 : 1;
|
||||||
Shutter[i].close_velocity_max = ShutterGlobal.open_velocity_max*Shutter[i].open_time / Shutter[i].close_time;
|
Shutter[i].close_velocity_max = ShutterGlobal.open_velocity_max*Shutter[i].open_time / Shutter[i].close_time;
|
||||||
|
|
||||||
//servo can make any movement without time restriction
|
|
||||||
Shutter[i].min_realPositionChange = 0;
|
|
||||||
if (ShutterGlobal.position_mode != SHT_PWM_VALUE) {
|
|
||||||
Shutter[i].min_realPositionChange = 2 * tmax(ShutterGlobal.open_velocity_max, Shutter[i].close_velocity_max);
|
|
||||||
}
|
|
||||||
|
|
||||||
Shutter[i].min_TiltChange = 2 * Shutter[i].tilt_velocity;
|
Shutter[i].min_TiltChange = 2 * Shutter[i].tilt_velocity;
|
||||||
|
|
||||||
|
//servo can make any movement without time restriction
|
||||||
|
Shutter[i].min_realPositionChange = 2 * tmax(ShutterGlobal.open_velocity_max, Shutter[i].close_velocity_max);
|
||||||
|
switch (ShutterGlobal.position_mode) {
|
||||||
|
case SHT_PWM_VALUE:
|
||||||
|
Shutter[i].min_realPositionChange = 0;
|
||||||
|
break;
|
||||||
|
case SHT_COUNTER:
|
||||||
|
Shutter[i].min_realPositionChange = SHT_DIV_ROUND(Shutter[i].min_realPositionChange, Shutter[i].motordelay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d min realpos_chg: %d, min tilt_chg %d"), i+1, Shutter[i].min_realPositionChange, Shutter[i].min_TiltChange);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d min realpos_chg: %d, min tilt_chg %d"), i+1, Shutter[i].min_realPositionChange, Shutter[i].min_TiltChange);
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d Openvel %d, Closevel: %d"), i+1, ShutterGlobal.open_velocity_max, Shutter[i].close_velocity_max);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Openvel %d, Closevel: %d"), i+1, ShutterGlobal.open_velocity_max, Shutter[i].close_velocity_max);
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init. Pos %d, Inv %d, Locked %d, Endstop enab %d, webButt inv %d, Motordel: %d"),
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init. Pos %d, Inv %d, Locked %d, Endstop enab %d, webButt inv %d, Motordel: %d"),
|
||||||
i+1, Shutter[i].real_position,
|
i+1, Shutter[i].real_position,
|
||||||
(ShutterSettings.shutter_options[i] & 1) ? 1 : 0, (ShutterSettings.shutter_options[i] & 2) ? 1 : 0, (ShutterSettings.shutter_options[i] & 4) ? 1 : 0, (ShutterSettings.shutter_options[i] & 8) ? 1 : 0, Shutter[i].motordelay);
|
(ShutterSettings.shutter_options[i] & 1) ? 1 : 0, (ShutterSettings.shutter_options[i] & 2) ? 1 : 0, (ShutterSettings.shutter_options[i] & 4) ? 1 : 0, (ShutterSettings.shutter_options[i] & 8) ? 1 : 0, Shutter[i].motordelay);
|
||||||
@ -810,10 +814,7 @@ void ShutterPowerOff(uint8_t i)
|
|||||||
// Store current PWM value to ensure proper position after reboot.
|
// Store current PWM value to ensure proper position after reboot.
|
||||||
switch (ShutterGlobal.position_mode) {
|
switch (ShutterGlobal.position_mode) {
|
||||||
case SHT_PWM_VALUE:
|
case SHT_PWM_VALUE:
|
||||||
Shutter[i].pwm_value = SHT_DIV_ROUND((ShutterSettings.shutter_pwmrange[1][i]-ShutterSettings.shutter_pwmrange[0][i]) * Shutter[i].target_position , Shutter[i].open_max)+ShutterSettings.shutter_pwmrange[0][i];
|
|
||||||
//analogWrite(Pin(GPIO_PWM1, i), Shutter[i].pwm_value);
|
|
||||||
TasmotaGlobal.pwm_value[i] = Shutter[i].pwm_value;
|
TasmotaGlobal.pwm_value[i] = Shutter[i].pwm_value;
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: PWM final %d"),Shutter[i].pwm_value);
|
|
||||||
pwm_apply = true;
|
pwm_apply = true;
|
||||||
char scmnd[20];
|
char scmnd[20];
|
||||||
#ifdef SHUTTER_CLEAR_PWM_ONSTOP
|
#ifdef SHUTTER_CLEAR_PWM_ONSTOP
|
||||||
@ -990,12 +991,7 @@ void ShutterRtc50mS(void)
|
|||||||
case SHT_PWM_VALUE:
|
case SHT_PWM_VALUE:
|
||||||
ShutterUpdateVelocity(i);
|
ShutterUpdateVelocity(i);
|
||||||
Shutter[i].real_position += Shutter[i].direction > 0 ? Shutter[i].pwm_velocity : (Shutter[i].direction < 0 ? -Shutter[i].pwm_velocity : 0);
|
Shutter[i].real_position += Shutter[i].direction > 0 ? Shutter[i].pwm_velocity : (Shutter[i].direction < 0 ? -Shutter[i].pwm_velocity : 0);
|
||||||
// avoid overshoot on servo if changes are very small
|
Shutter[i].pwm_value = SHT_DIV_ROUND((ShutterSettings.shutter_pwmrange[1][i] - ShutterSettings.shutter_pwmrange[0][i]) * Shutter[i].real_position , Shutter[i].open_max) + ShutterSettings.shutter_pwmrange[0][i];
|
||||||
if ((Shutter[i].direction > 0 && Shutter[i].real_position > Shutter[i].target_position)
|
|
||||||
|| (Shutter[i].direction < 0 && Shutter[i].real_position < Shutter[i].target_position)) {
|
|
||||||
Shutter[i].real_position = Shutter[i].target_position;
|
|
||||||
}
|
|
||||||
Shutter[i].pwm_value = SHT_DIV_ROUND((ShutterSettings.shutter_pwmrange[1][i]-ShutterSettings.shutter_pwmrange[0][i]) * Shutter[i].real_position , Shutter[i].open_max)+ShutterSettings.shutter_pwmrange[0][i];
|
|
||||||
TasmotaGlobal.pwm_value[i] = Shutter[i].pwm_value;
|
TasmotaGlobal.pwm_value[i] = Shutter[i].pwm_value;
|
||||||
pwm_apply = true;
|
pwm_apply = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user