Closed Dragontamer333 closed 4 years ago
Do you know how many steps you need to open or close the blinds fully?
On Sun, 31 May 2020 at 5:02 AM Dragontamer333 notifications@github.com wrote:
So I have a general understanding of how stepper motors work with they alternate sets of magnets, and each alternation is a step. So By having an input of a number of steps it will turn that many steps/degrees. How would I use that ideology to make the blinds turn only a percentage of a completely open blinds. Open is 100 % and that equates to 100 steps, but how would it be done with the code to close the blinds to 70%.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/68, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZXPITP6GGI3IENB2ULRUF67ZANCNFSM4NO327SA .
No I do not. Does that matter? I'm not in a situation where I can know the number of steps, but I'm just trying to get the code to work and will test it out later.
To be honest, I have not implemented blinds with Motor control so I am just guessing here.
Try to get the code working (without the Sinric Pro) integration using a library like this https://github.com/Stan-Reifel/FlexyStepper
Open or Close needs different calculations and you need to keep a track of what's the current position in order to calculate the difference and move
Check out these examples. It might help you to get an idea. https://github.com/intive/patronage20-embedded/blob/e6a358c3bb3491f4fc8ed22fdd78ff7f2f7987cd/substations/01_BlindsController/01_BlindsController.ino https://github.com/intive/patronage20-embedded/blob/e6a358c3bb3491f4fc8ed22fdd78ff7f2f7987cd/libraries/BlindsController/blinds.h
Hi Dragontamer! Your question is very interesting, and much more complicated than the first glance thinks.
The first thing you need to know in advance is how many steps the motor has to take for the entire distance. This depends on the installation and must be calculated in advance.
The sketch must know the current position at all times. A stepper motor does not know this. Here you can use limit switches (End-Stops) on one or both sides. As soon as one of these switches is triggered, you will know the exact position (100% or 0%). If the position is unknown (e.g. when booting the ESP) you have to move to one of these positions until the limit switch is triggered (homing).
To implement the motor control I would proceed as follows: 1) Defining variables
currentPosition
(this keeps the current position in number of steps)stepsToDo
2) Implementation of a function doStep
to control the motor.
This function checks if the variable stepsToDo
is not equal to 0.
If stepsToDo
is greater than 0 a step is made in the positive direction and stepsToDo
and currentPosition
is increased by 1.
If stepsToDo
is less than 0 a step is made in the negative direction and stepsToDo
and currentPosition
is decreased by 1.
3) Call doSteps
inside the loop
function
Everytime loop
is called and there are steps to do, one step will be done.
4) SinricPro onSetPosition
and onAdjustPosition
In these functions, you must convert percentages of the variable position
/ positionDelta
into the number of steps required and enter them in the variable stepsToDo
. The rest is then processed by the function doStep
Extension:
As soon as the function doStep
has processed all steps, you can send the event sendPositionEvent
and the current position (as percentage value) to the SinricPro server.
Ok, thanks everyone for your help. I'm waiting on my stepper motors now, so I'll have to test your suggestions out when I get them.
Guys I really need your help I am stuck:( anybody did it ?
So I have a general understanding of how stepper motors work with they alternate sets of magnets, and each alternation is a step. So By having an input of a number of steps it will turn that many steps/degrees. How would I use that ideology to make the blinds turn only a percentage of a completely open blinds. Open is 100 % and that equates to 100 steps, but how would it be done with the code to close the blinds to 70%.