mirror of https://github.com/arendst/Tasmota.git
#14678 option to let direction relay to execute.
Two new compiler options for user_config.override (below default values) #define SHUTTER_RELAY_OPERATION_TIME = 100 // wait for direction relay 0.1sec before power up main relay #define MOTOR_STOP_TIME = 500 // wait 0.5 second after stop to do any other action. e.g. move in the opposite direction
This commit is contained in:
parent
19dc1b620f
commit
06cdb42cec
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
xdrv_27_Shutter[i].ino - Shutter/Blind support for Tasmota
|
||||
|
||||
Copyright (C) 2021 Stefan Bode
|
||||
Copyright (C) 2022 Stefan Bode
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,11 +27,19 @@
|
|||
#define SHUTTER_STEPPER
|
||||
#endif
|
||||
|
||||
#ifndef SHUTTER_RELAY_OPERATION_TIME
|
||||
#define SHUTTER_RELAY_OPERATION_TIME = 100 // wait for direction relay 0.1sec before power up main relay
|
||||
#endif
|
||||
|
||||
#ifndef MOTOR_STOP_TIME
|
||||
#define MOTOR_STOP_TIME = 500 // wait 0.5 second after stop to do any other action. e.g. move in the opposite direction
|
||||
#endif
|
||||
|
||||
//#define SHUTTER_UNITTEST
|
||||
|
||||
#define D_SHUTTER "SHUTTER"
|
||||
|
||||
const uint16_t MOTOR_STOP_TIME = 500; // in mS
|
||||
|
||||
const uint16_t RESOLUTION = 1000; // incresed to 1000 in 8.5 to ramp servos
|
||||
const uint8_t STEPS_PER_SECOND = 20; // FUNC_EVERY_50_MSECOND
|
||||
const uint16_t pwm_servo_max = 500;
|
||||
|
@ -474,7 +482,7 @@ void ShutterDecellerateForStop(uint8_t i)
|
|||
|
||||
void ShutterPowerOff(uint8_t i)
|
||||
{
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Stop %d. Mode %d, time:%d"), i+1,Shutter[i].switch_mode, Shutter[i].time); // fix log to indicate correct shutter number
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Stop %d Mode %d time %d"), i+1,Shutter[i].switch_mode, Shutter[i].time); // fix log to indicate correct shutter number
|
||||
ShutterDecellerateForStop(i);
|
||||
uint8_t cur_relay = Settings->shutter_startrelay[i] + (Shutter[i].direction == 1 ? 0 : (uint8_t)(ShutterGlobal.position_mode == SHT_TIME)) ;
|
||||
if (Shutter[i].direction !=0) {
|
||||
|
@ -1177,6 +1185,8 @@ void CmndShutterPosition(void)
|
|||
}
|
||||
if (Shutter[index].direction != new_shutterdirection) {
|
||||
ShutterStartInit(index, new_shutterdirection, Shutter[index].target_position);
|
||||
uint8_t save_direction = Shutter[i].direction;
|
||||
Shutter[i].direction = 0; // set temporary direction = 0 to avoid RTC timer sarting. Some delay may happen before shutter starts moving
|
||||
switch (ShutterGlobal.position_mode) {
|
||||
case SHT_COUNTER:
|
||||
case SHT_PWM_TIME:
|
||||
|
@ -1185,6 +1195,7 @@ void CmndShutterPosition(void)
|
|||
if (!ShutterGlobal.skip_relay_change) {
|
||||
// Code for shutters with circuit safe configuration, switch the direction Relay
|
||||
ExecuteCommandPowerShutter(Settings->shutter_startrelay[index] +1, new_shutterdirection == 1 ? 0 : 1, SRC_SHUTTER);
|
||||
delay(SHUTTER_RELAY_OPERATION_TIME);
|
||||
// power on
|
||||
ExecuteCommandPowerShutter(Settings->shutter_startrelay[index], 1, SRC_SHUTTER);
|
||||
}
|
||||
|
@ -1204,9 +1215,9 @@ void CmndShutterPosition(void)
|
|||
AddLog(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE);
|
||||
for (uint8_t k=0 ; k <= (uint8_t)(Shutter[index].switch_mode == SHT_PULSE) ; k++) {
|
||||
ExecuteCommandPowerShutter(Settings->shutter_startrelay[index], 1, SRC_SHUTTER);
|
||||
delay(500);
|
||||
delay(MOTOR_STOP_TIME);
|
||||
ExecuteCommandPowerShutter(Settings->shutter_startrelay[index], 0, SRC_SHUTTER);
|
||||
delay(500);
|
||||
delay(MOTOR_STOP_TIME);
|
||||
}
|
||||
// reset shutter time to avoid 2 seconds above count as runtime
|
||||
Shutter[index].time = 0;
|
||||
|
@ -1215,6 +1226,7 @@ void CmndShutterPosition(void)
|
|||
} // if (!ShutterGlobal.skip_relay_change)
|
||||
break;
|
||||
} // switch (ShutterGlobal.position_mode)
|
||||
Shutter[i].direction = save_direction;
|
||||
ShutterGlobal.RelayCurrentMask = 0;
|
||||
} // if (Shutter[i].direction[index] != new_shutterdirection)
|
||||
} else {
|
||||
|
@ -1611,6 +1623,7 @@ void CmndShutterSetTilt(void)
|
|||
}
|
||||
}
|
||||
XdrvMailbox.data[0] = '\0';
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("SHT: TiltTarget %d, payload %d"), Shutter[XdrvMailbox.index -1].tilt_target_pos,XdrvMailbox.payload);
|
||||
ResponseCmndNumber(Shutter[XdrvMailbox.index -1].tilt_target_pos);
|
||||
Shutter[XdrvMailbox.index -1].tiltmoving = 1;
|
||||
CmndShutterPosition();
|
||||
|
|
Loading…
Reference in New Issue