1
- # mm-python-api
2
- MachineMotion Python API
3
-
4
1
# How-to Guide: MachineMotion Python SDK
5
2
6
3
<div style =" text-align : center ;" ><img src =" https://s3.amazonaws.com/ventioncms/vention_images/images/000/001/021/large/cover_python_guide.png?1550698357 " width =" 80% " /></div >
@@ -11,7 +8,21 @@ MachineMotion Python API
11
8
12
9
This guide will cover the setup and use of Vention’s MachineMotion™ Python Software Development Kit (SDK). After reading this guide, you will be ready to deploy custom motion and control applications using Vention’s MachineMotion controller. Before you begin, we recommended reading the <a href =" https://www.vention.io/technical_documents/machine_motion_docs/vention_machine_motion_user_guide " target =" _blank " >MachineMotion Quick Start Guide</a > to get familiar with the technology.
13
10
14
- ## Typical System Overview
11
+ ## Overview
12
+
13
+ The MachineMotion python SDK has been designed to allow user applications to execute:
14
+
15
+ > - internally to MachineMotion; or
16
+ > - on an external computer connected to MachineMotion via the USB or Ethernet port.
17
+
18
+ The Python SDK includes the following core features:
19
+
20
+ > - Simplied interface to all MachineMotion functionality
21
+ > - Control of one or multiple MachineMotion from a single program
22
+ > - Direct access to the internal motion controller via gCode
23
+
24
+
25
+ ---
15
26
16
27
Many systems are built by centralizing application-level software on a host computer. The software interacts with various devices (such as robotic devices, sensors, proprietary products, and data acquisition equipment) and delivers the required application behavior (see Figure 1).
17
28
@@ -98,11 +109,11 @@ from _MachineMotion import *
98
109
99
110
# Define a callback to process controller gCode responses
100
111
def templateCallback (data ):
101
- print " Controller gCode responses " + data
112
+ print ( " Controller gCode responses " + data )
102
113
103
114
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
104
115
105
- print " Controller connected"
116
+ print ( " Controller connected" )
106
117
```
107
118
108
119
#### Output
@@ -143,13 +154,13 @@ from _MachineMotion import *
143
154
144
155
# Define a callback to process controller gCode responses (if desired)
145
156
def templateCallback (data ):
146
- print " Controller gCode responses " + data
157
+ print ( " Controller gCode responses " + data )
147
158
148
159
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
149
160
150
161
machine_motion_example = machine_motion_example.configMachineMotionIp(NETWORK_MODE .static, " 192.168.0.2" , " 255.255.255.0" , " 192.168.0.1" )
151
162
152
- print " --> Controller connected & ethernet interface configured (static)"
163
+ print ( " --> Controller connected & ethernet interface configured (static)" )
153
164
```
154
165
155
166
#### Output 1
@@ -170,13 +181,13 @@ from _MachineMotion import *
170
181
171
182
# Define a callback to process controller gCode responses (if desired)
172
183
def templateCallback (data ):
173
- print " Controller gCode responses " + data
184
+ print ( " Controller gCode responses " + data )
174
185
175
186
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
176
187
177
188
machine_motion_example = machine_motion_example.configMachineMotionIp(NETWORK_MODE .dhcp, " " , " " , " " )
178
189
179
- print " --> Controller connected & ethernet interface configured (dhcp)"
190
+ print ( " --> Controller connected & ethernet interface configured (dhcp)" )
180
191
```
181
192
182
193
#### Output 2
@@ -213,14 +224,14 @@ from _MachineMotion import *
213
224
214
225
# Define a callback to process controller gCode responses (if desired)
215
226
def templateCallback (data ):
216
- print " Controller gCode responses " + data
227
+ print ( " Controller gCode responses " + data )
217
228
218
229
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
219
230
220
231
# Configure the axis number one, 8 uSteps and 150 mm / turn for a timing belt
221
232
machine_motion_example = machine_motion_example.configAxis(1 , MICRO_STEPS .ustep_8, MECH_GAIN .timing_belt_150mm_turn)
222
233
223
- print " --> Controller axis 1 configured"
234
+ print ( " --> Controller axis 1 configured" )
224
235
```
225
236
226
237
#### Output
@@ -256,14 +267,14 @@ from _MachineMotion import *
256
267
257
268
# Define a callback to process controller gCode responses (if desired)
258
269
def templateCallback (data ):
259
- print " Controller gCode responses " + data
270
+ print ( " Controller gCode responses " + data )
260
271
261
272
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
262
273
263
274
# Saving a string on the controller
264
275
machine_motion_example = machine_motion_example.saveData(" data_1" , " save_this_string_on_the_controller" )
265
276
266
- print " --> Data sent on controller"
277
+ print ( " --> Data sent on controller" )
267
278
```
268
279
269
280
---
@@ -285,11 +296,11 @@ from _MachineMotion import *
285
296
286
297
# Define a callback to process controller gCode responses (if desired)
287
298
def templateCallback (data ):
288
- print " Controller gCode responses " + data
299
+ print ( " Controller gCode responses " + data )
289
300
290
301
# Define a callback to print the data retrieved using the getData function
291
302
def printGetDataResult (data ):
292
- print " --> Retrieved data = " + data
303
+ print ( " --> Retrieved data = " + data )
293
304
294
305
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
295
306
@@ -328,7 +339,7 @@ from _MachineMotion import *
328
339
329
340
# Define a callback to process controller gCode responses (if desired)
330
341
def templateCallback (data ):
331
- print " Controller gCode responses " + data
342
+ print ( " Controller gCode responses " + data )
332
343
333
344
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
334
345
@@ -337,7 +348,7 @@ machine_motion_example.emitHome(1)
337
348
# Wait for the message to be acknowledged by the motion controller
338
349
while machine_motion_example.isReady() != " true" : pass
339
350
340
- print " --> This line executes after the motion controller has acknowledged receipt of the command."
351
+ print ( " --> This line executes after the motion controller has acknowledged receipt of the command." )
341
352
342
353
```
343
354
@@ -371,7 +382,7 @@ from _MachineMotion import *
371
382
372
383
# Define a callback to process controller gCode responses (if desired)
373
384
def templateCallback (data ):
374
- print " Controller gCode responses " + data
385
+ print ( " Controller gCode responses " + data )
375
386
376
387
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
377
388
@@ -381,7 +392,7 @@ machine_motion_example.emitHome(1)
381
392
while machine_motion_example.isReady() != " true" : pass
382
393
machine_motion_example.waitForMotionCompletion()
383
394
384
- print " --> This line executes after the motion controller has acknowledged the reception of the command."
395
+ print ( " --> This line executes after the motion controller has acknowledged the reception of the command." )
385
396
386
397
```
387
398
@@ -425,14 +436,14 @@ from _MachineMotion import *
425
436
426
437
# Define a callback to process controller gCode responses (if desired)
427
438
def templateCallback (data ):
428
- print " Controller gCode responses " + data
439
+ print ( " Controller gCode responses " + data )
429
440
430
441
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
431
442
432
443
# Send a stop command to the machine (this works even if the machine has not started moving yet)
433
444
machine_motion_example.emitStop()
434
445
435
- print " --> Machine Stopped"
446
+ print ( " --> Machine Stopped" )
436
447
437
448
```
438
449
@@ -464,15 +475,15 @@ from _MachineMotion import *
464
475
465
476
# Define a callback to process controller gCode responses (if desired)
466
477
def templateCallback (data ):
467
- print " Controller gCode responses " + data
478
+ print ( " Controller gCode responses " + data )
468
479
469
480
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
470
481
471
482
# Homing all the axes of the controller sequentially
472
483
machine_motion_example.emitHomeAll()
473
484
machine_motion_example.waitForMotionCompletion()
474
485
475
- print " --> All axes are now at home position."
486
+ print ( " --> All axes are now at home position." )
476
487
477
488
```
478
489
@@ -495,15 +506,15 @@ from _MachineMotion import *
495
506
496
507
# Define a callback to process controller gCode responses (if desired)
497
508
def templateCallback (data ):
498
- print " Controller gCode responses " + data
509
+ print ( " Controller gCode responses " + data )
499
510
500
511
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
501
512
502
513
# Homing axis 1
503
514
machine_motion_example.emitHome(1 )
504
515
machine_motion_example.waitForMotionCompletion()
505
516
506
- print " --> Axis 1 is now at home position."
517
+ print ( " --> Axis 1 is now at home position." )
507
518
508
519
```
509
520
@@ -549,14 +560,14 @@ from _MachineMotion import *
549
560
550
561
# Define a callback to process controller gCode responses (if desired)
551
562
def templateCallback (data ):
552
- print " Controller gCode responses " + data
563
+ print ( " Controller gCode responses " + data )
553
564
554
565
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
555
566
556
567
# Configuring the travel speed to 10,000 mm / min
557
568
machine_motion_example.emitSpeed(10000 )
558
569
559
- print " --> Machine moves are not set to 10 000 mm / min"
570
+ print ( " --> Machine moves are not set to 10 000 mm / min" )
560
571
561
572
```
562
573
@@ -578,14 +589,14 @@ from _MachineMotion import *
578
589
579
590
# Define a callback to process controller gCode responses (if desired)
580
591
def templateCallback (data ):
581
- print " Controller gCode responses " + data
592
+ print ( " Controller gCode responses " + data )
582
593
583
594
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
584
595
585
596
# Configuring the travel speed to 1000 mm / second^2
586
597
machine_motion_example.emitAcceleration(1000 )
587
598
588
- print " --> Machine moves are not set to accelerate @ 1000 mm / second^2"
599
+ print ( " --> Machine moves are not set to accelerate @ 1000 mm / second^2" )
589
600
590
601
```
591
602
@@ -642,7 +653,7 @@ machine_motion_example.waitForMotionCompletion()
642
653
machine_motion_example.emitAbsoluteMove(1 , 100 )
643
654
machine_motion_example.waitForMotionCompletion()
644
655
645
- print " --> Example completed."
656
+ print ( " --> Example completed." )
646
657
647
658
```
648
659
@@ -694,7 +705,7 @@ from _MachineMotion import *
694
705
695
706
# Define a callback to process controller gCode responses (if desired)
696
707
def templateCallback (data ):
697
- print " Controller gCode responses " + data
708
+ print ( " Controller gCode responses " + data )
698
709
699
710
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
700
711
@@ -715,7 +726,7 @@ machine_motion_example.waitForMotionCompletion()
715
726
machine_motion_example.emitRelativeMove(1 , " negative" , 100 )
716
727
machine_motion_example.waitForMotionCompletion()
717
728
718
- print " --> Example completed."
729
+ print ( " --> Example completed." )
719
730
720
731
```
721
732
@@ -764,7 +775,7 @@ from _MachineMotion import *
764
775
765
776
# Define a callback to process controller gCode responses (if desired)
766
777
def templateCallback (data ):
767
- print " Controller gCode responses " + data
778
+ print ( " Controller gCode responses " + data )
768
779
769
780
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
770
781
@@ -782,7 +793,7 @@ machine_motion_example.waitForMotionCompletion()
782
793
machine_motion_example.emitgCode(" G0 X500 Y500 F10000" )
783
794
machine_motion_example.waitForMotionCompletion()
784
795
785
- print " --> Example completed."
796
+ print ( " --> Example completed." )
786
797
787
798
```
788
799
@@ -863,11 +874,11 @@ from _MachineMotion import *
863
874
864
875
# Define a callback to process controller gCode responses (if desired)
865
876
def templateCallback (data ):
866
- print " Controller gCode responses " + data
877
+ print ( " Controller gCode responses " + data )
867
878
868
879
# Define a callback to invoke when a control device is attached to the controller
869
880
def attachControlDeviceCallback (data ):
870
- print " Attach control device callback: " + data
881
+ print ( " Attach control device callback: " + data )
871
882
872
883
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
873
884
@@ -900,11 +911,11 @@ from _MachineMotion import *
900
911
901
912
# Define a callback to process controller gCode responses (if desired)
902
913
def templateCallback (data ):
903
- print " Controller gCode responses " + data
914
+ print ( " Controller gCode responses " + data )
904
915
905
916
# Define a callback to invoke when a control device is attached to the controller
906
917
def attachControlDeviceCallback (data ):
907
- print " Attach control device callback: " + data
918
+ print ( " Attach control device callback: " + data )
908
919
909
920
# Define a callback to invoke when a control device is detached from the controller
910
921
def detachControlDeviceCallback (data ):
@@ -952,19 +963,19 @@ from _MachineMotion import *
952
963
953
964
# Define a callback to process controller gCode responses (if desired)
954
965
def templateCallback (data ):
955
- print " Controller gCode responses " + data
966
+ print ( " Controller gCode responses " + data )
956
967
957
968
# Define a callback to invoke when a control device is attached to the controller
958
969
def attachControlDeviceCallback (data ):
959
- print " Attach control device callback: " + data
970
+ print ( " Attach control device callback: " + data )
960
971
961
972
# Define a callback to invoke when a control device is detached from the controller
962
973
def detachControlDeviceCallback (data ):
963
- print " Detach control device callback: " + data
974
+ print ( " Detach control device callback: " + data )
964
975
965
976
# Define a callback to invoke when a control device is read
966
977
def readControlDeviceCallback (data ):
967
- print " Read control device callback: " + data
978
+ print ( " Read control device callback: " + data )
968
979
969
980
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
970
981
@@ -1009,23 +1020,23 @@ from _MachineMotion import *
1009
1020
1010
1021
# Define a callback to process controller gCode responses (if desired)
1011
1022
def templateCallback (data ):
1012
- print " Controller gCode responses " + data
1023
+ print ( " Controller gCode responses " + data )
1013
1024
1014
1025
# Define a callback to invoke when a control device is attached to the controller
1015
1026
def attachControlDeviceCallback (data ):
1016
- print " Attach control device callback: " + data
1027
+ print ( " Attach control device callback: " + data )
1017
1028
1018
1029
# Define a callback to invoke when a control device is detached from the controller
1019
1030
def detachControlDeviceCallback (data ):
1020
- print " Detach control device callback: " + data
1031
+ print ( " Detach control device callback: " + data )
1021
1032
1022
1033
# Define a callback to invoke when a control device is read
1023
1034
def readControlDeviceCallback (data ):
1024
- print " Read control device callback: " + data
1035
+ print ( " Read control device callback: " + data )
1025
1036
1026
1037
# Define a callback to invoke when a control device is written
1027
1038
def writeControlDeviceCallback (data ):
1028
- print " Write control device callback: " + data
1039
+ print ( " Write control device callback: " + data )
1029
1040
1030
1041
machine_motion_example = MachineMotion(templateCallback, DEFAULT_IP_ADDRESS .usb_windows)
1031
1042
0 commit comments