|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/DRV8825/actions/workflows/arduino-lint.yml) |
| 4 | +[](https://github.com/RobTillaart/DRV8825/actions/workflows/jsoncheck.yml) |
| 5 | +[](https://github.com/RobTillaart/DRV8825/blob/master/LICENSE) |
| 6 | +[](https://github.com/RobTillaart/DRV8825/releases) |
| 7 | + |
| 8 | + |
| 9 | +# DRV8825 |
| 10 | + |
| 11 | +Arduino library for DRV8825 stepper motor driver. |
| 12 | + |
| 13 | + |
| 14 | +## Description |
| 15 | + |
| 16 | +**DRV8825** is a library for DRV8825 stepper motor driver. |
| 17 | + |
| 18 | +**Warning: experimental** |
| 19 | + |
| 20 | +The 8825 stepper motor driver control a stepper motor with |
| 21 | +a direction signal and a step pulse. |
| 22 | + |
| 23 | + |
| 24 | +## Hardware connection |
| 25 | + |
| 26 | +See datasheet. |
| 27 | + |
| 28 | + |
| 29 | +## Interface |
| 30 | + |
| 31 | + |
| 32 | +### Constants |
| 33 | + |
| 34 | +```cpp |
| 35 | +// setDirection |
| 36 | +const uint8_t DRV8825_CLOCK_WISE = 0; // LOW |
| 37 | +const uint8_t DRV8825_COUNTERCLOCK_WISE = 1; // HIGH |
| 38 | +``` |
| 39 | + |
| 40 | +### Constructor |
| 41 | + |
| 42 | +- **DRV8825()** Constructor. |
| 43 | + |
| 44 | + with steps per rotation as parameter. |
| 45 | +This parameter is optional and if set to zero, steps will not be counted. |
| 46 | +- **bool begin(uint8_t dirPin, uint8_t stepPin)** set the direction and step pin. |
| 47 | +Both pins are initially set to LOW. |
| 48 | + |
| 49 | + |
| 50 | +### Direction |
| 51 | + |
| 52 | +To define in which way the motor will turn. |
| 53 | + |
| 54 | +- **void setDirection(uint8_t direction = DRV8825_CLOCK_WISE)** idem. |
| 55 | +- **uint8_t getDirection()** returns DRV8825_CLOCK_WISE (0) or |
| 56 | +DRV8825_COUNTERCLOCK_WISE (1). |
| 57 | + |
| 58 | + |
| 59 | +### Steps |
| 60 | + |
| 61 | +- **void setStepsPerRotation(uint16_t stepsPerRotation)** specifies the steps per rotation for the specific stepper motor. |
| 62 | +If set to zero, the steps will not be counted. |
| 63 | +- **uint16_t getStepsPerRotation()** returns the value set before |
| 64 | +or zero default. |
| 65 | +- **void step()** The workhorse, will give a pulse on the STEP pin. |
| 66 | +- **int32_t resetSteps(int32_t s = 0; )** |
| 67 | +- **int32_t getSteps()** returns the sum of the steps made. |
| 68 | +CW = + and CWW = - so one can go back to a relative position. |
| 69 | + |
| 70 | +The combination getSteps with stepsPerRotation indicates the position of the motor. |
| 71 | + |
| 72 | + |
| 73 | +## Operational |
| 74 | + |
| 75 | +The base functions are: |
| 76 | + |
| 77 | +```cpp |
| 78 | +DRV8825 stpr; |
| 79 | + |
| 80 | +void setup() |
| 81 | +{ |
| 82 | + Serial.begin(115200); |
| 83 | + ... |
| 84 | + stpr.begin(4, 5); // direction + step pin |
| 85 | + stpr.setDirection(DRV8825_CLOCK_WISE); |
| 86 | + ... |
| 87 | +} |
| 88 | + |
| 89 | +void loop() |
| 90 | +{ |
| 91 | +... |
| 92 | + stpr.step; |
| 93 | +... |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +See examples. |
| 98 | + |
| 99 | + |
| 100 | +## Future |
| 101 | + |
| 102 | +Ideas are kept here so they won't get lost. |
| 103 | + |
| 104 | +- redo interface |
| 105 | + - stepCW() + stepCCW(); or just CW(); and CCW(); |
| 106 | + - left() + right(); |
| 107 | + - step(nr of steps) blocking!! |
| 108 | +- add position |
| 109 | + - = steps % steps/rotation |
| 110 | +- base class DIRSTEP |
| 111 | + - 8825 as derived? |
| 112 | + - other too |
0 commit comments