Tasmota: Stepper Motor Shutter Control

Created on 23 Nov 2019  Â·  96Comments  Â·  Source: arendst/Tasmota

@stefanbode

Is it possible to set up the shutter driver to work with the Stepper Motor driver? The driver uses either a A4988 or a DRV8825. My thought is that whereas your driver expects two relay components, the stepper uses rotation direction and on/off which could correspond to the two relays. The stepping increment could be "static" and set via MotorMIS. Due to the way stepper motors shudder, power enabled would need to be managed as well. Perhaps it would be the second relay instead of motor on/off and instead the setup would drive motor on/off always on (e.g., a third relay always powered on)?

I'm piggybacking on @TrDA-hab's (TrDA on Discord) personal project he's built to control his roller shutter. I just wanted to put the two of you in touch since you're not on Discord. I think this is an opportunity to provide a working solution using both your driver and the stepper motor driver.

Cheers!

Mike

enhancement fixed

Most helpful comment

I must admit I was not aware that the steppers do make so much fun. you can now use the shuttermotordelay[x] to define a soft start/stop. Also shutterfrequency now permanently save the new PWM frequency.

I got the following relyable working: 30V A4988, frequency 10,000 Hz and really soft start stop: shuttermotordelay 4.0

All 96 comments

I stumbled upon the conversation, very interesting stuff. Hope @stefanbode sees this.

I just wanted to emphasize the importance os this project, by copying the discord chat:

TrDALast Saturday at 7:11 AM
These are me designed and printed on a 3D printer for mounting the Nema-17 stepper motor. This is done to control a large roller blind. The tasmota-wiki contains information about the management of Nema-17 + ESP8266 + A4986
IMG-20190622-WA0007
20190706_171123
Roller-gear_v8
GT2-1_v26

//Rule1 on power1#state=1 do publish cmnd/Sonoff_MOTOR_1/MotorMove 10000 endon
//Rule2 on power1#state=0 do publish cmnd/Sonoff_MOTOR_1/MotorMove -10000 endon
Rule1 on power1#state=1 do MotorMove 10000 endon
Rule2 on power1#state=0 do MotorMove -10000 endon
Rule3 on system#boot do MotorRPM 300 endon

20191015_214059
20191015_210922
20190706_165104
20190706_165746

If you are going to remake your 28BYJ-48 engine to work with the A4988:
https://coeleveld.com/wp-content/uploads/2016/10/Modifying-a-28BYJ-48-step-motor-from-unipolar-to-bipolar.pdf
If you are going to print the drive for your roller blinds on a 3D printer, you can use these 3D models for the 28BYJ-48 engine.
https://www.thingiverse.com/thing:2392856
https://www.thingiverse.com/thing:3368379

20190524_194144
A4988-8
28BYJ-48_V2

TrDALast Saturday at 12:08 PM
You can connect two A4988 drivers in parallel with one ESP8266, and they will work synchronously - I tested it, it works fine

20191123_133416
Nema-17_v2
A4988_x2

There is another option for connecting two NEMA-17, they will also work synchronously - this is a standard solution for 3D printers.
Attention - stepper motors must be the same!
https://nl.aliexpress.com/item/33052488815.html
A4988_x4

All credit goes to https://github.com/TrDA-hab

I stumbled upon the conversation, very interesting stuff. Hope @stefanbode sees this.

Come on this is really over-engineered. You really want to operate a Schutter with a Stepper Motor?

I've seen many DIY shutters on the Internet that use steppers. Do, from what I have seen, yes. And from these two additional data points, ...

Ok maybe I can give it a try. But how does the current driver behave if i change the position during movement. I assume this is all in sync whatever you do. Are there limits or can I use unsigned long variables for the position. This might the easiest way to implement. Internally I already have something that I can use for the position command.

@TrDA-hab ⬆️

Is there an option to get the current position of the stepper. For example how to stop it. Power off is maybe not a good idea. I assume it is not self locking. I saw the wiki with some commands but no info what and how stuff is reported back. Look I need to assemble one and give it a try to see what happens

Adding @Leuselator who wrote the stepper driver.

my2ct: Steppers themselves usually don't report anything.

You have (at least) one endstop that reports a known position and from there on it is step counting by the „user“ and trusting no steps are lost.

Usually this works very well, see 3D printers as proof...

@stefanbode

But how does the current driver behave if i change the position during movement?

  1. To change the movement, it is necessary to stop the stepper motor (STOP command), and then give the stepper motor a command to move in the opposite direction.
  2. To stop the stepper motor, it is necessary to issue the STOP command, but this command is currently not implemented in the firmware.
  3. Currently, you can only wait for the current command to execute, only then give another command.

Is there an option to get the current position of the stepper?

  1. There is no feedback in standard drivers / motors, it is not possible to get the position of the motor.
  2. We can only send a command to the driver with the indicated number of steps + direction of movement + rotation speed, and we hope that there will be no skipping steps at the stepper motor.

For example, the commands: raise and lower the curtain:
Rule1 on power1#state=1 do MotorMove 10000 endon
Rule2 on power1#state=0 do MotorMove -10000 endon

p.s.
https://reprap.org/wiki/Pololu_stepper_driver_board
https://reprap.org/wiki/NEMA_17_Stepper_motor
https://reprap.org/wiki/Motor_control_loop

Hi gents, I have now a working Nema17 with a a4988 stepper. In general this will be more complicated than I expected because you cannot stop the motor. Once you send a command to the driver the ESP ist busy. It looks like the command is blocking. The only way to get it something similar to the current behaviour is to split the command in 100ms chunks....

I enhanced the motordriver in different ways. Also worked with the most course stepping of 1 to get the maximum time delay between two commands. Additionally made the numbers of remaining steps public, so you can control. Anyhow the required behavior makes it really tough to use it in Tasmota. I will now check, if I can use the PWM with a frequency "hook" to get more control during operation of the stepper driver.

Good news, friends. I have an updated shutter driver that works with the stepper motor. Anyhow this is really tricky stuff right now and I need some investigation if I broke down something else. The good news is we do not need the 10k code from the Stepper driver.

Happy to test. I’m currently using a NodeMCU to drive a stepper to operate my roller blinds. Using rules at the moment to deal with open and close. One thing that would be really useful would be if acceleration could be implemented so as to avoid the hard start when the stepper starts moving. Also - this is mainly for quality of life - would it be possible to get a settings page for MotorRPM and MotorSPR? The current build doesn’t seem to remember those settings after reboots (although that could be an issue with my build). I’ve set them pre-compile now to get around it.

