1'''
2Motion - Motion_3axis_helical_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 axis = 0
41 stop_decel = 0
42 timeout = 3 ## second
43
44 ## Helical parameters
45 center_x = 0
46 center_y = 0
47 finish_x = 100
48 finish_y = 100
49 pitch_axis3 = 0
50 pitch_axis4 = 0
51 rotation_num = 0
52 speed = 0
53 cal_timeout = 1000
54 helical_dir_cw = 0
55
56 ## Get firmware model & version
57 driver_info = dev.Sys_getDriverInfo(timeout)
58 print("Model name: " + driver_info[0])
59 print("Firmware version: " + driver_info[-1])
60
61 ## Motion open
62 err = dev.Motion_open(port, timeout)
63 print(f"Motion_open in port {port}, status: {err}")
64
65 ## Motion open configuration file
66 err = dev.Motion_openCfgFile('C:/Users/user/Desktop/3AxisStage_2P.ini')
67 print(f"Motion_openCfgFile, status: {err}")
68
69 ## Motion load configuration file
70 err = dev.Motion_loadCfgFile(timeout)
71 print(f"Motion_loadCfgFile, status: {err}")
72
73 ## Motion configure
74 err = dev.Motion_cfgHelicalInterpo(port, center_x, center_y, finish_x, finish_y, int(False), pitch_axis3, int(False), pitch_axis4, rotation_num,
75 speed, helical_dir_cw, cal_timeout, timeout)
76 print(f"Motion_cfgHelicalInterpo in axis{axis}, status: {err}")
77
78 ## Motion start
79 err = dev.Motion_startHelicalInterpo(port, timeout)
80 print(f"Motion_startHelicalInterpo in axis{axis}, status: {err}")
81
82 move_status = 0
83 while move_status == 0:
84 move_status = dev.Motion_getMoveStatus(port, axis, timeout)
85 if move_status != 0:
86 print(f"Move completed axis {axis}...")
87 return move_status
88
89 ## Motion stop
90 err = dev.Motion_stop(port, axis, stop_decel, timeout)
91 print(f"Motion_stop in axis{axis}, status: {err}")
92
93 ## Motion close
94 err = dev.Motion_close(port, timeout)
95 print(f"Motion_close in port {port}, status: {err}")
96 except Exception as err:
97 pywpc.printGenericError(err)
98
99 ## Disconnect device
100 dev.disconnect()
101
102 ## Release device handle
103 dev.close()
104
105 return
106
107if __name__ == '__main__':
108 main()