Stepper Control

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
romicon
New user
Posts: 3
Joined: 17 Sep 2023, 20:57

Stepper Control

#1 Post by romicon » 17 Sep 2023, 21:04

Hello,

i have a Stepper driver 4Ampere with puls and dir pin.
How can I control this amplifier with esp easy.

Best regards

Oliver

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Stepper Control

#2 Post by TD-er » 17 Sep 2023, 22:38

Depends on what you want to do.
Using longpulse_ms, you could already do really basic operations on the stepper motor.
See:
https://espeasy.readthedocs.io/en/lates ... ernal-gpio

For example use this in the rules: (replace 'X' with the GPIO you need for the direction, replace 'Y' with the GPIO for the pulses)

Code: Select all

on stepup do
  gpio,X,1
  longpulse_ms,Y,1,10,10,%eventvalue1%
endon

on stepdown do
  gpio,X,0
  longpulse_ms,Y,1,10,10,%eventvalue1%
endon
Then you can trigger an event like this, to make 1000 steps in the "up" direction:
event,stepup=1000

100 steps down:
event,stepdown=100

romicon
New user
Posts: 3
Joined: 17 Sep 2023, 20:57

Re: Stepper Control

#3 Post by romicon » 18 Sep 2023, 19:22

Hello,
thank you for your Answer.
I would like to control a stepper motor as a suntracker.
In the morning, approach limit switch 1 east. At midday, approach limit switch 2, south. In the evening, approach limit switch 3 west. Sunset back to the east.

Thank you
Oliver

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Stepper Control

#4 Post by TD-er » 18 Sep 2023, 21:11

How many steps does it roughly take between each limit switch?

Also what would be the best approach for your setup?
Divide the time between sunrise and noon in N pulses, or let it run a few pulses every minute (or 5 minutes), so it can overcome some friction to start moving.

romicon
New user
Posts: 3
Joined: 17 Sep 2023, 20:57

Re: Stepper Control

#5 Post by romicon » 19 Sep 2023, 19:44

Hello,
I'll try that out. I want to control via http request
In node red you have all expansion options.



With this command in the Browser or Node red, rotate the stepper left or right .
http://192.168.178.121/control?cmd=event,stepup.
http://192.168.178.121/control?cmd=event,stepdown

rule1
on stepup do
gpio,26,1
longpulse_ms,25,1,10,10,500
endon


rule2
on stepdown do
gpio,26,0
longpulse_ms,25,1,10,10,500
endon


Best regards

Oliver

User avatar
Ath
Normal user
Posts: 3520
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Stepper Control

#6 Post by Ath » 19 Sep 2023, 19:52

For maintenance it is much easier to have those rules in a single rules file, no need to store them in separate files, as they are handled sequentially. The split was once, a long time ago, needed because of the way the rules files were then uploaded, but that has been resolved years ago.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests