Repository navigation
Expand file tree
/
Copy pathAPI
More file actions
117 lines (60 loc) · 2.22 KB
/
Copy pathAPI
File metadata and controls
117 lines (60 loc) · 2.22 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
int sminit (int ms1, int ms2, int ms3, int stepdir, int step, int reset, int sleep, int enable, int stepprev)
Initialize stepper motor.
First 8 parameters - pin numbers to which we connected A4988 controller signal (numbered according wiringPi scheme),
the last - steps per evolution of stepper motor.
Returns handler to stepper motor structure, you can use it referring to particular motor
You can connect up to 10 motors (witch controllers) to single Raspberry, signals from controllers can be connected
in parallel to single GPIO pins.
if you don't use some signal for example MS1, MS2, MS3 set it as connected to pin number 99.
void smprec(int moth, int div);
Set controller Microstepping Resolution.
moth - stepper motor handle
res - resolution:
0 - full step
1- half step
2 - quarter step
3 - eighth step
4 - sixteenth step
void smspeed(int moth, int rpm);
Set motor speed.
You can change speed when moror is working.
moth - stepper motor handle
rmp - rotations per minute
int smgetspeed(int moth);
Get motor current motor speed, rotations per minute.
moth - stepper motor handle
void smrun(int moth);
Start rotating the motor.
moth - stepper motor handle
This function is non-blocking, starts the motor and returns.
You are able to change rotation speed, resolution, perform other tasks etc.
To stop the motor, use smstop function.
void smstop(int moth);
Stop rotating of the motor.
moth - stepper motor handle
void smdir(int moth, int dir);
Set rotating direction
dir - direction
0 - clockwise
1 - counterclockwise
void smstep(int moth, int count);
Perform count steps
moth - stepper motor handle
count - number of steps
void smangle(int moth, int full, int fract);
Rotate by angle
moth - stepper motor handle
full - the number of complete 360 degrees turns
frac - the remaining angle
For example, full = 1, frac = 45 is the angle of 405 degrees
void smreset(int moth);
Reset the controller
moth - stepper motor handle
void smsleep(int moth, int state);
Put controller in sleep state.
moth - stepper motor handle
state: 0- sleep, 1 - no sleep
void smenable(int moth, int state);
Enable/disable controller outputs
moth - stepper motor handle
state: 0- enable (normal operation), 1 - disable outputs