Oh, You will love it :-) I had exactly the same in mind. Ramp is definitely a good idea, to avoid overload the motor. Regarding the RPM this is not as easy. I have a fixed 1000 steps/sec which is 5RPS when having stepping to 1. The ramp is 0.5sec; which is fast enough but also gives some room for accelerating the heavy load. I still work on the timing because as always it is NOT straight forward just to use just the stepper driver. This is unusable because it blocks TASMOTA for the complete operation.

Stefan - Thank you! As always, a better outcome than originally envisioned and much more useful for Tasmota users!

Stefan - That sounds great. Looking forward to testing. The wife will not be happy that I'm going to disassemble the kitchen blinds again......

Great job guys. I was wondering, why my code results in so much additional driversize as well. I was happy enough to get it work somehow and yes - the way I drive the motor is blocking Tasmota and not elegant at all. Unfortunately I've no time @ the moment to put effort into this - but I cross fingers for you!
Greetings

@stefanbode
I used to use these libraries DRV8825.h (for other projects).
Maybe you can use this library?
https://github.com/laurb9/StepperDriver

for information only.

I have added the stepper driver support for shutters/blinds. Please start testing with the following configuration:

Schuttermode 1: Failsafe Configuration. No INTERLOCK
D1: Relay1i: A4988 PIN: EN
D2: Relay2 : A4988 PIN: DIR
D3: PWM1: A4988 PIN: STP
D4: COUNTER1: Connect to D3#
A4988: MS1,MS2,MS3 to GROUND or not connected. 1 step == 1.8°

The Stepper will operate with 1000 steps/sec. Ramp up 0..1000 in 10 steps in 0.5 sek. Ramp down with 500 steps/sec.

Shutteropendurationand shutterclosedurationmust be equal.

Ramp will take 0.25sec extra per move. You CAN define shuttermotordelay 0.25, but not required.

You can start/stop/change direction at any time. Stepper will go with full speed near endpoint and then slow down to touch correct position. If shuttermotordelay is too high the stepper will overrun the endpoint. bad idea! I did several movements forward and backward. There was no single step missing. Position was always targeted 100%.

Thanks Stefan. I'll get testing tomorrow evening. Thanks for all your efforts.

At the end it was really fun to overcome the issue that after some time you did not exactly get back where you should be. Using the COUNTER and measure what you do with a ramp starting from 0Hz did the trick at the end. The PWM is much smarter because integrated in the core. All the drivers block the code. Very inconvenient, if you expect a runtime of 20sec or more. You do NOT need to include the stepper driver for compiling. I only use standard PWM, COUNTER, RELAY.

@stefanbode

On the issue of controlling and receiving feedback from stepper motors (Closed Loop Stepper Motor), there are three good projects with great potential. Receiving the information:

  • direction/speed/acceleration of movement.
  • restore missed steps.
  • debugging.
  • SPI, I2C, UART, PWM.
  • and other.

You may find it interesting.

  1. Ustepper:
    https://ustepper.com/store/ustepper-boards/27-46-ustepper-s.html#/28-connector-dc_jack/31-stepper_motor-no_stepper_motor
    https://github.com/uStepper/uStepperS
    https://nl.aliexpress.com/item/4000418431198.html

  2. Mechaduino:
    https://tropical-labs.com/shop/mechaduino-0-2-pcb/
    https://github.com/jcchurch13
    https://nl.aliexpress.com/item/32952527069.html

  3. MKS-SERVO:
    https://github.com/makerbase-mks/MKS-SERVO42A
    https://nl.aliexpress.com/item/32917408111.html

  4. Nano zero stepper:
    https://github.com/Misfittech/nano_stepper
    https://www.aliexpress.com/item/4000418442909.html

p.s. MKS Steptest PWM pulse generator:
https://nl.aliexpress.com/item/32856654440.html
https://www.amazon.com/Value-Home-Tools-generator-controller-amplifier-control-driven/dp/B07K4QX123/ref=sr_1_1?keywords=MKS+Steptest&qid=1575393584&sr=8-1

for information only.

@titomontes @TrDA-hab @RiRilot @Leuselator

This enhancement is now merged into the latest development branch. Are you able to test this new feature and report back your success or any issues encountered?

Yes, I will this evening UK time. I have compiled the latest dev branch and stuck it on a NodeMCU. I'll hook it up and report back.

Yes, I find this solution very interesting and will do many tests. I will report the result back. I will do it now.

I’m struggling to get the stepper to move more than a few steps in either direction. I think this is because I’m not very familiar with the shutter configuration. I can’t seem to get them in to shutter mode 2.

What I'm seeing is the stepper moving a few steps then stopping. The counter is continuing to count steps which says to me that the EN pin isn't staying high.

It doesn’t work for me either. The error is the same.
1
2
3
4
5

You have compiled you own version and enabled the shutter in the user config? Only then you have access to the shutter commands. The shutter mode 1 is default and wil be selected depending on interlock and pulsetimers. If you do nothing everything is fine. Please see the wiki. You have to execute setoption80 1 and reboot to enable the shutter. There is an actual wiki also for steppers already online

Yes, I forgot to execute setoption80 1. The error is the same.

23:38:52 CMD: SetOption80 23:38:52 MQT: stat/tasmota/RESULT = {"SetOption80":"ON"} 23:39:08 CMD: ShutterOpenDuration 23:39:08 MQT: stat/tasmota/RESULT = {"ShutterOpenDuration1":"500.0"} 23:39:20 CMD: ShutterCloseDuration 23:39:20 MQT: stat/tasmota/RESULT = {"ShutterCloseDuration1":"500.0"} 23:39:46 CMD: ShutterRelay1 1 23:39:46 SHT: Relay 1 is 1 23:39:46 SHT: Accuracy digits: 1 23:39:46 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 1000000, Opentime 500.0 [s], Closetime 500.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 0 23:39:46 MQT: stat/tasmota/RESULT = {"ShutterRelay1":1}

Your open duration is really 500 sek? I have to check if my variables are all big enough. They should match. No worries

The rest looks ok. Please do not forget the counter 1 as described in the wiki

