|
1 | | -# MWC_Stepper |
2 | | - Arduino Step Motor Driver Library |
| 1 | +# MWC_Stepper Step Driver |
| 2 | + Arduino Step Motor Driver Library. For more information about that library usage, go to my blog page [mertwhocodes-step-driver]( http://mertwhocodes.com/index.php/en/2020/05/08/stepper-motor-driver-with-arduino/) |
| 3 | + |
| 4 | + |
| 5 | +# **Description** |
| 6 | +This is the library for drive step motor for Arduino. It supports DC motors & Stepper motors with microstepping. |
| 7 | +A4988, DRV8825, DRV8834, DRV8880,TB6600... and generic two-pin stepper motor driver library. Features: |
| 8 | +- Constant speed mode(RPM) |
| 9 | +- Microstepping |
| 10 | +# **Connection:** |
| 11 | + |
| 12 | +# **Wiring** |
| 13 | +- VCC 9-42 **–** VDC |
| 14 | +- GND **-** Power supply ground |
| 15 | +- ENA- **-** Arduino GND |
| 16 | +- ENA+ **-** Arduino Pin 5 |
| 17 | +- DIR- **-** Arduino GND |
| 18 | +- DIR+ **-** Arduino Pin 4 |
| 19 | +- PUL- **-** Arduino GND |
| 20 | +- PUL+ **-** Arduino Pin 3 |
| 21 | +- A-, A+ **-** Coil 1 stepper motor |
| 22 | +- B-, B+ **-** Coil 2 stepper motor |
| 23 | +# **Code** |
| 24 | +See basic two direction stepping 1:8 1 tour for each direction example. |
| 25 | +```c |
| 26 | +/* |
| 27 | + Name: step_drive.ino |
| 28 | + |
| 29 | + Author: mertwhocodes |
| 30 | +*/ |
| 31 | +#include<mwc_stepper.h> |
| 32 | + |
| 33 | +#define EN_PIN 3 |
| 34 | +#define DIR_PIN 2 |
| 35 | +#define STEP_PIN 5 |
| 36 | + |
| 37 | +#define RPM 50 |
| 38 | +#define RPM1 50 |
| 39 | + |
| 40 | +#define PULSE 1600 |
| 41 | + |
| 42 | +#define ClOCKWISE 1 |
| 43 | +#define OTHERWISE 0 |
| 44 | + |
| 45 | +MWCSTEPPER nema23(EN_PIN, DIR_PIN, STEP_PIN); |
| 46 | + |
| 47 | +void setup() { |
| 48 | + |
| 49 | + nema23.init(); |
| 50 | + |
| 51 | + //nema23.active(DEACTIVE); |
| 52 | +} |
| 53 | + |
| 54 | +void loop() { |
| 55 | + nema23.set(ClOCKWISE, RPM, PULSE); |
| 56 | + |
| 57 | + for (size_t i = 0; i < 1600; i++) |
| 58 | + { |
| 59 | + nema23.run(); |
| 60 | + } |
| 61 | + |
| 62 | + delay(1000); |
| 63 | + |
| 64 | + nema23.set(OTHERWISE, RPM1, PULSE); |
| 65 | + |
| 66 | + for (size_t i = 0; i < 1600; i++) |
| 67 | + { |
| 68 | + //nema23.run(); |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +``` |
0 commit comments