-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhMicroStepper.h
80 lines (66 loc) · 2 KB
/
hMicroStepper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
microStepper.h - Library for stepper motor driving
Created by San Zamoyski, 30.05.2017, updated in 2020
based on
Created by Clayton P. Webster, February 20th, 2010
Released into the public domain
*/
#ifndef hmicroStepper_h // keep from including twice
#define hmicroStepper_h
#define microsteps 32
#include "Arduino.h"
class hMicroStepper
{
public:
hMicroStepper(int coil1a, int coil1b, int coil2a, int coil2b, int steps);
void disable();
void takestep(boolean invert);
private:
//void setPwmFrequency(int pin, int divisor);
int _coil1a;
int _coil1b;
int _coil2a;
int _coil2b;
int _counter;
boolean _invert;
byte _increment;
//const int microsteps = 16;
//8 steps: uint8_t microstepcurve[] = {0, 50, 98, 142, 180, 212, 236, 250, 255};
//4 steps: uint8_t microstepcurve[] = {0, 98, 180, 236, 255}; //0
//4 steps: uint8_t microstepcurve[] = {255, 157, 75, 19, 0}; //1
byte _steps[microsteps][4] = {
{ 0 , 0 , 1 , 0 },
{ 1 , 205 , 1 , 5 },
{ 1 , 157 , 1 , 19 },
{ 1 , 113 , 1 , 43 },
{ 1 , 75 , 1 , 75 },
{ 1 , 43 , 1 , 113 },
{ 1 , 19 , 1 , 157 },
{ 1 , 5 , 1 , 205 },
{ 1 , 0 , 1 , 255 },
{ 1 , 5 , 0 , 50 },
{ 1 , 19 , 0 , 98 },
{ 1 , 43 , 0 , 142 },
{ 1 , 75 , 0 , 180 },
{ 1 , 113 , 0 , 212 },
{ 1 , 157 , 0 , 236 },
{ 1 , 205 , 0 , 250 },
{ 1 , 255 , 0 , 255 },
{ 0 , 50 , 0 , 250 },
{ 0 , 98 , 0 , 236 },
{ 0 , 142 , 0 , 212 },
{ 0 , 180 , 0 , 180 },
{ 0 , 212 , 0 , 142 },
{ 0 , 236 , 0 , 98 },
{ 0 , 250 , 0 , 50 },
{ 0 , 255 , 0 , 0 },
{ 0 , 250 , 1 , 205 },
{ 0 , 236 , 1 , 157 },
{ 0 , 212 , 1 , 113 },
{ 0 , 180 , 1 , 75 },
{ 0 , 142 , 1 , 43 },
{ 0 , 98 , 1 , 19 },
{ 0 , 50 , 1 , 5 }
};
};
#endif