APIs, concepts, guides, and more
TouchProbe.cs
1
58using RSI.RapidCode.dotNET; // Import our RapidCode Library.
59
60#if DOXYGEN // RSI internal documentation use only
61using RSI.RapidCode;
62#endif
63
65class TouchProbe
66 {
68 // PDO Method
69 static void CaptureEachIndexPulseDuringMotion(MotionController controller)
70 {
71 // In this example, we have 1 Panasonic Node with the following exchanged Inputs. These constants likely will not be those you use.
72 const int TOUCH_PROBE_OUTPUT_INDEX = 3; // NetworkOutput #3 - Touch Probe Function
73 const int TOUCH_PROBE_STATUS_INDEX = 6; // NetworkInput #6 - Touch Probe Status
74 const int TOUCH_PROBE_VALUE_INDEX = 7; // NetworkInput #7 - Touch Probe pos1 pos value
75
76 // We want to Enable the Touch Probe (Bit 0 to 1), Set to Continuous Capture (Bit 1 to 1), Set to Z-phase (Bit 2 to 1), and Sample the positive Edge (Bit 4 to 1)
77 // Our Touch Probe Function should be binary xxxx xxxx xx01 x111 -or- 0x17
78 // Note if you are making use of Touch Probe 2, some of the above bits will become significant
79 const ulong TOUCH_PROBE_ON_EACH_Z_PHASE_COMMAND = 0x17;
80
81 // Enable
82 controller.NetworkOutputValueSet(TOUCH_PROBE_OUTPUT_INDEX, TOUCH_PROBE_ON_EACH_Z_PHASE_COMMAND);
83
84 // Evaluate
85 ulong currentStatus = controller.NetworkInputValueGet(TOUCH_PROBE_STATUS_INDEX);
86 // See above Touch Probe Status Section for details. Maybe be useful for your diagnostics and assurance that it is ok to use the next value.
87
88 // You'll want to initiate some type of motion so you get a new position every Z-phase
89
90 // After you see currentStatus Bit 1 has high, you know you have your first (of many) Z-Phase.
91 ulong lastZPhasePosition = controller.NetworkInputValueGet(TOUCH_PROBE_VALUE_INDEX);
92 }
94
96 // SDO Method
97 static void CapturePositionOnFallingEdgeOfSI6(MotionController controller, Axis axis)
98 {
99 // Here we are assuming that you still have Touch Probe Status as PDO entries. They can be set and read using SDO in similiar fashion if that isn't the case.
100 const int TOUCH_PROBE_OUTPUT_INDEX = 3; // NetworkOutput #3 - Touch Probe Function
101 const int TOUCH_PROBE_STATUS_INDEX = 6; // NetworkInput #6 - Touch Probe Status
102
103 const int TOUCH_PROBE_2_FALLING_EDGE_VALUE_INDEX = 0x60BD;
104 const int TOUCH_PROBE_2_FALLING_EDGE_VALUE_SUB_INDEX = 0x0;
105 const int TOUCH_PROBE_2_FALLING_EDGE_VALUE_SIZE = 0x4;
106
107 // We want to Enable the Touch Probe 2 (Bit 8 to 1), Set to First Event (Bit 9 to 0), Set to EXT2 (Bit 10 to 0), and Sample the negative Edge (Bit 13 to 1)
108 // Our Touch Probe Function should be binary xx1x x001 xxxx xxxx -or- 0x2100
109 // Note if you are making use of Touch Probe 1, some of the above bits will become significant
110 const ulong TOUCH_PROBE_2_ON_FIRST_FALLING_EXT2_COMMAND = 0x2100;
111
112 // Enable
113 controller.NetworkOutputValueSet(TOUCH_PROBE_OUTPUT_INDEX, TOUCH_PROBE_2_ON_FIRST_FALLING_EXT2_COMMAND);
114
115 // Evaluate
116 ulong currentStatus = controller.NetworkInputValueGet(TOUCH_PROBE_STATUS_INDEX);
117 // See above Touch Probe Status Section for details. Maybe be useful for your diagnostics and assurance that it is ok to use the next value.
118
119 // After you've observed currentStatus Bit 10 go high, you know the following value is useful.
120 int fallingEdgeExt2 = axis.NetworkNode.ServiceChannelRead(TOUCH_PROBE_2_FALLING_EDGE_VALUE_INDEX, TOUCH_PROBE_2_FALLING_EDGE_VALUE_SUB_INDEX, TOUCH_PROBE_2_FALLING_EDGE_VALUE_SIZE);
121 }
123
125 static void Main(string[] args)
126 {
127 // Initialize RapidCode Objects
128 MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/); // Insert the path location of the RMP.rta (usually the RapidSetup folder)
129 HelperFunctions.CheckErrors(controller); // [Helper Function] Check that the controller has been initialized correctly.
130
131 HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
132 Axis axis = controller.AxisGet(0);
133
134 CaptureEachIndexPulseDuringMotion(controller);
135
136 CapturePositionOnFallingEdgeOfSI6(controller, axis);
137 }
139 }
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Helper Functions for checking logged creation errors, starting the network, etc.
NetworkNode * NetworkNode
Gets the associated NetworkNode object.
Definition rsi.h:5579
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5549
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
uint64_t NetworkInputValueGet(int32_t index)
void NetworkOutputValueSet(int32_t index, uint64_t outputValue)
Sets a PDO output directly.
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:796
int32_t ServiceChannelRead(int32_t index, int32_t subIndex, int32_t byteCount)
Read a 32-bit integer value from the SDO.