1'''
2Motion - Motion_2axis_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-2025 WPC Systems Ltd. All rights reserved.
12'''
13
14## WPC
15from wpcsys import pywpc
16
17
18def main():
19 ## Get Python driver version
20 print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
21
22 ## Create device handle
23 dev = pywpc.EMotion()
24
25 ## Connect to device
26 try:
27 dev.connect("192.168.1.110") ## Depend on your device
28 except Exception as err:
29 pywpc.printGenericError(err)
30 ## Release device handle
31 dev.close()
32 return
33
34 try:
35 ## Parameters setting
36 port = 0 ## Depend on your device
37 stop_decel = 0
38 timeout = 3 ## [sec]
39
40 ## Linear interpolation parameters
41 axis1 = 0
42 dest_posi1 = 2000
43 axis2 = 1
44 dest_posi2 = 2000
45
46 ## Get firmware model & version
47 driver_info = dev.Sys_getDriverInfo(timeout)
48 print(f"Model name: {driver_info[0]}, Firmware version: {driver_info[-1]} ")
49
50 ## Motion open
51 err = dev.Motion_open(port, timeout)
52 print(f"Motion_open in port {port}, status: {err}")
53
54 ## Motion open configuration file
55 err = dev.Motion_openCfgFile('C:/Users/user/Desktop/3AxisStage_2P.ini')
56 print(f"Motion_openCfgFile, status: {err}")
57
58 ## Motion load configuration file
59 err = dev.Motion_loadCfgFile(timeout)
60 print(f"Motion_loadCfgFile, status: {err}")
61
62 ## Motion configure
63 err = dev.Motion_cfg2AxisLinearInterpo(port, axis1, dest_posi1, axis2, dest_posi2, speed=2000, accel=100000, decel=100000, timeout=timeout)
64 print(f"Motion_cfg2AxisLinearInterpo in axis{axis1} and {axis2}, status: {err}")
65
66 ## Motion start
67 err = dev.Motion_startLinearInterpo(port, timeout)
68 print(f"Motion_startLinearInterpo in port {port}, status: {err}")
69
70 move_status = 0
71 while move_status == 0:
72 axis1_move_status = dev.Motion_getMoveStatus(port, axis1, timeout)
73 axis2_move_status = dev.Motion_getMoveStatus(port, axis2, timeout)
74 move_status = axis1_move_status & axis2_move_status
75 if move_status == 0:
76 print("Moving......")
77 else:
78 print("Move completed")
79
80 ## Motion stop
81 for i in [axis1, axis2]:
82 err = dev.Motion_stop(port, i, stop_decel, timeout)
83 print(f"Motion_stop in axis{i}, status: {err}")
84
85 ## Motion close
86 err = dev.Motion_close(port, timeout)
87 print(f"Motion_close in port {port}, status: {err}")
88 except Exception as err:
89 pywpc.printGenericError(err)
90
91 finally:
92 ## Disconnect device
93 dev.disconnect()
94
95 ## Release device handle
96 dev.close()
97
98
99if __name__ == '__main__':
100 main()