1'''
2Motion - Motion_3axis_linear_interpolation.py with synchronous mode.
3
4-------------------------------------------------------------------------------------
5Please change correct serial number or IP and port number BEFORE you run example code.
6
7For other examples please check:
8 https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
9See README.md file to get detailed usage of this example.
10
11Copyright (c) 2022-2024 WPC Systems Ltd. All rights reserved.
12'''
13
14## Python
15import time
16
17## WPC
18
19from wpcsys import pywpc
20
21def main():
22 ## Get Python driver version
23 print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
24
25 ## Create device handle
26 dev = pywpc.EMotion()
27
28 ## Connect to device
29 try:
30 dev.connect("192.168.1.110") ## Depend on your device
31 except Exception as err:
32 pywpc.printGenericError(err)
33 ## Release device handle
34 dev.close()
35 return
36
37 try:
38 ## Parameters setting
39 port = 0 ## Depend on your device
40 stop_decel = 0
41 timeout = 3 ## second
42
43 ## Linear interpolation parameters
44 axis1 = 0
45 dest_posi1 = 2000
46 axis2 = 1
47 dest_posi2 = 2000
48 axis3 = 2
49 dest_posi3 = 2000
50
51 ## Get firmware model & version
52 driver_info = dev.Sys_getDriverInfo(timeout)
53 print("Model name: " + driver_info[0])
54 print("Firmware version: " + driver_info[-1])
55
56 ## Motion open
57 err = dev.Motion_open(port, timeout)
58 print(f"Motion_open in port {port}, status: {err}")
59
60 ## Motion open configuration file
61 err = dev.Motion_openCfgFile('C:/Users/user/Desktop/3AxisStage_2P.ini')
62 print(f"Motion_openCfgFile, status: {err}")
63
64 ## Motion load configuration file
65 err = dev.Motion_loadCfgFile(timeout)
66 print(f"Motion_loadCfgFile, status: {err}")
67
68 ## Motion configure
69 err = dev.Motion_cfg3AxisLinearInterpo(port, axis1, dest_posi1, axis2, dest_posi2, axis3, dest_posi3, speed=2000, accel=100000, decel=100000, timeout)
70 print(f"Motion_cfg3AxisLinearInterpo in port {port}, status: {err}")
71
72 ## Motion start
73 err = dev.Motion_startLinearInterpo(port, timeout)
74 print(f"Motion_startLinearInterpo in port {port}, status: {err}")
75
76 move_status = 0
77 while move_status == 0:
78 axis1_move_status = dev.Motion_getMoveStatus(port, axis1, timeout)
79 axis2_move_status = dev.Motion_getMoveStatus(port, axis2, timeout)
80 axis3_move_status = dev.Motion_getMoveStatus(port, axis3, timeout)
81 move_status = axis1_move_status & axis2_move_status & axis3_move_status
82 if move_status == 0:
83 print("Moving......")
84 else:
85 print("Move completed")
86
87 ## Motion stop
88 for i in [axis1, axis2, axis3]:
89 err = dev.Motion_stop(port, i, stop_decel, timeout)
90 print(f"Motion_stop axis{i}, status: {err}")
91
92 ## Motion close
93 err = dev.Motion_close(port, timeout)
94 print(f"Motion_close in port {port}, status: {err}")
95 except Exception as err:
96 pywpc.printGenericError(err)
97
98 ## Disconnect device
99 dev.disconnect()
100
101 ## Release device handle
102 dev.close()
103
104 return
105
106if __name__ == '__main__':
107 main()