easydriver stepper driver
Posted: 26 Feb 2021, 12:09
Hi,
anyone used easydriver with espeasy?
TIA?
anyone used easydriver with espeasy?
TIA?
Have fun with controlling everything!
https://www.letscontrolit.com/forum/
yes, this one. WIth one advantage: also works with 3V3. See specs.TD-er wrote: ↑26 Feb 2021, 12:22 I think you need to give slightly more information here
No idea what "easydriver" is.
Any link?
Is it this board? https://www.sparkfun.com/products/12779
Code: Select all
defs:
// variables will change:
long previousmotorMicros = 0; // will store last time motor was updated
// the follwoing variable is a long because the time, measured in milliseconds
// will quickly become a larger number than can be stored in an int.
long motorinterval = 120; // microseconds high low step original 180
long previousldrMicros = 0;
long ldrreadinterval = 10000000; // 10 seconds
long currentMicros;
loop:
if (motor_mode == 'R') {
digitalWrite(MotorEnable, LOW);
digitalWrite(MotorSleep, HIGH);
if (dir != prevdir) {
prevdir = dir;
delay(1500); // pause to change direction run
}
if (currentMicros - previousmotorMicros > motorinterval) {
previousmotorMicros = currentMicros;
if (stepp == LOW)
stepp = HIGH;
else
stepp = LOW;
digitalWrite(MotorDir, dir);
digitalWrite(MotorStep, stepp);
}
}
if (motor_mode == 'S') {
digitalWrite(MotorEnable, HIGH);
digitalWrite(MotorSleep, LOW);
}
}
any hint?TD-er wrote: ↑26 Feb 2021, 12:22 I think you need to give slightly more information here
No idea what "easydriver" is.
Any link?
Is it this board? https://www.sparkfun.com/products/12779
this code is the motor driving of what i have working on a arduino nano for curtains control. now i want to migrate it to espeasy to integrate it with HA. simple.TD-er wrote: ↑01 Mar 2021, 09:29 Where does this code come from? It is not part of the ESPEasy code.
Judging the code you posted, you need 4 GPIO pins for it, and I don't know any example plugin which you can easily modify for this.
The Wemos motorshield does use I2C to communicate.
Also the code is using "delay(1500)", which is not a really good idea to use in ESPEasy plugin code, so I guess it is not as simple as cut-and-paste somewhere in the code to get it to work.
Maybe on the playground there is a plugin already resembling what's needed for this?
Is the wemos motorshield suitble for steppers?TD-er wrote: ↑01 Mar 2021, 09:29 Where does this code come from? It is not part of the ESPEasy code.
Judging the code you posted, you need 4 GPIO pins for it, and I don't know any example plugin which you can easily modify for this.
The Wemos motorshield does use I2C to communicate.
Also the code is using "delay(1500)", which is not a really good idea to use in ESPEasy plugin code, so I guess it is not as simple as cut-and-paste somewhere in the code to get it to work.
Maybe on the playground there is a plugin already resembling what's needed for this?
Commands are documented in the RTD documentation: https://espeasy.readthedocs.io/en/lates ... #p048-page
Hya,TD-er wrote: ↑03 Mar 2021, 14:41 Maybe the (recently added) loop timer can be of any help here?
https://espeasy.readthedocs.io/en/lates ... oop-timers.
For performance reasons I would not try to set the loop timer to a very short interval.
So maybe in the rules when handling this timer you may determine the number of steps needed and call for a command to make those steps (e.g. not trying to loop every 10 msec for example to make 1 step)
Code: Select all
On System#Boot do //When the ESP boots, do
looptimerset_ms,1,1 // Start loop timer 2, 2500 msec interval
endon
On Rules#Timer=1 do
MotorShieldCMD,Stepper,1,Forward,20,double
loopTimerSet_ms,1,1
timerResume,1
endon
Code: Select all
On System#Boot do //When the ESP boots, do
looptimerset_ms,1,10 // Start loop timer 2, 10 msec interval
endon
On Rules#Timer=1 do
if %v1%=1
MotorShieldCMD,Stepper,1,Forward,50,single
endif
if %v1%=0
MotorShieldCMD,Stepper,1,Backward,50,single
endif
endon
on OPEN#status do
if %eventstatus%=0
let 1,1
else
let 1,0
endif
endon
Code: Select all
on OPEN#status do
if %eventstatus%=0
let 1,1
else
let 1,0
endif
endon
Code: Select all
On System#Boot do //When the ESP boots, do
let,1,0
let,2,0
asyncevent,loop // Trigger the loop
endon
on loop do
if %v1%=0
MotorShieldCMD,Stepper,1,Forward,100,single
endif
if %v1%=1
MotorShieldCMD,Stepper,1,Backward,100,single
endif
asyncevent,loop
endon
on OPEN#status do
if %eventvalue%=1
let,1,1
asyncevent,loop
else
let,1,0
asyncevent,loop
endif
endon
He had that, see:TD-er wrote: ↑18 Mar 2021, 22:43 Why don't you use the loop timer?
See: https://espeasy.readthedocs.io/en/lates ... =looptimer
but I think the 10 msec interval just was a bit too much for an ESP,pw444 wrote: ↑17 Mar 2021, 20:00 I have now the follwing:
Code: Select all
On System#Boot do //When the ESP boots, do looptimerset_ms,1,10 // Start loop timer 2, 10 msec interval endon ...(partially removed, Ath)
and how?add a new command to the motorshield to set a continous speed and thus calling it from the PLUGIN_TEN_PER_SECOND or maybe even PLUGIN_FIFTY_PER_SECOND.
i'm using asyncevent as from example. but as docs, asyncevent goes to a quee.on loop do
if %v1%=0
MotorShieldCMD,Stepper,1,Forward,100,single
endif
if %v1%=1
MotorShieldCMD,Stepper,1,Backward,100,single
endif
asyncevent,loop
endon
the log, showing the intervals.
Code: Select all
136357: Stepper1->Forward Steps: 100 SINGLE
136717: ACT : asyncevent,loop
136731: EVENT: loop
136746: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
136758: Stepper1->Forward Steps: 100 SINGLE
137122: ACT : asyncevent,loop
137140: EVENT: loop
137155: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
137167: Stepper1->Forward Steps: 100 SINGLE
137558: ACT : asyncevent,loop
137573: EVENT: loop
137588: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
137600: Stepper1->Forward Steps: 100 SINGLE
137959: ACT : asyncevent,loop
137973: EVENT: loop
137988: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
138000: Stepper1->Forward Steps: 100 SINGLE
138394: ACT : asyncevent,loop
138410: EVENT: loop
138425: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
138438: Stepper1->Forward Steps: 100 SINGLE
138820: ACT : asyncevent,loop
138840: EVENT: loop
138855: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
138867: Stepper1->Forward Steps: 100 SINGLE
139249: ACT : asyncevent,loop
139263: EVENT: loop
139278: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
139290: Stepper1->Forward Steps: 100 SINGLE
139673: ACT : asyncevent,loop
139689: EVENT: loop
139703: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
139715: Stepper1->Forward Steps: 100 SINGLE
140101: ACT : asyncevent,loop
140118: EVENT: loop
140133: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
140145: Stepper1->Forward Steps: 100 SINGLE
140526: ACT : asyncevent,loop
140540: EVENT: loop
140555: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
140567: Stepper1->Forward Steps: 100 SINGLE
140934: ACT : asyncevent,loop
140947: EVENT: loop
140984: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
141000: Stepper1->Forward Steps: 100 SINGLE
141361: ACT : asyncevent,loop
141374: EVENT: loop
141389: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
141401: Stepper1->Forward Steps: 100 SINGLE
141790: ACT : asyncevent,loop
141809: EVENT: loop
141824: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
141837: Stepper1->Forward Steps: 100 SINGLE
142195: ACT : asyncevent,loop
142209: EVENT: loop
142225: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
142237: Stepper1->Forward Steps: 100 SINGLE
142624: ACT : asyncevent,loop
142640: EVENT: loop
142655: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
142667: Stepper1->Forward Steps: 100 SINGLE
143031: ACT : asyncevent,loop
143045: EVENT: loop
143061: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
143073: Stepper1->Forward Steps: 100 SINGLE
143458: ACT : asyncevent,loop
143472: EVENT: loop
143490: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
143502: Stepper1->Forward Steps: 100 SINGLE
143882: ACT : asyncevent,loop
143896: EVENT: loop
143911: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
143926: Stepper1->Forward Steps: 100 SINGLE
144308: ACT : asyncevent,loop
144321: EVENT: loop
144335: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
144349: Stepper1->Forward Steps: 100 SINGLE
144732: ACT : asyncevent,loop
144750: EVENT: loop
144765: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
144779: Stepper1->Forward Steps: 100 SINGLE
145159: ACT : asyncevent,loop
145171: EVENT: loop
145188: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
145200: Stepper1->Forward Steps: 100 SINGLE
145582: ACT : asyncevent,loop
145598: EVENT: loop
145614: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
145626: Stepper1->Forward Steps: 100 SINGLE
146009: ACT : asyncevent,loop
146022: EVENT: loop
146037: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
146049: Stepper1->Forward Steps: 100 SINGLE
146433: ACT : asyncevent,loop
146447: EVENT: loop
146462: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
146474: Stepper1->Forward Steps: 100 SINGLE
146857: ACT : asyncevent,loop
146871: EVENT: loop
146886: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
146898: Stepper1->Forward Steps: 100 SINGLE
147281: ACT : asyncevent,loop
147296: EVENT: loop
147314: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
147327: Stepper1->Forward Steps: 100 SINGLE
147712: ACT : asyncevent,loop
147726: EVENT: loop
147744: ACT : MotorShieldCMD,Stepper,1,Forward,100,single
147758: Stepper1->Forward Steps: 100 SINGLE
but I think the 10 msec interval just was a bit too much for an ESP,
or else I don't know why that solution was abandoned