00:00:32 CMD: shutterrelay1 1
00:00:32 SHT: Relay 1 is 1
00:00:32 SHT: Accuracy digits: 1
00:00:32 SHT: Shutter 0 (Relay:1): Init. Pos: 18000 [90 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 20000, Opentime 10.0 [s], Closetime 10.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 2,motordelay 0
00:00:32 RSL: stat/tasmota/RESULT = {"ShutterRelay1":1}

I have GPIOs defines as this:
image

On togging a relay motor moves a few steps then stops. Counter continues to count pulses. Motor stays stationary:

image

Stepper driver is definitely connected to the correct GPIOs

Let’s assume the wire ring to the a4988 is correct. Can you increase log level to 4 and send the log. Looks still ok from here. The current on the driver should be 0.3A. There is a small screw on the driver that you can change with a plastic !!! Screwdriver. 1a, 1b and 2a, 2b are correct? There should be a non infinite resistance on the 1 and the 2’s.

23:59:24 CMD: shuttermotordelay 0.25 23:59:24 SHT: Accuracy digits: 1 23:59:24 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 100000, Opentime 50.0 [s], Closetime 50.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 5 23:59:24 MQT: stat/tasmota/RESULT = {"ShutterMotorDelay1":"0.25"} 23:59:34 CMD: ShutterRelay 23:59:34 MQT: stat/tasmota/RESULT = {"ShutterRelay1":1} 00:00:06 CMD: ShutterRelay1 1 00:00:06 SHT: Relay 1 is 1 00:00:06 SHT: Accuracy digits: 1 00:00:06 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 100000, Opentime 50.0 [s], Closetime 50.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 5 00:00:06 MQT: stat/tasmota/RESULT = {"ShutterRelay1":1} 00:01:43 CMD: Shutteropenduration 500 00:01:43 SHT: Accuracy digits: 1 00:01:43 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 1000 , Max Way: 1000000, Opentime 500.0 [s], Closetime 50.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 5 00:01:43 MQT: stat/tasmota/RESULT = {"ShutterOpenDuration1":"500.0"} 00:01:59 CMD: ShutterCloseDuration 500 00:01:59 SHT: Accuracy digits: 1 00:01:59 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 1000000, Opentime 500.0 [s], Closetime 500.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 5 00:01:59 MQT: stat/tasmota/RESULT = {"ShutterCloseDuration1":"500.0"}

Se d the log when sending shutteropen or Shutterclose with the 10sec. To make it simple first

00:06:39 CMD: shutteropen 10 00:06:39 SRC: WebConsole from 192.168.1.52 00:06:39 CMD: Group 0, Index 1, Command "SHUTTEROPEN", Data "10" 00:06:39 SHT: Position in: payload 10 (2), payload 100, index 1, source 7 00:06:39 SHT: lastsource 7:, realpos 0, target 1000000, payload 100 00:06:39 SRC: Shutter 00:06:39 SHT: Switched relay: 0 by Shutter 00:06:39 MQT: stat/tasmota/RESULT = {"POWER1":"OFF"} 00:06:39 MQT: stat/tasmota/POWER1 = OFF 00:06:39 SHT: Wait for Motorstop 500 00:06:39 SRC: Shutter 00:06:39 SHT: Switched relay: 0 by Shutter 00:06:39 MQT: stat/tasmota/RESULT = {"POWER2":"OFF"} 00:06:39 MQT: stat/tasmota/POWER2 = OFF 00:06:39 SRC: Shutter 00:06:39 SHT: Switched relay: 1 by Shutter 00:06:39 MQT: stat/tasmota/RESULT = {"POWER1":"ON"} 00:06:39 MQT: stat/tasmota/POWER1 = ON 00:06:39 MQT: stat/tasmota/RESULT = {"ShutterOpen1":100} 00:06:39 SHT: Shutter 0: Real Pos: 800, Target 1000000, source: Shutter, start-pos: 0 %, direction: 1, rtcshutter: 0.6 [s] 00:06:39 SRC: PulseTimer 00:06:39 SHT: Switched relay: 1 by PulseTime 00:06:39 MQT: stat/tasmota/RESULT = {"POWER1":"OFF"} 00:06:39 MQT: stat/tasmota/POWER1 = OFF 00:06:40 WIF: Checking connection... 00:06:40 WIF: Connected 00:06:40 SHT: Shutter 0: Real Pos: 2800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 1.6 [s] 00:06:41 SHT: Shutter 0: Real Pos: 4900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 2.7 [s] 00:06:42 SHT: Shutter 0: Real Pos: 6900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 3.7 [s] 00:06:43 SHT: Shutter 0: Real Pos: 8900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 4.7 [s] 00:06:44 SHT: Shutter 0: Real Pos: 10900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 5.7 [s] 00:06:45 SHT: Shutter 0: Real Pos: 12900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 6.7 [s] 00:06:46 SHT: Shutter 0: Real Pos: 14900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 7.7 [s] 00:06:47 SHT: Shutter 0: Real Pos: 16800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 8.6 [s] 00:06:48 SHT: Shutter 0: Real Pos: 18800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 9.6 [s] 00:06:49 SHT: Shutter 0: Real Pos: 20800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 10.6 [s] 00:06:50 SHT: Shutter 0: Real Pos: 22900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 11.7 [s] 00:06:51 SHT: Shutter 0: Real Pos: 24900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 12.7 [s] 00:06:52 SHT: Shutter 0: Real Pos: 26800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 13.6 [s] 00:06:53 SHT: Shutter 0: Real Pos: 28900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 14.7 [s] 00:06:54 SHT: Shutter 0: Real Pos: 30900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 15.7 [s] 00:06:55 SHT: Shutter 0: Real Pos: 32800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 16.6 [s] 00:06:56 SHT: Shutter 0: Real Pos: 34800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 17.6 [s] 00:06:57 SHT: Shutter 0: Real Pos: 36900, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 18.7 [s] 00:06:58 SHT: Shutter 0: Real Pos: 38800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 19.6 [s] 00:06:59 SHT: Shutter 0: Real Pos: 40800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 20.6 [s] 00:07:00 WIF: Checking connection... 00:07:00 WIF: Connected 00:07:00 SHT: Shutter 0: Real Pos: 42800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 21.6 [s] 00:07:01 SHT: Shutter 0: Real Pos: 44800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 22.6 [s] 00:07:02 SHT: Shutter 0: Real Pos: 46800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 23.6 [s] 00:07:03 SHT: Shutter 0: Real Pos: 48800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 24.6 [s] 00:07:04 SHT: Shutter 0: Real Pos: 50800, Target 1000000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 25.6 [s]
......................

Driver is fine. I can controll it with the normal A4988 code.

22:07:21 CMD: shutterclose
22:07:21 SHT: Start shutter in direction -1
22:07:21 RSL: stat/tasmota/RESULT = {"POWER2":"ON"}
22:07:21 RSL: stat/tasmota/POWER2 = ON
22:07:21 RSL: stat/tasmota/RESULT = {"ShutterClose1":0}
22:07:21 RSL: stat/tasmota/RESULT = {"POWER2":"OFF"}
22:07:21 RSL: stat/tasmota/POWER2 = OFF
22:07:21 SHT: Shutter 0: Real Pos: 19000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 0.5 [s]
22:07:22 SHT: Shutter 0: Real Pos: 17000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 1.5 [s]
22:07:23 SHT: Shutter 0: Real Pos: 15000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 2.5 [s]
22:07:24 SHT: Shutter 0: Real Pos: 13000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 3.5 [s]
22:07:25 SHT: Shutter 0: Real Pos: 11000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 4.5 [s]
22:07:26 SHT: Shutter 0: Real Pos: 9000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 5.5 [s]
22:07:27 SHT: Shutter 0: Real Pos: 7000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 6.5 [s]
22:07:28 SHT: Shutter 0: Real Pos: 5000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 7.5 [s]
22:07:29 SHT: Shutter 0: Real Pos: 3000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 8.5 [s]
22:07:30 SHT: Shutter 0: Real Pos: 1000, Target 0, source: PulseTimer, start-pos: 100 %, direction: -1, rtcshutter: 9.5 [s]
22:07:31 RSL: stat/tasmota/RESULT = {"POWER2":"ON"}
22:07:31 RSL: stat/tasmota/POWER2 = ON
22:07:31 RSL: stat/tasmota/SHUTTER1 = 0
22:07:31 RSL: tele/tasmota/RESULT = {"Shutter1":{"Position":0,"direction":0}}
22:07:31 RSL: stat/tasmota/RESULT = {"POWER2":"OFF"}
22:07:31 RSL: stat/tasmota/POWER2 = OFF
22:07:40 CMD: shutteropen
22:07:40 SHT: Start shutter in direction 1
22:07:40 RSL: stat/tasmota/RESULT = {"POWER1":"ON"}
22:07:40 RSL: stat/tasmota/POWER1 = ON
22:07:40 RSL: stat/tasmota/RESULT = {"ShutterOpen1":100}
22:07:40 SHT: Shutter 0: Real Pos: 400, Target 20000, source: Shutter, start-pos: 0 %, direction: 1, rtcshutter: 0.2 [s]
22:07:40 RSL: stat/tasmota/RESULT = {"POWER1":"OFF"}
22:07:40 RSL: stat/tasmota/POWER1 = OFF
22:07:41 SHT: Shutter 0: Real Pos: 2400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 1.2 [s]
22:07:42 SHT: Shutter 0: Real Pos: 4400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 2.2 [s]
22:07:43 SHT: Shutter 0: Real Pos: 6400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 3.2 [s]
22:07:44 SHT: Shutter 0: Real Pos: 8400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 4.2 [s]
22:07:45 SHT: Shutter 0: Real Pos: 10400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 5.2 [s]
22:07:46 SHT: Shutter 0: Real Pos: 12400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 6.2 [s]
22:07:47 SHT: Shutter 0: Real Pos: 14400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 7.2 [s]
22:07:48 SHT: Shutter 0: Real Pos: 16400, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 8.2 [s]
22:07:49 SHT: Shutter 0: Real Pos: 18300, Target 20000, source: PulseTimer, start-pos: 0 %, direction: 1, rtcshutter: 9.1 [s]
22:07:50 RSL: stat/tasmota/RESULT = {"POWER1":"ON"}
22:07:50 RSL: stat/tasmota/POWER1 = ON
22:07:50 RSL: stat/tasmota/SHUTTER1 = 100
22:07:50 RSL: tele/tasmota/RESULT = {"Shutter1":{"Position":100,"direction":0}}
22:07:50 RSL: stat/tasmota/RESULT = {"POWER1":"OFF"}
22:07:50 RSL: stat/tasmota/POWER1 = OFF

Shuttermode 1 does mean Relay1 enable or disable the motor. Relay2 is for the direction. The Pwm Pulses the stepper.

How can I install Shuttermode 2 ???

00:10:15 CMD: Shuttermode 2
00:10:15 SRC: WebConsole from 192.168.1.52
00:10:15 CMD: Group 0, Index 1, Command "SHUTTERMODE", Data "2"
00:10:15 MQT: stat/tasmota/RESULT = {"Command":"Unknown"}

Pulsetime 0 on both relay and no interlock in the shutterrelays.

The modes get selected by the definition of interlock and pulsetime. Please take a look again in the wiki for the circuit safe configuration

Backlog PulseTime1 0; PulseTime2 0
Backlog Interlock 1,2; Interlock OFF

correctly ???

Interlock 1,2 is also not needed. Just in case put interlock 3,4. So sure relays are not in

I have set those and now it's working. That isn't shuttermode 2 according to the docs. That's what threw me.

Docs say:

Stepper motors (ShutterMode: 2) - First relay: OFF/DOWN PULSE, Second relay: OFF/UP PULSE
Backlog PulseTime1 2; PulseTime2 2
Backlog Interlock 1,2; Interlock ON (Interlocked relay pair)

I did:

backlog pulsetime1 0; pulsetime 2 0
backlog interlock 1,2; Interlock OFF

And now it's working. Looks good to me. Lovely smooth movement and nice accelleration.

Uups. Really?

Yup

Oh yes long long day for me. It is mode 1. My fault. Any progress?

Yeah, it's all working now! I've managed to set a good open and close time. No lost steps.

We could really do with a setting to increase the motor RPM in this mode as I use 5:1 panetary geared steppers and the current speed is slooooooooooooow.

I use MotorSPR 16000 in the A4988 driving mode.

You have ms1,ms2,ms3 to ground to get full stars and not only 1/16?

00:16:15 CMD: Backlog PulseTime1 0; PulseTime2 0
00:16:15 SRC: WebConsole from 192.168.1.52
00:16:15 CMD: Group 0, Index 1, Command "BACKLOG", Data "PulseTime1 0; PulseTime2 0"
00:16:16 SRC: Backlog
00:16:16 CMD: Group 0, Index 1, Command "PULSETIME", Data "0"
00:16:16 MQT: stat/tasmota/RESULT = {"PulseTime1":{"Set":0,"Remaining":0}}
00:16:16 SRC: Backlog
00:16:16 CMD: Group 0, Index 2, Command "PULSETIME", Data "0"
00:16:16 MQT: stat/tasmota/RESULT = {"PulseTime2":{"Set":0,"Remaining":0}}
00:16:16 CFG: Saved to flash at F7, Count 125, Bytes 4096
00:16:20 WIF: Checking connection...
00:16:20 WIF: Connected
00:16:25 CMD: Backlog Interlock 3,4; Interlock OFF
00:16:25 SRC: WebConsole from 192.168.1.52
00:16:25 CMD: Group 0, Index 1, Command "BACKLOG", Data "Interlock 3,4; Interlock OFF"
00:16:25 SRC: Backlog
00:16:25 CMD: Group 0, Index 1, Command "INTERLOCK", Data "3,4"
00:16:25 MQT: stat/tasmota/RESULT = {"Interlock":"OFF","Groups":"1,2"}
00:16:26 SRC: Backlog
00:16:26 CMD: Group 0, Index 1, Command "INTERLOCK", Data "OFF"
00:16:26 MQT: stat/tasmota/RESULT = {"Interlock":"OFF","Groups":"1,2"}
00:16:26 CFG: Saved to flash at F6, Count 126, Bytes 4096
00:16:33 HTP: Main Menu
00:16:38 HTP: Console
00:16:40 WIF: Checking connection...

Yeah, I have my 4988 on a breakout with dip switches I can configure. Got them all set to 1/1 stepping.

It makes 5rps. The current is 1000Hz. After 1500 it starts slipping. All ms must be LOW

This are 300 rpm and this is very fast normally. One round are 200 pulses.

At 1/5 gear ratio it need 1000 pulses for 1 revolution at 1/1 microstepping.

Yes, the skill worked!
Why does the stepper move even after restart?

Yes, you can try to modify the const value in the code for the frequency. It is 1000. Let me know if other values also work. If you change the timing will break, but it is a try

Stepper move only After restart if relay1i is not off or not correct wired to EN of the driver

I will have a play with the code tomorrow. It's in xdrv_27_shutter.ino rather than xdrv_25_A4988.ino yes?

Yes, I do not need the a4988 because this was blocking tasmota. Pwm is much smarter

It sure is. I really didn't like the way with the other code I couldn't do anything once I issued a move command.

My fork also works without the counter but then it is by far not that accurate. With counter is better

I will check tomorrow if my nema17 still works with much higher speed. If yes I will make the speed configurable.

Yes it works. But I do not understand the logic of work. Tomorrow I will continue testing.

This is really good stuff stefan. I've got it doing open and close with a single button using a couple of rules. Thankyou so much for your efforts with this. It's a much more elegant solution that how it was before.

I have added a shutterfrequency command. maybe temporary. I was able to change it not more than 1500. Then my motor slips and do not move anymore.
@TrDA-hab : The shutter moven on restart because all relays start with LOW. This enables the shutter. I think it is the same on reboot. The only workaround I can think of is an inverter on the EN pin

3200 steps / second is my maximum with 18V

@stefanbode
Today I will continue to test. In 5 hours I will be at home.
I am willing to spend a lot of time. I am wondering if this solution would work very well.

My steppers are running from 12V. I'll have a play and see how far I can push it tonight. I think the default is actually fast enough for my needs even at 5:1.
I'm using a TMC2208 driver in it right now. Seems to work well with the new code and is silent.

3200 sp/s --- very good result. In my recent projects, I have not used more than 2500 sp/s (12V).
I think to test the stepper at 24V, these are additional plans.

@stefanbode
Today I did all the settings and connections again. It works.
But there is a problem - it works 5 seconds .... and ESP freezes!?!

Step by step what I did:

D5(red): Relay2: A4988 PIN: DIR
D6(blue): PWM1: A4988 PIN: STP
D7(geen): Relay1i: A4988 PIN: EN

//user_config_override.h

ifndef USE_SHUTTER

define USE_SHUTTER

endif

//platformio.ini
-DUSE_CONFIG_OVERRIDE

SetOption80 1

//ShutterMode 1:
Backlog PulseTime1 0; PulseTime2 0
Interlock OFF

* reboot *

Backlog ShutterOpenDuration 15; ShutterCloseDuration 15; shuttermotordelay 0.25

//ShutterRelay1 1
22:37:54 CMD: ShutterRelay1 1
22:37:54 SHT: Relay 1 is 1
22:37:54 SHT: Accuracy digits: 1
22:37:54 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 30000, Opentime 15.0 [s], Closetime 15.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 5
22:37:54 MQT: stat/tasmota/RESULT = {"ShutterRelay1":1}

//power1 1
22:43:33 CMD: power1 1
22:43:33 SHT: Wait for Motorstop 500
22:43:33 MQT: stat/tasmota/RESULT = {"POWER1":"ON"}
22:43:33 MQT: stat/tasmota/POWER1 = ON
22:43:34 SHT: Shutter 0: Real Pos: 13600, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 0.2 [s]
22:43:35 SHT: Shutter 0: Real Pos: 15600, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 1.1 [s]
22:43:36 SHT: Shutter 0: Real Pos: 17600, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 2.2 [s]
22:43:36 SHT: Shutter 0: Real Pos: 19500, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 3.1 [s]
22:43:37 SHT: Shutter 0: Real Pos: 21500, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 4.1 [s]
22:43:38 SHT: Shutter 0: Real Pos: 23500, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 5.1 [s]
22:43:39 SHT: Shutter 0: Real Pos: 25500, Target 30000, source: I, start-pos: 0 %, direction: 1, rtcshutter: 6.1 [s]

+++++++++++++++++++++++
... and my ESP freezes !?!

I tested it 5 times.
I uploaded the firmware after clearing the memory every time.
I need ideas.

7

... or should I execute this command additionally? --- Interlock 3.4

RealPOS and startpos % seems not to match. Very strange. Maybe you make a shuttersetclose first to reinit it to a close position

The interlock will not fix it. Maybe also weblog 4 give a little more info, but I assume not

... only tomorrow I can continue testing.

@stefanbode

Good news.
I ended up testing at this point:

  1. I download and updated the firmware. Everything works stably without errors. I tested this for 1 hour without stopping.
  2. I tested shutterfrequency in the range of 50-1500. Everything works.
  3. The slider does not change the speed - I really look forward to this function.
  4. How to turn off the sound of the bell before starting the stepper? It really bothers me, especially if it is night and my family is sleeping.

I am very pleased with the result. Thank you very much.

@stefanbode

In the new project, I want to control two A4988s from one esp8266 in turn. I remember the restriction on the simultaneous operation of one PWM.

I did a test and it does not work. In WIKI I do not see restrictions.
Where am I wrong? Or is it impossible?

D1: Relay1i: A4988#1 PIN: EN
D2: Relay2: A4988#1 PIN: DIR
D3: PWM1: A4988#1 PIN: STP

D5: Relay2: A4988#2 PIN: DIR
D6: PWM1: A4988#2 PIN: STP
D7: Relay1i: A4988#2 PIN: EN
8
A4988 x2 v1

This is quite simple. It must be pwm2 and counter2 because it is shutter2. The number of the Pwm has nothing to do with the relay

@stefanbode

Good news.
I ended up testing at this point:

  1. I download and updated the firmware. Everything works stably without errors. I tested this for 1 hour without stopping.
  2. I tested shutterfrequency in the range of 50-1500. Everything works.
  3. The slider does not change the speed - I really look forward to this function.
  4. How to turn off the sound of the bell before starting the stepper? It really bothers me, especially if it is night and my family is sleeping.

I am very pleased with the result. Thank you very much.

For speed there is no slider. It is also not intended to change this normally. Should be more or less a configuration parameter. What’s about the bell? Is Santa calling. I really have no bell implemented in the code. No Christmas gift. Who creates the sound? The stepper motor? My did not

@TrDA-hab / @stefanbode

Please write up a concise summary of how to set up the shutter feature for a stepper motor. I'm happy to "polish" it afterward, but need you guys to provide the technical details.

Thanks.

@meingraham

  1. The test is not finished. There is a work in progress.
  2. I am already working on a description.

@meingraham

I'm testing it now. I need more time. Please wait.
This is my test could - just for an example.

D1: Relay2: A4988#1 PIN: DIR
D2: PWM1: A4988#1 PIN: STP
D3: Relay1i: A4988#1 PIN: EN
//D4: Counter1: D2

D5: Relay4: A4988#2 PIN: DIR
D6: PWM2: A4988#2 PIN: STP
D7: Relay3i: A4988#2 PIN: EN
//D8: Counter2: D6

*user_config_override.h

ifndef USE_SHUTTER

define USE_SHUTTER

endif

*platformio.ini
-DUSE_CONFIG_OVERRIDE


//SetOption80 1
18:21:44 CMD: SetOption80 1
18:21:44 MQT: stat/tasmota/RESULT = {"SetOption80":"ON"}

*ShutterMode 1:
//Backlog PulseTime1 0; PulseTime2 0
//Interlock OFF
18:22:01 CMD: Backlog PulseTime1 0; PulseTime2 0; Interlock OFF
18:22:02 MQT: stat/tasmota/RESULT = {"PulseTime1":{"Set":0,"Remaining":0}}
18:22:02 MQT: stat/tasmota/RESULT = {"PulseTime2":{"Set":0,"Remaining":0}}
18:22:02 MQT: stat/tasmota/RESULT = {"Interlock":"OFF","Groups":"1,2"}

*restart ESP
// restart 1
18:26:47 CMD: restart 1
18:26:47 MQT: stat/tasmota/RESULT = {"Restart":"Restarting"}

//
00:00:00 CFG: Loaded from flash at F4, Count 16
00:00:00 SHT: Accuracy digits: 1
00:00:00 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 20000, Opentime 10.0 [s], Closetime 10.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 0
00:00:00 Project tasmota Tasmota Version 7.1.1.1(tasmota)-2_6_1
00:00:00 WIF: Connecting to AP1 Cisco-3G in mode 11N as tasmota-6504...
00:00:05 WIF: Connected
00:00:05 HTP: Web server active on tasmota-6504 with IP address 192.168.1.99
18:34:34 MQT: Attempting connection...
18:34:34 MQT: Connected
18:34:34 MQT: tele/tasmota/LWT = Online (retained)
18:34:34 MQT: cmnd/tasmota/POWER =
18:34:34 MQT: tele/tasmota/INFO1 = {"Module":"Generic","Version":"7.1.1.1(tasmota)","FallbackTopic":"cmnd/DVES_895968_fb/","GroupTopic":"cmnd/tasmotas/"}
18:34:34 MQT: tele/tasmota/INFO2 = {"WebServerMode":"Admin","Hostname":"tasmota-6504","IPAddress":"192.168.1.99"}
18:34:34 MQT: tele/tasmota/INFO3 = {"RestartReason":"Software/System restart"}
18:34:34 MQT: stat/tasmota/RESULT = {"POWER1":"OFF"}
18:34:34 MQT: stat/tasmota/POWER1 = OFF
18:34:34 MQT: stat/tasmota/RESULT = {"POWER2":"OFF"}
18:34:34 MQT: stat/tasmota/POWER2 = OFF
18:34:34 MQT: stat/tasmota/RESULT = {"POWER3":"OFF"}
18:34:34 MQT: stat/tasmota/POWER3 = OFF
18:34:38 MQT: tele/tasmota/STATE = {"Time":"2019-12-06T18:34:38","Uptime":"0T00:00:12","UptimeSec":12,"Heap":29,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":{"STATE":"OFF"},"POWER2":{"STATE":"OFF"},"POWER3":"OFF","Dimmer":10,"Fade":"OFF","Speed":1,"LedTable":"ON","Wifi":{"AP":1,"SSId":"Cisco-3G","BSSId":"58:6D:8F:83:AC:94","Channel":6,"RSSI":82,"LinkCount":1,"Downtime":"0T00:00:06"}}
18:34:38 MQT: tele/tasmota/SENSOR = {"Time":"2019-12-06T18:34:38","COUNTER":{"C1":0},"Shutter1":{"Position":0,"direction":0}}

*TEST ShutterMode (ShutterMode=1):
//ShutterRelay1 1
18:27:29 CMD: ShutterRelay1 1
18:27:29 SHT: Relay 1 is 1
18:27:29 SHT: Accuracy digits: 1
18:27:29 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 20000, Opentime 10.0 [s], Closetime 10.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 0
18:27:29 MQT: stat/tasmota/RESULT = {"ShutterRelay1":1}

//Backlog ShutterOpenDuration 15; ShutterCloseDuration 15; shuttermotordelay 0.25
18:35:46 CMD: Backlog ShutterOpenDuration 15; ShutterCloseDuration 15; shuttermotordelay 0.25
18:35:46 SHT: Accuracy digits: 1
18:35:46 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 150 , Max Way: 30000, Opentime 15.0 [s], Closetime 10.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 0
18:35:46 MQT: stat/tasmota/RESULT = {"ShutterOpenDuration1":"15.0"}
18:35:47 SHT: Accuracy digits: 1
18:35:47 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 30000, Opentime 15.0 [s], Closetime 15.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 0
18:35:47 MQT: stat/tasmota/RESULT = {"ShutterCloseDuration1":"15.0"}
18:35:47 SHT: Accuracy digits: 1
18:35:47 SHT: Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 30000, Opentime 15.0 [s], Closetime 15.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 5
18:35:47 MQT: stat/tasmota/RESULT = {"ShutterMotorDelay1":"0.25"}

22:37:54 MQT: stat/tasmota/RESULT = {"ShutterRelay1":1}

//ShutterOpen
18:36:47 CMD: ShutterOpen
18:36:47 MQT: stat/tasmota/RESULT = {"POWER1":"OFF"}
18:36:47 MQT: stat/tasmota/POWER1 = OFF
18:36:47 SHT: Wait for Motorstop 500
18:36:47 MQT: stat/tasmota/RESULT = {"POWER2":"OFF"}
18:36:47 MQT: stat/tasmota/POWER2 = OFF
18:36:47 MQT: stat/tasmota/RESULT = {"POWER1":"ON"}
18:36:47 MQT: stat/tasmota/POWER1 = ON
18:36:47 MQT: stat/tasmota/RESULT = {"ShutterOpen1":100}
18:36:47 SHT: Shutter 0: Real Pos: 700, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 0.60 [s]
18:36:48 SHT: Shutter 0: Real Pos: 2300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 1.40 [s]
18:36:49 SHT: Shutter 0: Real Pos: 4400, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 2.45 [s]
18:36:50 SHT: Shutter 0: Real Pos: 6300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 3.40 [s]
18:36:51 SHT: Shutter 0: Real Pos: 8300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 4.40 [s]
18:36:52 SHT: Shutter 0: Real Pos: 10300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 5.40 [s]
18:36:53 SHT: Shutter 0: Real Pos: 12300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 6.40 [s]
18:36:54 SHT: Shutter 0: Real Pos: 14300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 7.40 [s]
18:36:55 SHT: Shutter 0: Real Pos: 16300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 8.40 [s]
18:36:56 SHT: Shutter 0: Real Pos: 18300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 9.40 [s]
18:36:57 SHT: Shutter 0: Real Pos: 20300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 10.40 [s]
18:36:58 SHT: Shutter 0: Real Pos: 22300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 11.40 [s]
18:36:59 SHT: Shutter 0: Real Pos: 24300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 12.40 [s]
18:37:00 SHT: Shutter 0: Real Pos: 26300, Target 30000, source: Shutter, start-pos: 0 %, direction: 1, motordelay 5, rtcshutter: 13.40 [s]

@stefanbode

I found the cause of ESP freezing:

  1. For PWM1 and Counter1 - not connected or poor wire connection. Or no set GPIO pin for Counter1 in Module parameters.
  2. ESP freeze time is always different after reboot. Maybe 5 times work well, or freeze right away.

@stefanbode

Tasmota 7.1.2.2
SHUTTER1 - works well.
SHUTTER2 - does not work.

My work log.
13:48:27 CMD: ShutterOpen1
13:48:27 RSL: stat/tasmota/RESULT = {"POWER1":"OFF"}
13:48:27 RSL: stat/tasmota/POWER1 = OFF
13:48:27 SHT: Wait for Motorstop 500
13:48:28 RSL: stat/tasmota/RESULT = {"POWER2":"OFF"}
13:48:28 RSL: stat/tasmota/POWER2 = OFF
13:48:28 RSL: stat/tasmota/RESULT = {"POWER1":"ON"}
13:48:28 RSL: stat/tasmota/POWER1 = ON
13:48:28 RSL: stat/tasmota/RESULT = {"ShutterOpen1":100}

13:49:43 CMD: ShutterOpen2
13:49:43 RSL: stat/tasmota/RESULT = {"POWER1":"OFF"}
13:49:43 RSL: stat/tasmota/POWER1 = OFF
13:49:43 SHT: Wait for Motorstop 500
13:49:43 RSL: stat/tasmota/RESULT = {"POWER2":"OFF"}
13:49:43 RSL: stat/tasmota/POWER2 = OFF
13:49:43 RSL: stat/tasmota/RESULT = {"POWER1":"ON"}
13:49:43 RSL: stat/tasmota/POWER1 = ON
13:49:43 RSL: stat/tasmota/RESULT = {"ShutterOpen2":100}

My settings:
D1: Relay2: A4988#1 PIN: DIR
D2: PWM1: A4988#1 PIN: STP
D3: Relay1i: A4988#1 PIN: EN
D4: Counter1: D2
D5: Relay4: A4988#2 PIN: DIR
D6: PWM2: A4988#2 PIN: STP
D7: Relay3i: A4988#2 PIN: EN
D8: Counter2: D6

* rename user_config_override.h to user_config.h
*
insert it user_config.h

ifndef USE_SHUTTER

define USE_SHUTTER

endif

* in platformio.ini Uncomment by deleting ";"
tasmota
-DUSE_CONFIG_OVERRIDE

*Enable shutter support (SHUTTER1 is enable)
SetOption80 1

*set for ShutterMode 1
Backlog PulseTime1 0; PulseTime2 0
Backlog PulseTime3 0; PulseTime4 0
Interlock OFF

*restart ESP
restart 1

*Test ShutterMode 1 (SHUTTER1 is already on)
ShutterRelay1 1

*Enable SHUTTER2 and test ShutterMode 1
ShutterRelay2 1

*Setting for SHUTTER1 and SHUTTER2
Backlog ShutterOpenDuration1 15; ShutterCloseDuration1 15; shuttermotordelay1 0.25
Backlog ShutterOpenDuration2 15; ShutterCloseDuration2 15; shuttermotordelay2 0.25


shutterfrequency 1500 (1000 by default or all PWM)

*TEST work
ShutterOpen1 or ShutterClose1
ShutterOpen2 or ShutterClose2

I've been testing all day with my shutters. No issues at all. It's performed perfectly for countless open and close cycles.

@RiRilot

I've been testing all day with my shutters. No issues at all. It's performed perfectly for countless open and close cycles.

Can you tell us more?

How much, what, how your shutters are connected 1/2/3/4 ?
How much did you use ESP-01 or Wemos D1 mini or Lolin V3?
How much did you use A4988 or drv8825 or tmc2208?
What voltage did you use for steppers 12V / 24V / 36V ?
What GPIO did you use?
How did you connect your steppers in parallel / sequentially?
What voltage levels did you use MS1 / MS2 / MS3 for each test case?
What configuration of software / hardware settings did you use?
How did you connect the components? Scheme or drawing or photo or printscreen?
How much time did you spend on each option?

Forgive me ... what did you test ... I don’t understand ???

How much, what, how your shutters are connected 1/2/3/4 ?

  • 1 Shutter connected

How much did you use ESP-01 or Wemos D1 mini or Lolin V3?

  • NodeMCU

How much did you use A4988 or drv8825 or tmc2208?

  • TMC2208 in stand alone mode

What voltage did you use for steppers 12V / 24V / 36V ?

  • 12V driver set to Vref 0.7v so around 1.2A current based on my Rsense.

What GPIO did you use?


  • image

How did you connect your steppers in parallel / sequentially?

  • Single stepper

What voltage levels did you use MS1 / MS2 / MS3 for each test case?

  • All open so 1/1 microstepping

What configuration of software / hardware settings did you use?

  • Shutter 0 (Relay:1): Init. Pos: 0 [0 %], Open Vel.: 100 Close Vel.: 100 , Max Way: 70000, Opentime 35.0 [s], Closetime 35.0 [s], CoedffCalc: c0: 300, c1 500, c2: 700, c3: 900, c4: 1000, binmask 3, is inverted 0, shuttermode 1,motordelay 0
    ShutterOpenDuration 35
    ShutterCloseDuration 35

How did you connect the components? Scheme or drawing or photo or printscreen?

  • Schematic below. I have made this as a PCB:
    image

How much time did you spend on each option?
Not sure what you mean.

PCB layout:

image

I will check on this today. It looks like a side effect, but agree, it should work as long as you do not operate both shutters on the same time because of the PWM frequency.

@stefanbode

Tasmota 7.1.2.2
SHUTTER1 - works well.
SHUTTER2 - does not work.

My work log.
13:48:27 CMD: ShutterOpen1
13:48:27 RSL: stat/tasmota/RESULT = {"POWER1":"OFF"}
13:48:27 RSL: stat/tasmota/POWER1 = OFF
13:48:27 SHT: Wait for Motorstop 500
13:48:28 RSL: stat/tasmota/RESULT = {"POWER2":"OFF"}
13:48:28 RSL: stat/tasmota/POWER2 = OFF
13:48:28 RSL: stat/tasmota/RESULT = {"POWER1":"ON"}
13:48:28 RSL: stat/tasmota/POWER1 = ON
13:48:28 RSL: stat/tasmota/RESULT = {"ShutterOpen1":100}

13:49:43 CMD: ShutterOpen2
13:49:43 RSL: stat/tasmota/RESULT = {"POWER1":"OFF"}
13:49:43 RSL: stat/tasmota/POWER1 = OFF
13:49:43 SHT: Wait for Motorstop 500
13:49:43 RSL: stat/tasmota/RESULT = {"POWER2":"OFF"}
13:49:43 RSL: stat/tasmota/POWER2 = OFF
13:49:43 RSL: stat/tasmota/RESULT = {"POWER1":"ON"}
13:49:43 RSL: stat/tasmota/POWER1 = ON
13:49:43 RSL: stat/tasmota/RESULT = {"ShutterOpen2":100}

My settings:
D1: Relay2: A4988#1 PIN: DIR
D2: PWM1: A4988#1 PIN: STP
D3: Relay1i: A4988#1 PIN: EN
D4: Counter1: D2
D5: Relay4: A4988#2 PIN: DIR
D6: PWM2: A4988#2 PIN: STP
D7: Relay3i: A4988#2 PIN: EN
D8: Counter2: D6

* rename user_config_override.h to user_config.h
*
insert it user_config.h

ifndef USE_SHUTTER

define USE_SHUTTER

endif

* in platformio.ini Uncomment by deleting ";"
tasmota
-DUSE_CONFIG_OVERRIDE

*Enable shutter support (SHUTTER1 is enable)
SetOption80 1

*set for ShutterMode 1
Backlog PulseTime1 0; PulseTime2 0
Backlog PulseTime3 0; PulseTime4 0
Interlock OFF

*restart ESP
restart 1

*Test ShutterMode 1 (SHUTTER1 is already on)
ShutterRelay1 1

*Enable SHUTTER2 and test ShutterMode 1
ShutterRelay2 1

*Setting for SHUTTER1 and SHUTTER2
Backlog ShutterOpenDuration1 15; ShutterCloseDuration1 15; shuttermotordelay1 0.25
Backlog ShutterOpenDuration2 15; ShutterCloseDuration2 15; shuttermotordelay2 0.25

shutterfrequency 1500 (1000 by default or all PWM)

*TEST work
ShutterOpen1 or ShutterClose1
ShutterOpen2 or ShutterClose2

I already found an error:
*Test ShutterMode 1 (SHUTTER1 is already on)
ShutterRelay1 1

*Enable SHUTTER2 and test ShutterMode 1
ShutterRelay2 1

ShutterRelay1 1 is ok but Shutterrelay2 3 (because for the shutter2 the starting relay is 3)

If you want to test the shutter on Relay3i and Relay4 you HAVE to define it as Shutter2. Because otherwise, it will not connect to PWM2 and COUNTER2

Agree, it is a bug for more than 1 shutter. Fix will come soon

I must admit I was not aware that the steppers do make so much fun. you can now use the shuttermotordelay[x] to define a soft start/stop. Also shutterfrequency now permanently save the new PWM frequency.

I got the following relyable working: 30V A4988, frequency 10,000 Hz and really soft start stop: shuttermotordelay 4.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsponz picture jsponz  Â·  289Comments

s-hadinger picture s-hadinger  Â·  226Comments

macpit picture macpit  Â·  636Comments

sleezy100 picture sleezy100  Â·  373Comments

h-tro picture h-tro  Â·  112Comments