5. IO
5.1. Setting the control box digital output
prototype |
|
|---|---|
Description |
Setting the control box digital outputs |
Mandatory parameters |
|
Default Parameters |
|
Return Value |
Error Code Success-0 Failure- errcode |
5.2. Setting Tool Digital Outputs
prototype |
|
|---|---|
Description |
Setting the digital output of the tool |
Mandatory parameters |
|
Default Parameters |
|
Return Value |
Error Code Success-0 Failure- errcode |
5.3. Setting the control box analog output
Prototype |
|
|---|---|
Description |
Setting the control box analog output |
Mandatory parameters |
|
Default parameters |
|
Return Value |
Error Code Success-0 Failure- errcode |
5.4. Setting Tool Analog Outputs
Prototype |
|
|---|---|
Description |
Setup Tool Analog Output |
Mandatory parameters |
|
Default parameters |
|
Return Value |
Error Code Success-0 Failure- errcode |
5.5. Set digital, analog output code example
1from fairino import Robot
2import time
3# Establish a connection with the robot controller and return a robot object if the connection is successful
4robot = Robot.RPC('192.168.58.2')
5status = 1
6smooth = 0
7block = 0
8for i in range(16):
9 robot.SetDO(i, status, smooth, block)
10 time.sleep(0.3)
11status = 0
12for i in range(16):
13 robot.SetDO(i, status, smooth, block)
14 time.sleep(0.3)
15status = 1
16for i in range(2):
17 robot.SetToolDO(i, status, smooth, block)
18 time.sleep(1)
19status = 0
20for i in range(2):
21 robot.SetToolDO(i, status, smooth, block)
22 time.sleep(1)
23for i in range(100):
24 robot.SetAO(0, i, block)
25 time.sleep(0.03)
26for i in range(100):
27 robot.SetToolAO(0, i, block)
28 time.sleep(0.03)
29robot.CloseRPC()
5.6. Getting control box digital inputs
prototype |
|
|---|---|
Description |
Get control box digital inputs |
Mandatory parameters |
|
Default Parameters |
|
Return Value |
|
5.7. Get Tool Digital Inputs
prototype |
|
|---|---|
Description |
Get Tool Digital Inputs |
Mandatory parameters |
|
Default Parameters |
|
Return Value |
Error Code Success-0 Failure- errcode
- |
5.8. Getting Control Box Analog Inputs
Prototype |
|
|---|---|
Description |
Get control box analog inputs |
Mandatory parameters |
|
Default Parameters |
|
Return Value |
|
5.9. Get Tool Analog Inputs
Prototype |
|
|---|---|
Description |
Get end analog input |
Mandatory parameters |
|
Default Parameters |
|
Return Value |
|
5.11. Obtain the DO output status at the end of the robot
Prototype |
|
|---|---|
Description |
Obtain the DO output status at the end of the robot |
Mandatory parameters |
NULL |
Default Parameters |
NULL |
Return Value |
|
5.12. Obtain the DO output status of the robot controller
Prototype |
|
|---|---|
Description |
Obtain the DO output status of the robot controller |
Mandatory parameters |
NULL |
Default Parameters |
NULL |
Return Value |
|
5.13. Get the robot DI, DO status code examples
1from fairino import Robot
2import time
3# Establish a connection with the robot controller and return a robot object if the connection is successful
4robot = Robot.RPC('192.168.58.2')
5block = 0
6error,di = robot.GetDI(0, block)
7print(f"di0: {di}")
8error,tool_di = robot.GetToolDI(1, block)
9print(f"tool_di1: {tool_di}")
10error,ai = robot.GetAI(0, block)
11print(f"ai0: {ai:.2f}")
12error,tool_ai = robot.GetToolAI(0, block)
13print(f"tool_ai0: {tool_ai:.2f}")
14error,button_state = robot.GetAxlePointRecordBtnState()
15print(f"_button_state is: {button_state}")
16error,tool_do_state = robot.GetToolDO()
17print(f"tool DO state: {tool_do_state}")
18error,[do_state_h, do_state_l] = robot.GetDO()
19print(f"DO state hight : {do_state_h}")
20print(f"DO state low : {do_state_l}")
21robot.CloseRPC()
5.14. Waiting for control box digital inputs
prototype |
|
|---|---|
Description |
Waiting for control box digital input |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
5.15. Waiting for control box with multiple digital inputs
prototype |
|
|---|---|
Description |
Waiting for control box with multiple digital inputs |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
5.16. Waiting for tool digital inputs
prototype |
|
|---|---|
Description |
Waiting for end digital input |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
5.17. Waiting for control box analog inputs
prototype |
|
|---|---|
Description |
Waiting for control box analog input |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
5.18. Waiting for tool analog inputs
prototype |
|
|---|---|
Description |
Waiting for end analog input |
Mandatory parameters |
|
Default parameters |
NULL |
Return Value |
Error Code Success-0 Failure- errcode |
5.19. Waiting control box digital, analog input signal code example
1from fairino import Robot
2# Establish a connection with the robot controller and return a robot object if the connection is successful
3robot = Robot.RPC('192.168.58.2')
4status = 1
5smooth = 0
6block = 0
7for i in range(16):
8 robot.SetDO(i, status, smooth, block)
9 time.sleep(0.3)
10status = 0
11for i in range(16):
12 robot.SetDO(i, status, smooth, block)
13 time.sleep(0.3)
14status = 1
15for i in range(2):
16 robot.SetToolDO(i, status, smooth, block)
17 time.sleep(1)
18status = 0
19for i in range(2):
20 robot.SetToolDO(i, status, smooth, block)
21 time.sleep(1)
22for i in range(100):
23 robot.SetAO(0, i, block)
24 time.sleep(0.03)
25for i in range(100):
26 robot.SetToolAO(0, i, block)
27 time.sleep(0.03)
28block = 0
29error,di = robot.GetDI(0, block)
30print(f"di0: {di}")
31error,tool_di = robot.GetToolDI(1, block)
32print(f"tool_di1: {tool_di}")
33error,ai = robot.GetAI(0, block)
34print(f"ai0: {ai:.2f}")
35error,tool_ai = robot.GetToolAI(0, block)
36print(f"tool_ai0: {tool_ai:.2f}")
37error,button_state = robot.GetAxlePointRecordBtnState()
38print(f"_button_state is: {button_state}")
39error,tool_do_state = robot.GetToolDO()
40print(f"tool DO state: {tool_do_state}")
41error,[do_state_h, do_state_l] = robot.GetDO()
42print(f"DO state hight : {do_state_h}")
43print(f"DO state low : {do_state_l}")
44rtn = robot.WaitDI(0, 1, 1000, 1)
45print(f"WaitDI over; rtn is: {rtn}")
46rtn = robot.WaitMultiDI(1, 3, 3, 1000, 1)
47print(f"WaitDI over; rtn is: {rtn}")
48rtn = robot.WaitToolDI(1, 1, 1000, 1)
49print(f"WaitDI over; rtn is: {rtn}")
50rtn = robot.WaitAI(0, 0, 50, 1000, 1)
51print(f"WaitDI over; rtn is: {rtn}")
52rtn = robot.WaitToolAI(0, 0, 50, 1000, 1)
53print(f"WaitDI over; rtn is: {rtn}")
54robot.CloseRPC()
5.20. Set Whether Control Box DO Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether control box DO output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.21. Set Whether Control Box AO Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether control box AO output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.22. Set Whether End Tool DO Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether end tool DO output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.23. Set Whether End Tool AO Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether end tool AO output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.24. Set Whether Extended DO Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether extended DO output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.25. Set Whether Extended AO Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether extended AO output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.26. Set Whether SmartTool Output Resets After Stop/Pause
Added in version python: SDK-v2.0.5
Prototype |
|
|---|---|
Description |
Set whether SmartTool output resets after stop/pause |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure- errcode |
5.27. Code Example for Setting Output Reset After Lua Program Stop/Pause
1from fairino import Robot
2import time
3robot = Robot.RPC('192.168.58.2')
4for i in range(16):
5 robot.SetDO(i, 1, 0, 0)
6 time.sleep(0.2)
7resetFlag = 0
8resumeReloadFlag = 0
9rtn = robot.SetOutputResetCtlBoxDO(resetFlag, resumeReloadFlag)
10robot.SetOutputResetCtlBoxAO(resetFlag, resumeReloadFlag)
11robot.SetOutputResetAxleDO(resetFlag, resumeReloadFlag)
12robot.SetOutputResetAxleAO(resetFlag, resumeReloadFlag)
13robot.SetOutputResetExtDO(resetFlag, resumeReloadFlag)
14robot.SetOutputResetExtAO(resetFlag, resumeReloadFlag)
15robot.SetOutputResetSmartToolDO(resetFlag, resumeReloadFlag)
16robot.ProgramLoad("test.lua")
17robot.ProgramRun()
18time.sleep(2)
19robot.PauseMotion()
20time.sleep(2)
21robot.ResumeMotion()
22time.sleep(2)
23robot.CloseRPC()
24return 0
5.28. Set Configurable CI Port Functions
Prototype |
|
|---|---|
Description |
Set configurable CI port functions |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.29. Get Configurable CI Port Functions of the Control Box
Prototype |
|
|---|---|
Description |
Get configurable CI port functions of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.30. Set Configurable CO Port Functions
Prototype |
|
|---|---|
Description |
Set configurable CO port functions |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.31. Get Configurable CO Port Functions
Prototype |
|
|---|---|
Description |
Get configurable CO port functions |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.32. Set Configurable End-CI Port Functions of the End-Effector
Prototype |
|
|---|---|
Description |
Set configurable End-CI port functions of the end-effector |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.33. Get Configurable End-CI Port Functions of the End-Effector
Prototype |
|
|---|---|
Description |
Get configurable End-CI port functions of the end-effector |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.34. Set Configurable CI Active State of the Control Box
Prototype |
|
|---|---|
Description |
Set configurable CI active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.35. Get Configurable CI Active State of the Control Box
Prototype |
|
|---|---|
Description |
Get configurable CI active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.36. Set Configurable CO Active State of the Control Box
Prototype |
|
|---|---|
Description |
Set configurable CO active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.37. Get Configurable CO Active State of the Control Box
Prototype |
|
|---|---|
Description |
Get configurable CO active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.38. Set Configurable CI Active State of the End-Effector
Prototype |
|
|---|---|
Description |
Set configurable CI active state of the end-effector |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.39. Get Configurable CI Active State of the End-Effector
Prototype |
|
|---|---|
Description |
Get configurable CI active state of the end-effector |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.40. Set Standard DI Active State of the Control Box
Prototype |
|
|---|---|
Description |
Set standard DI active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.41. Get Standard DI Active State of the Control Box
Prototype |
|
|---|---|
Description |
Get standard DI active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.42. Set Standard DO Active State of the Control Box
Prototype |
|
|---|---|
Description |
Set standard DO active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.43. Get Standard DO Active State of the Control Box
Prototype |
|
|---|---|
Description |
Get standard DO active state of the control box |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code Success-0 Failure-errcode |
5.45. Safety Dual-Channel CI Function Configuration
Prototype |
|
|---|---|
Description |
Safety dual-channel CI function configuration |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code, 0-success; non-zero-error |
5.46. Safety Dual-Channel CO Function Configuration
Prototype |
|
|---|---|
Description |
Safety dual-channel CO function configuration |
Required Parameters |
|
Default Parameters |
None |
Return Value |
Error code, 0-success; non-zero-error |
5.47. Safety Dual-Channel IO Function Configuration Code Example
1from fairino import Robot
2import time
3
4def main():
5 # Establish connection with the robot controller
6 robot = Robot.RPC('192.168.58.2')
7 time.sleep(0.5) # Wait for connection and data reception
8
9 print("========== Safety IO Config Test ==========")
10
11 # ========== Set Safety DI Configuration ==========
12 print("\n--- Set Safety DI Configuration ---")
13 rtn = robot.SetSafetyDIConfig(0, 201)
14 print(f"SetSafetyDIConfig(0, 201) rtn is {rtn}")
15
16 rtn = robot.SetSafetyDIConfig(1, 202)
17 print(f"SetSafetyDIConfig(1, 202) rtn is {rtn}")
18
19 rtn = robot.SetSafetyDIConfig(2, 203)
20 print(f"SetSafetyDIConfig(2, 203) rtn is {rtn}")
21
22 rtn = robot.SetSafetyDIConfig(3, 204)
23 print(f"SetSafetyDIConfig(3, 204) rtn is {rtn}")
24
25 # Get DI configuration
26 rtn, getDIConfig = robot.GetDIConfig()
27 print(f"GetDIConfig rtn is {rtn}, value is {getDIConfig[0]} {getDIConfig[1]} {getDIConfig[2]} {getDIConfig[3]} {getDIConfig[4]} {getDIConfig[5]} {getDIConfig[6]} {getDIConfig[7]}")
28
29 # ========== Clear Safety DI Configuration ==========
30 print("\n--- Clear Safety DI Configuration ---")
31 rtn = robot.SetSafetyDIConfig(0, 0)
32 print(f"SetSafetyDIConfig(0, 0) rtn is {rtn}")
33
34 rtn = robot.SetSafetyDIConfig(1, 0)
35 print(f"SetSafetyDIConfig(1, 0) rtn is {rtn}")
36
37 rtn = robot.SetSafetyDIConfig(2, 0)
38 print(f"SetSafetyDIConfig(2, 0) rtn is {rtn}")
39
40 rtn = robot.SetSafetyDIConfig(3, 0)
41 print(f"SetSafetyDIConfig(3, 0) rtn is {rtn}")
42
43 # Get DI configuration to verify clearance
44 rtn, getDIConfig = robot.GetDIConfig()
45 print(f"GetDIConfig rtn is {rtn}, value is {getDIConfig[0]} {getDIConfig[1]} {getDIConfig[2]} {getDIConfig[3]} {getDIConfig[4]} {getDIConfig[5]} {getDIConfig[6]} {getDIConfig[7]}")
46
47 # ========== Set Safety DO Configuration ==========
48 print("\n--- Set Safety DO Configuration ---")
49 rtn = robot.SetSafetyDOConfig(0, 204)
50 print(f"SetSafetyDOConfig(0, 204) rtn is {rtn}")
51
52 rtn = robot.SetSafetyDOConfig(1, 205)
53 print(f"SetSafetyDOConfig(1, 205) rtn is {rtn}")
54
55 rtn = robot.SetSafetyDOConfig(2, 206)
56 print(f"SetSafetyDOConfig(2, 206) rtn is {rtn}")
57
58 rtn = robot.SetSafetyDOConfig(3, 207)
59 print(f"SetSafetyDOConfig(3, 207) rtn is {rtn}")
60
61 # Get DO configuration
62 rtn, getDOConfig = robot.GetDOConfig()
63 print(f"GetDOConfig rtn is {rtn}, value is {getDOConfig[0]} {getDOConfig[1]} {getDOConfig[2]} {getDOConfig[3]} {getDOConfig[4]} {getDOConfig[5]} {getDOConfig[6]} {getDOConfig[7]}")
64
65 # ========== Clear Safety DO Configuration ==========
66 print("\n--- Clear Safety DO Configuration ---")
67 rtn = robot.SetSafetyDOConfig(0, 0)
68 print(f"SetSafetyDOConfig(0, 0) rtn is {rtn}")
69
70 rtn = robot.SetSafetyDOConfig(1, 0)
71 print(f"SetSafetyDOConfig(1, 0) rtn is {rtn}")
72
73 rtn = robot.SetSafetyDOConfig(2, 0)
74 print(f"SetSafetyDOConfig(2, 0) rtn is {rtn}")
75
76 rtn = robot.SetSafetyDOConfig(3, 0)
77 print(f"SetSafetyDOConfig(3, 0) rtn is {rtn}")
78
79 # Get DO configuration to verify clearance
80 rtn, getDOConfig = robot.GetDOConfig()
81 print(f"GetDOConfig rtn is {rtn}, value is {getDOConfig[0]} {getDOConfig[1]} {getDOConfig[2]} {getDOConfig[3]} {getDOConfig[4]} {getDOConfig[5]} {getDOConfig[6]} {getDOConfig[7]}")
82
83 time.sleep(2)
84
85 # Close connection
86 robot.CloseRPC()
87 time.sleep(1)
88
89 print("\n========== Test Complete ==========")
90
91
92if __name__ == "__main__":
93 main()