node-red-contrib-periph-motor 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/examples/drv2605/demo.json +162 -0
- package/examples/tmc2130/demo.json +114 -0
- package/examples/tmc2208/demo.json +151 -0
- package/examples/tmc2209/demo.json +151 -0
- package/examples/tmc5160/demo.json +26 -0
- package/nodes/drv2605/drv2605.html +79 -0
- package/nodes/drv2605/drv2605.js +79 -0
- package/nodes/tmc2130/tmc2130.html +116 -0
- package/nodes/tmc2130/tmc2130.js +106 -0
- package/nodes/tmc2208/tmc2208.html +92 -0
- package/nodes/tmc2208/tmc2208.js +106 -0
- package/nodes/tmc2209/tmc2209.html +106 -0
- package/nodes/tmc2209/tmc2209.js +119 -0
- package/nodes/tmc5160/tmc5160.html +95 -0
- package/nodes/tmc5160/tmc5160.js +136 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -16,7 +16,12 @@ npm install node-red-contrib-periph-motor
|
|
|
16
16
|
|
|
17
17
|
| Node | Kind | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
+
| `periph-drv2605` | input | Plays haptic effects on an ERM or LRA vibration motor through a DRV2605 haptic driver over I²C (fixed address 0x5A). The EN pin must be high. |
|
|
19
20
|
| `periph-drv8830` | input | Drives a brushed DC motor through a DRV8830 low-voltage H-bridge over I²C, and reports its fault status. The chip regulates the commanded voltage across the motor, so speed stays constant as the supply sags. |
|
|
21
|
+
| `periph-tmc2130` | input | Drives a two-phase bipolar stepper motor through a Trinamic TMC2130 over SPI (Mode 3). The chip has no internal step generator, so the node pulses the STEP and DIR GPIOs; moves are blocking. |
|
|
22
|
+
| `periph-tmc2208` | input | Drives a two-phase bipolar stepper motor through a Trinamic TMC2202 / TMC2208 / TMC2224 over its single-wire UART. The chip's internal step generator moves the motor, so no STEP pulses are needed. |
|
|
23
|
+
| `periph-tmc2209` | input | Drives a two-phase bipolar stepper motor through a Trinamic TMC2209 over its single-wire UART. The chip's internal step generator moves the motor, so no STEP pulses are needed. |
|
|
24
|
+
| `periph-tmc5160` | input | Drives a two-phase bipolar stepper motor through a Trinamic TMC5160 over SPI (Mode 3) or single-wire UART. The chip's internal SixPoint ramp generator moves the motor; positions are in full steps, speeds in full steps/s and accelerations in full steps/s². |
|
|
20
25
|
|
|
21
26
|
## Links
|
|
22
27
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-drv2605-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "DRV2605 Haptic Demo",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Haptic feedback on a vibration motor. The first Inject node sends a button-press effect ({effect: 7}, Soft Bump) on click; the second sends a notification sequence ({sequence: [47, [\"wait\", 200], 47]}, two buzzes 200 ms apart); the third sends {rtp: 0.6} for a constant 60 % buzz and, after 1 s, a Function node sends {stop: true}. Every reply from the periph-drv2605 node is shown in a Debug node. Demonstrates click, notification and constant-buzz haptics."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "inj-click",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"name": "Button press",
|
|
13
|
+
"props": [
|
|
14
|
+
{
|
|
15
|
+
"p": "payload"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"repeat": "",
|
|
19
|
+
"crontab": "",
|
|
20
|
+
"once": false,
|
|
21
|
+
"onceDelay": 0.1,
|
|
22
|
+
"topic": "",
|
|
23
|
+
"payload": "{\"effect\":7}",
|
|
24
|
+
"payloadType": "json",
|
|
25
|
+
"z": "tab-drv2605-demo",
|
|
26
|
+
"x": 150,
|
|
27
|
+
"y": 80,
|
|
28
|
+
"wires": [
|
|
29
|
+
[
|
|
30
|
+
"drv"
|
|
31
|
+
]
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "inj-notify",
|
|
36
|
+
"type": "inject",
|
|
37
|
+
"name": "Notification",
|
|
38
|
+
"props": [
|
|
39
|
+
{
|
|
40
|
+
"p": "payload"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"repeat": "",
|
|
44
|
+
"crontab": "",
|
|
45
|
+
"once": false,
|
|
46
|
+
"onceDelay": 0.1,
|
|
47
|
+
"topic": "",
|
|
48
|
+
"payload": "{\"sequence\":[47,[\"wait\",200],47]}",
|
|
49
|
+
"payloadType": "json",
|
|
50
|
+
"z": "tab-drv2605-demo",
|
|
51
|
+
"x": 150,
|
|
52
|
+
"y": 140,
|
|
53
|
+
"wires": [
|
|
54
|
+
[
|
|
55
|
+
"drv"
|
|
56
|
+
]
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "inj-buzz",
|
|
61
|
+
"type": "inject",
|
|
62
|
+
"name": "Constant buzz",
|
|
63
|
+
"props": [
|
|
64
|
+
{
|
|
65
|
+
"p": "payload"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"repeat": "",
|
|
69
|
+
"crontab": "",
|
|
70
|
+
"once": false,
|
|
71
|
+
"onceDelay": 0.1,
|
|
72
|
+
"topic": "",
|
|
73
|
+
"payload": "{\"rtp\":0.6}",
|
|
74
|
+
"payloadType": "json",
|
|
75
|
+
"z": "tab-drv2605-demo",
|
|
76
|
+
"x": 150,
|
|
77
|
+
"y": 200,
|
|
78
|
+
"wires": [
|
|
79
|
+
[
|
|
80
|
+
"drv",
|
|
81
|
+
"fn-stop"
|
|
82
|
+
]
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "fn-stop",
|
|
87
|
+
"type": "function",
|
|
88
|
+
"name": "stop after 1 s",
|
|
89
|
+
"func": "setTimeout(function() {\n node.send({ payload: { stop: true } });\n}, 1000);\nreturn null;",
|
|
90
|
+
"outputs": 1,
|
|
91
|
+
"noerr": 0,
|
|
92
|
+
"initialize": "",
|
|
93
|
+
"finalize": "",
|
|
94
|
+
"libs": [],
|
|
95
|
+
"z": "tab-drv2605-demo",
|
|
96
|
+
"x": 400,
|
|
97
|
+
"y": 240,
|
|
98
|
+
"wires": [
|
|
99
|
+
[
|
|
100
|
+
"drv"
|
|
101
|
+
]
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "inj-status",
|
|
106
|
+
"type": "inject",
|
|
107
|
+
"name": "Read status",
|
|
108
|
+
"props": [
|
|
109
|
+
{
|
|
110
|
+
"p": "payload"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"repeat": "",
|
|
114
|
+
"crontab": "",
|
|
115
|
+
"once": false,
|
|
116
|
+
"onceDelay": 0.1,
|
|
117
|
+
"topic": "",
|
|
118
|
+
"payload": "{\"status\":true}",
|
|
119
|
+
"payloadType": "json",
|
|
120
|
+
"z": "tab-drv2605-demo",
|
|
121
|
+
"x": 150,
|
|
122
|
+
"y": 280,
|
|
123
|
+
"wires": [
|
|
124
|
+
[
|
|
125
|
+
"drv"
|
|
126
|
+
]
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"id": "drv",
|
|
131
|
+
"type": "periph-drv2605",
|
|
132
|
+
"name": "",
|
|
133
|
+
"bus": "1",
|
|
134
|
+
"actuator": "erm",
|
|
135
|
+
"library": "A",
|
|
136
|
+
"z": "tab-drv2605-demo",
|
|
137
|
+
"x": 640,
|
|
138
|
+
"y": 140,
|
|
139
|
+
"wires": [
|
|
140
|
+
[
|
|
141
|
+
"dbg"
|
|
142
|
+
]
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "dbg",
|
|
147
|
+
"type": "debug",
|
|
148
|
+
"name": "reply",
|
|
149
|
+
"active": true,
|
|
150
|
+
"tosidebar": true,
|
|
151
|
+
"console": false,
|
|
152
|
+
"tostatus": false,
|
|
153
|
+
"complete": "payload",
|
|
154
|
+
"targetType": "msg",
|
|
155
|
+
"statusVal": "",
|
|
156
|
+
"statusType": "auto",
|
|
157
|
+
"z": "tab-drv2605-demo",
|
|
158
|
+
"x": 850,
|
|
159
|
+
"y": 140,
|
|
160
|
+
"wires": []
|
|
161
|
+
}
|
|
162
|
+
]
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-tmc2130-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "TMC2130 Stepper Demo",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "A small linear-axis controller. One Inject node sends {enable: true, current: 0.8, microsteps: 16} once at start. A second Inject node ticks every 5 s into a Function node that alternates {move: 400, speed: 200} and {move: -400, speed: 200}, so the TMC2130 moves forward and backward with software-timed STEP/DIR pulses. A third Inject node polls the driver status every 2 s (any other message); a Function node checks msg.payload.fault and raises a Node-RED warning when it is non-zero and a notice when sg_result drops below 100, while a Debug node shows every reply."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "inj-setup",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"name": "Enable 0.8 A, 16 microsteps",
|
|
13
|
+
"topic": "",
|
|
14
|
+
"payload": "{\"enable\":true,\"current\":0.8,\"microsteps\":16}",
|
|
15
|
+
"payloadType": "json",
|
|
16
|
+
"repeat": "",
|
|
17
|
+
"crontab": "",
|
|
18
|
+
"once": true,
|
|
19
|
+
"onceDelay": 1,
|
|
20
|
+
"z": "tab-tmc2130-demo",
|
|
21
|
+
"x": 190,
|
|
22
|
+
"y": 80,
|
|
23
|
+
"wires": [["tmc2130-node"]]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "inj-cycle",
|
|
27
|
+
"type": "inject",
|
|
28
|
+
"name": "Cycle tick (5 s)",
|
|
29
|
+
"topic": "",
|
|
30
|
+
"payload": "",
|
|
31
|
+
"payloadType": "date",
|
|
32
|
+
"repeat": "5",
|
|
33
|
+
"crontab": "",
|
|
34
|
+
"once": true,
|
|
35
|
+
"onceDelay": 3,
|
|
36
|
+
"z": "tab-tmc2130-demo",
|
|
37
|
+
"x": 140,
|
|
38
|
+
"y": 160,
|
|
39
|
+
"wires": [["fn-cycle"]]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "fn-cycle",
|
|
43
|
+
"type": "function",
|
|
44
|
+
"name": "move 400 / -400",
|
|
45
|
+
"func": "const seq = [{ move: 400, speed: 200 }, { move: -400, speed: 200 }];\nconst i = context.get('step') || 0;\ncontext.set('step', (i + 1) % seq.length);\nmsg.payload = seq[i];\nreturn msg;",
|
|
46
|
+
"outputs": 1,
|
|
47
|
+
"noerr": 0,
|
|
48
|
+
"z": "tab-tmc2130-demo",
|
|
49
|
+
"x": 330,
|
|
50
|
+
"y": 160,
|
|
51
|
+
"wires": [["tmc2130-node"]]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "inj-poll",
|
|
55
|
+
"type": "inject",
|
|
56
|
+
"name": "Poll status (2 s)",
|
|
57
|
+
"topic": "",
|
|
58
|
+
"payload": "",
|
|
59
|
+
"payloadType": "date",
|
|
60
|
+
"repeat": "2",
|
|
61
|
+
"crontab": "",
|
|
62
|
+
"once": true,
|
|
63
|
+
"onceDelay": 2,
|
|
64
|
+
"z": "tab-tmc2130-demo",
|
|
65
|
+
"x": 140,
|
|
66
|
+
"y": 240,
|
|
67
|
+
"wires": [["tmc2130-node"]]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "tmc2130-node",
|
|
71
|
+
"type": "periph-tmc2130",
|
|
72
|
+
"name": "TMC2130",
|
|
73
|
+
"bus": "0",
|
|
74
|
+
"device": "0",
|
|
75
|
+
"speedHz": "1000000",
|
|
76
|
+
"stepGpio": "0:27",
|
|
77
|
+
"dirGpio": "0:22",
|
|
78
|
+
"enGpio": "0:17",
|
|
79
|
+
"rsense": "0.11",
|
|
80
|
+
"current": "0.5",
|
|
81
|
+
"microsteps": "16",
|
|
82
|
+
"speed": "200",
|
|
83
|
+
"z": "tab-tmc2130-demo",
|
|
84
|
+
"x": 560,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": [["fn-fault", "dbg-out"]]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "fn-fault",
|
|
90
|
+
"type": "function",
|
|
91
|
+
"name": "fault / stall check",
|
|
92
|
+
"func": "if (msg.payload.fault) {\n node.warn('TMC2130 fault bitmask: ' + msg.payload.fault);\n return msg;\n}\nif (msg.payload.tstep !== undefined && msg.payload.sg_result < 100) {\n node.warn('TMC2130 SG_RESULT low: ' + msg.payload.sg_result);\n return msg;\n}\nreturn null;",
|
|
93
|
+
"outputs": 1,
|
|
94
|
+
"noerr": 0,
|
|
95
|
+
"z": "tab-tmc2130-demo",
|
|
96
|
+
"x": 780,
|
|
97
|
+
"y": 120,
|
|
98
|
+
"wires": [[]]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "dbg-out",
|
|
102
|
+
"type": "debug",
|
|
103
|
+
"name": "TMC2130 reply",
|
|
104
|
+
"active": true,
|
|
105
|
+
"tosidebar": true,
|
|
106
|
+
"console": false,
|
|
107
|
+
"tostatus": false,
|
|
108
|
+
"complete": "payload",
|
|
109
|
+
"z": "tab-tmc2130-demo",
|
|
110
|
+
"x": 780,
|
|
111
|
+
"y": 200,
|
|
112
|
+
"wires": []
|
|
113
|
+
}
|
|
114
|
+
]
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-tmc2208-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "TMC2208 Stepper Demo",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "A silent desk-fan / camera-slider controller. One Inject node sends {enable: true, current: 0.8, microsteps: 16} once at start. A second Inject node ticks every 5 s into a Function node that cycles the commands {speed: 200}, {speed: -200}, {stop: true}, so the TMC2208's internal step generator turns the motor forward, backward and stops, without any STEP pulses. A third Inject node polls the driver status every 2 s (any other message); a Function node checks msg.payload.fault and raises a Node-RED warning when it is non-zero, while a Debug node shows every reply."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "inj-setup",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"name": "Enable 0.8 A, 16 microsteps",
|
|
13
|
+
"topic": "",
|
|
14
|
+
"payload": "{\"enable\":true,\"current\":0.8,\"microsteps\":16}",
|
|
15
|
+
"payloadType": "json",
|
|
16
|
+
"repeat": "",
|
|
17
|
+
"crontab": "",
|
|
18
|
+
"once": true,
|
|
19
|
+
"onceDelay": 1,
|
|
20
|
+
"z": "tab-tmc2208-demo",
|
|
21
|
+
"x": 190,
|
|
22
|
+
"y": 80,
|
|
23
|
+
"wires": [
|
|
24
|
+
[
|
|
25
|
+
"tmc2208-node"
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "inj-cycle",
|
|
31
|
+
"type": "inject",
|
|
32
|
+
"name": "Cycle tick (5 s)",
|
|
33
|
+
"topic": "",
|
|
34
|
+
"payload": "",
|
|
35
|
+
"payloadType": "date",
|
|
36
|
+
"repeat": "5",
|
|
37
|
+
"crontab": "",
|
|
38
|
+
"once": true,
|
|
39
|
+
"onceDelay": 3,
|
|
40
|
+
"z": "tab-tmc2208-demo",
|
|
41
|
+
"x": 140,
|
|
42
|
+
"y": 160,
|
|
43
|
+
"wires": [
|
|
44
|
+
[
|
|
45
|
+
"fn-cycle"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "fn-cycle",
|
|
51
|
+
"type": "function",
|
|
52
|
+
"name": "speed 200 / -200 / stop",
|
|
53
|
+
"func": "const seq = [{ speed: 200 }, { speed: -200 }, { stop: true }];\nconst i = context.get('step') || 0;\ncontext.set('step', (i + 1) % seq.length);\nmsg.payload = seq[i];\nreturn msg;",
|
|
54
|
+
"outputs": 1,
|
|
55
|
+
"noerr": 0,
|
|
56
|
+
"z": "tab-tmc2208-demo",
|
|
57
|
+
"x": 350,
|
|
58
|
+
"y": 160,
|
|
59
|
+
"wires": [
|
|
60
|
+
[
|
|
61
|
+
"tmc2208-node"
|
|
62
|
+
]
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "inj-poll",
|
|
67
|
+
"type": "inject",
|
|
68
|
+
"name": "Poll status (2 s)",
|
|
69
|
+
"topic": "",
|
|
70
|
+
"payload": "",
|
|
71
|
+
"payloadType": "date",
|
|
72
|
+
"repeat": "2",
|
|
73
|
+
"crontab": "",
|
|
74
|
+
"once": true,
|
|
75
|
+
"onceDelay": 2,
|
|
76
|
+
"z": "tab-tmc2208-demo",
|
|
77
|
+
"x": 140,
|
|
78
|
+
"y": 240,
|
|
79
|
+
"wires": [
|
|
80
|
+
[
|
|
81
|
+
"tmc2208-node"
|
|
82
|
+
]
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "tmc2208-node",
|
|
87
|
+
"type": "periph-tmc2208",
|
|
88
|
+
"z": "tab-tmc2208-demo",
|
|
89
|
+
"name": "TMC2208",
|
|
90
|
+
"port": "/dev/ttyS0",
|
|
91
|
+
"baudrate": "115200",
|
|
92
|
+
"rsense": "0.11",
|
|
93
|
+
"current": "0.5",
|
|
94
|
+
"microsteps": "16",
|
|
95
|
+
"enGpio": "",
|
|
96
|
+
"x": 570,
|
|
97
|
+
"y": 160,
|
|
98
|
+
"wires": [
|
|
99
|
+
[
|
|
100
|
+
"fn-fault",
|
|
101
|
+
"dbg-status"
|
|
102
|
+
]
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "fn-fault",
|
|
107
|
+
"type": "function",
|
|
108
|
+
"name": "warn on fault",
|
|
109
|
+
"func": "if (msg.payload.fault) {\n node.warn('TMC2208 fault bitmask: ' + msg.payload.fault);\n return msg;\n}\nreturn null;",
|
|
110
|
+
"outputs": 1,
|
|
111
|
+
"noerr": 0,
|
|
112
|
+
"z": "tab-tmc2208-demo",
|
|
113
|
+
"x": 790,
|
|
114
|
+
"y": 120,
|
|
115
|
+
"wires": [
|
|
116
|
+
[
|
|
117
|
+
"dbg-fault"
|
|
118
|
+
]
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "dbg-status",
|
|
123
|
+
"type": "debug",
|
|
124
|
+
"name": "Driver status",
|
|
125
|
+
"active": true,
|
|
126
|
+
"tosidebar": true,
|
|
127
|
+
"console": false,
|
|
128
|
+
"tostatus": false,
|
|
129
|
+
"complete": "payload",
|
|
130
|
+
"targetType": "msg",
|
|
131
|
+
"z": "tab-tmc2208-demo",
|
|
132
|
+
"x": 790,
|
|
133
|
+
"y": 200,
|
|
134
|
+
"wires": []
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"id": "dbg-fault",
|
|
138
|
+
"type": "debug",
|
|
139
|
+
"name": "Fault",
|
|
140
|
+
"active": true,
|
|
141
|
+
"tosidebar": true,
|
|
142
|
+
"console": false,
|
|
143
|
+
"tostatus": false,
|
|
144
|
+
"complete": "payload",
|
|
145
|
+
"targetType": "msg",
|
|
146
|
+
"z": "tab-tmc2208-demo",
|
|
147
|
+
"x": 970,
|
|
148
|
+
"y": 120,
|
|
149
|
+
"wires": []
|
|
150
|
+
}
|
|
151
|
+
]
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-tmc2209-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "TMC2209 Stepper Demo",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "A StallGuard4 stall-monitoring slider controller. One Inject node sends {enable: true, current: 0.8, microsteps: 16, stall_threshold: 60} once at start. A second Inject node ticks every 5 s into a Function node that cycles the commands {speed: 200}, {speed: -200}, {stop: true}, so the TMC2209's internal step generator turns the motor forward, backward and stops, without any STEP pulses. A third Inject node polls the driver status every 2 s (any other message); a Function node checks msg.payload.fault and sg_result (below 2 * stall_threshold) and raises a Node-RED warning, while a Debug node shows every reply."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "inj-setup",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"name": "Enable 0.8 A, 16 microsteps, SGTHRS 60",
|
|
13
|
+
"topic": "",
|
|
14
|
+
"payload": "{\"enable\":true,\"current\":0.8,\"microsteps\":16,\"stall_threshold\":60}",
|
|
15
|
+
"payloadType": "json",
|
|
16
|
+
"repeat": "",
|
|
17
|
+
"crontab": "",
|
|
18
|
+
"once": true,
|
|
19
|
+
"onceDelay": 1,
|
|
20
|
+
"z": "tab-tmc2209-demo",
|
|
21
|
+
"x": 190,
|
|
22
|
+
"y": 80,
|
|
23
|
+
"wires": [
|
|
24
|
+
[
|
|
25
|
+
"tmc2209-node"
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "inj-cycle",
|
|
31
|
+
"type": "inject",
|
|
32
|
+
"name": "Cycle tick (5 s)",
|
|
33
|
+
"topic": "",
|
|
34
|
+
"payload": "",
|
|
35
|
+
"payloadType": "date",
|
|
36
|
+
"repeat": "5",
|
|
37
|
+
"crontab": "",
|
|
38
|
+
"once": true,
|
|
39
|
+
"onceDelay": 3,
|
|
40
|
+
"z": "tab-tmc2209-demo",
|
|
41
|
+
"x": 140,
|
|
42
|
+
"y": 160,
|
|
43
|
+
"wires": [
|
|
44
|
+
[
|
|
45
|
+
"fn-cycle"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "fn-cycle",
|
|
51
|
+
"type": "function",
|
|
52
|
+
"name": "speed 200 / -200 / stop",
|
|
53
|
+
"func": "const seq = [{ speed: 200 }, { speed: -200 }, { stop: true }];\nconst i = context.get('step') || 0;\ncontext.set('step', (i + 1) % seq.length);\nmsg.payload = seq[i];\nreturn msg;",
|
|
54
|
+
"outputs": 1,
|
|
55
|
+
"noerr": 0,
|
|
56
|
+
"z": "tab-tmc2209-demo",
|
|
57
|
+
"x": 350,
|
|
58
|
+
"y": 160,
|
|
59
|
+
"wires": [
|
|
60
|
+
[
|
|
61
|
+
"tmc2209-node"
|
|
62
|
+
]
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "inj-poll",
|
|
67
|
+
"type": "inject",
|
|
68
|
+
"name": "Poll status (2 s)",
|
|
69
|
+
"topic": "",
|
|
70
|
+
"payload": "",
|
|
71
|
+
"payloadType": "date",
|
|
72
|
+
"repeat": "2",
|
|
73
|
+
"crontab": "",
|
|
74
|
+
"once": true,
|
|
75
|
+
"onceDelay": 2,
|
|
76
|
+
"z": "tab-tmc2209-demo",
|
|
77
|
+
"x": 140,
|
|
78
|
+
"y": 240,
|
|
79
|
+
"wires": [
|
|
80
|
+
[
|
|
81
|
+
"tmc2209-node"
|
|
82
|
+
]
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "tmc2209-node",
|
|
87
|
+
"type": "periph-tmc2209",
|
|
88
|
+
"z": "tab-tmc2209-demo",
|
|
89
|
+
"name": "TMC2209",
|
|
90
|
+
"port": "/dev/ttyS0",
|
|
91
|
+
"baudrate": "115200",
|
|
92
|
+
"rsense": "0.11",
|
|
93
|
+
"current": "0.5",
|
|
94
|
+
"microsteps": "16",
|
|
95
|
+
"enGpio": "",
|
|
96
|
+
"x": 570,
|
|
97
|
+
"y": 160,
|
|
98
|
+
"wires": [
|
|
99
|
+
[
|
|
100
|
+
"fn-fault",
|
|
101
|
+
"dbg-status"
|
|
102
|
+
]
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "fn-fault",
|
|
107
|
+
"type": "function",
|
|
108
|
+
"name": "warn on fault",
|
|
109
|
+
"func": "if (msg.payload.fault) {\n node.warn('TMC2209 fault bitmask: ' + msg.payload.fault);\n return msg;\n}\nif (msg.payload.speed === undefined && msg.payload.sg_result < 120) {\n node.warn('TMC2209 possible stall, SG_RESULT ' + msg.payload.sg_result);\n return msg;\n}\nreturn null;",
|
|
110
|
+
"outputs": 1,
|
|
111
|
+
"noerr": 0,
|
|
112
|
+
"z": "tab-tmc2209-demo",
|
|
113
|
+
"x": 790,
|
|
114
|
+
"y": 120,
|
|
115
|
+
"wires": [
|
|
116
|
+
[
|
|
117
|
+
"dbg-fault"
|
|
118
|
+
]
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "dbg-status",
|
|
123
|
+
"type": "debug",
|
|
124
|
+
"name": "Driver status",
|
|
125
|
+
"active": true,
|
|
126
|
+
"tosidebar": true,
|
|
127
|
+
"console": false,
|
|
128
|
+
"tostatus": false,
|
|
129
|
+
"complete": "payload",
|
|
130
|
+
"targetType": "msg",
|
|
131
|
+
"z": "tab-tmc2209-demo",
|
|
132
|
+
"x": 790,
|
|
133
|
+
"y": 200,
|
|
134
|
+
"wires": []
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"id": "dbg-fault",
|
|
138
|
+
"type": "debug",
|
|
139
|
+
"name": "Fault",
|
|
140
|
+
"active": true,
|
|
141
|
+
"tosidebar": true,
|
|
142
|
+
"console": false,
|
|
143
|
+
"tostatus": false,
|
|
144
|
+
"complete": "payload",
|
|
145
|
+
"targetType": "msg",
|
|
146
|
+
"z": "tab-tmc2209-demo",
|
|
147
|
+
"x": 970,
|
|
148
|
+
"y": 120,
|
|
149
|
+
"wires": []
|
|
150
|
+
}
|
|
151
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"id": "tab-tmc5160-demo", "type": "tab", "label": "TMC5160 Stepper Demo", "disabled": false,
|
|
3
|
+
"info": "A positioning stage driven by the TMC5160 ramp generator. One Inject node sends {enable: true, current: 1.5, speed: 300, acceleration: 800} once at start. A second Inject node ticks every 5 s into a Function node that alternates {move_to: 400} and {move_to: 0}, so the chip moves forward and back by itself. A third Inject node polls the driver status every 2 s (any other message); a Function node checks msg.payload.fault and raises a Node-RED warning when it is non-zero and a notice when sg_result drops below 100, while a Debug node shows every reply."},
|
|
4
|
+
{"id": "inj-setup", "type": "inject", "name": "Enable 1.5 A, 300 steps/s, 800 steps/s²", "topic": "",
|
|
5
|
+
"payload": "{\"enable\":true,\"current\":1.5,\"speed\":300,\"acceleration\":800}", "payloadType": "json",
|
|
6
|
+
"repeat": "", "crontab": "", "once": true, "onceDelay": 1, "z": "tab-tmc5160-demo", "x": 220, "y": 80,
|
|
7
|
+
"wires": [["tmc5160-node"]]},
|
|
8
|
+
{"id": "inj-cycle", "type": "inject", "name": "Cycle tick (5 s)", "topic": "", "payload": "", "payloadType": "date",
|
|
9
|
+
"repeat": "5", "crontab": "", "once": true, "onceDelay": 3, "z": "tab-tmc5160-demo", "x": 140, "y": 160,
|
|
10
|
+
"wires": [["fn-cycle"]]},
|
|
11
|
+
{"id": "fn-cycle", "type": "function", "name": "move_to 400 / 0",
|
|
12
|
+
"func": "const seq = [{ move_to: 400 }, { move_to: 0 }];\nconst i = context.get('step') || 0;\ncontext.set('step', (i + 1) % seq.length);\nmsg.payload = seq[i];\nreturn msg;",
|
|
13
|
+
"outputs": 1, "noerr": 0, "z": "tab-tmc5160-demo", "x": 330, "y": 160, "wires": [["tmc5160-node"]]},
|
|
14
|
+
{"id": "inj-poll", "type": "inject", "name": "Poll status (2 s)", "topic": "", "payload": "", "payloadType": "date",
|
|
15
|
+
"repeat": "2", "crontab": "", "once": true, "onceDelay": 2, "z": "tab-tmc5160-demo", "x": 140, "y": 240,
|
|
16
|
+
"wires": [["tmc5160-node"]]},
|
|
17
|
+
{"id": "tmc5160-node", "type": "periph-tmc5160", "name": "TMC5160", "bus": "spi", "spiBus": "0", "spiDevice": "0",
|
|
18
|
+
"port": "/dev/ttyS0", "baudrate": "115200", "address": "0", "echo": true, "enGpio": "0:17", "diag0Gpio": "", "diag1Gpio": "",
|
|
19
|
+
"rsense": "0.075", "fclk": "12000000", "current": "1.0", "speed": "200", "acceleration": "400",
|
|
20
|
+
"z": "tab-tmc5160-demo", "x": 560, "y": 160, "wires": [["fn-fault", "dbg-out"]]},
|
|
21
|
+
{"id": "fn-fault", "type": "function", "name": "fault / stall check",
|
|
22
|
+
"func": "if (msg.payload.fault) {\n node.warn('TMC5160 fault bitmask: ' + msg.payload.fault);\n return msg;\n}\nif (msg.payload.tstep !== undefined && msg.payload.sg_result < 100) {\n node.warn('TMC5160 SG_RESULT low: ' + msg.payload.sg_result);\n return msg;\n}\nreturn null;",
|
|
23
|
+
"outputs": 1, "noerr": 0, "z": "tab-tmc5160-demo", "x": 780, "y": 120, "wires": [[]]},
|
|
24
|
+
{"id": "dbg-out", "type": "debug", "name": "TMC5160 reply", "active": true, "tosidebar": true, "console": false,
|
|
25
|
+
"tostatus": false, "complete": "payload", "z": "tab-tmc5160-demo", "x": 780, "y": 200, "wires": []}
|
|
26
|
+
]
|