-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstepperA4988.txt
75 lines (62 loc) · 1.73 KB
/
stepperA4988.txt
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
\ *********************************************************************
\ Controlling a NEMA14 motor with the A4988 driver *
\ Filename: stepperA4988.txt *
\ Date: 26.10.2020 *
\ Updated: 27.10.2020 *
\ File Version: 1.0 *
\ MCU: ARDUINO all models *
\ GNU General Public License *
\ FF Version: 5.0 *
\ Forth Author: Marc PETREMANN *
\ *********************************************************************
\ complete article:
\ https://arduino-forth.com/article/FORTH_FlashForth_stepMotors_driveA4988
\ require pinsDefinitions.txt
\ source: https://github.com/MPETREMANN11/ARDUINO-FORTH/blob/master/pinsDefinitions.txt
-stepper
marker -stepper
decimal
flash
43 constant PORTD
\ 42 constant DDRD --- unused
\ 41 constant PIND --- unused
PORTD %00000100 defPIN: DIRECTION
PORTD %00001000 defPIN: PULSE
ram
\ pulse delay
10 value pulseDelay
\ send one pulse to step motor
: impulse ( ---)
PULSE high
pulseDelay ms
PULSE low
pulseDelay ms
;
\ select Clock Wise rotation
: setCW ( ---)
DIRECTION high
;
\ select Counter Clock Wise rotation
: setCCW ( ---)
DIRECTION low
;
: setDirection ( n ---)
0<
if setCCW
else setCW
then
;
: steps ( n ---)
dup setDirection
abs
for
impulse
next
;
: init.stepper ( ---)
DIRECTION output
PULSE output
;
\ test stepper motor
init.stepper
200 steps