From a627df0ad11e1ff453c6b669d01abfa9d42ba0e0 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 11 Feb 2022 18:05:44 +0100 Subject: [PATCH 1/4] Fix shutter-stepper driver if >1 door moving Accelerate and decelerate did not work properly on two pins with different frequencies. Was always synced to the last send frequency without PIN awareness. If moving two doors or more frequency must work for each door independent --- tasmota/xdrv_27_shutter.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index 7b385af86..c2aca6742 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -175,8 +175,10 @@ void ShutterRtc50mS(void) if (Shutter[i].accelerator) { //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator); ShutterUpdateVelocity(i); - analogWriteFreq(Shutter[i].pwm_velocity); - analogWrite(Pin(GPIO_PWM1, i), 50); + digitalWrite(Pin(GPIO_PWM1, i), LOW); + // Convert frequency into clock cycles + uint32_t cc = microsecondsToClockCycles(1000000UL) / Shutter[i].pwm_velocity; + startWaveformClockCycles(Pin(GPIO_PWM1, i), cc/2, cc/2, 0, -1, 0, false); } break; } From 0d8b3c9d1adbd2ade4729bf92df304b36389edaf Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 11 Feb 2022 18:44:37 +0100 Subject: [PATCH 2/4] ESP32 compiler option --- tasmota/xdrv_27_shutter.ino | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index c2aca6742..8ab4eda5a 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -175,10 +175,15 @@ void ShutterRtc50mS(void) if (Shutter[i].accelerator) { //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator); ShutterUpdateVelocity(i); - digitalWrite(Pin(GPIO_PWM1, i), LOW); + #ifdef ESP8266 // Convert frequency into clock cycles uint32_t cc = microsecondsToClockCycles(1000000UL) / Shutter[i].pwm_velocity; startWaveformClockCycles(Pin(GPIO_PWM1, i), cc/2, cc/2, 0, -1, 0, false); + #endif // ESP8266 + #ifdef ESP32 + analogWriteFreq(Shutter[i].pwm_velocity) + analogWrite(Pin(GPIO_PWM1, i), 50); + #endif // ESP32 } break; } From 33e956d43879d0ab403f43f2dc94a283e48b2c52 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 11 Feb 2022 18:47:00 +0100 Subject: [PATCH 3/4] missing... --- tasmota/xdrv_27_shutter.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index 8ab4eda5a..e79349c90 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -175,6 +175,7 @@ void ShutterRtc50mS(void) if (Shutter[i].accelerator) { //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator); ShutterUpdateVelocity(i); + digitalWrite(Pin(GPIO_PWM1, i), LOW); #ifdef ESP8266 // Convert frequency into clock cycles uint32_t cc = microsecondsToClockCycles(1000000UL) / Shutter[i].pwm_velocity; From 127e6ff2487587206d792759ac00883a59929198 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 11 Feb 2022 19:07:46 +0100 Subject: [PATCH 4/4] missing `;` --- tasmota/xdrv_27_shutter.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index e79349c90..d4cbd0191 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -182,7 +182,7 @@ void ShutterRtc50mS(void) startWaveformClockCycles(Pin(GPIO_PWM1, i), cc/2, cc/2, 0, -1, 0, false); #endif // ESP8266 #ifdef ESP32 - analogWriteFreq(Shutter[i].pwm_velocity) + analogWriteFreq(Shutter[i].pwm_velocity); analogWrite(Pin(GPIO_PWM1, i), 50); #endif // ESP32 }