The RMP Motion Controller APIs
TouchProbe.cs
using RSI.RapidCode.dotNET; // Import our RapidCode Library.
#if DOXYGEN // RSI internal documentation use only
#endif
class TouchProbe
{
// PDO Method
static void CaptureEachIndexPulseDuringMotion(MotionController controller)
{
// In this example, we have 1 Panasonic Node with the following exchanged Inputs. These constants likely will not be those you use.
const int TOUCH_PROBE_OUTPUT_INDEX = 3; // NetworkOutput #3 - Touch Probe Function
const int TOUCH_PROBE_STATUS_INDEX = 6; // NetworkInput #6 - Touch Probe Status
const int TOUCH_PROBE_VALUE_INDEX = 7; // NetworkInput #7 - Touch Probe pos1 pos value
// 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)
// Our Touch Probe Function should be binary xxxx xxxx xx01 x111 -or- 0x17
// Note if you are making use of Touch Probe 2, some of the above bits will become significant
const ulong TOUCH_PROBE_ON_EACH_Z_PHASE_COMMAND = 0x17;
// Enable
controller.NetworkOutputValueSet(TOUCH_PROBE_OUTPUT_INDEX, TOUCH_PROBE_ON_EACH_Z_PHASE_COMMAND);
// Evaluate
ulong currentStatus = controller.NetworkInputValueGet(TOUCH_PROBE_STATUS_INDEX);
// 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.
// You'll want to initiate some type of motion so you get a new position every Z-phase
// After you see currentStatus Bit 1 has high, you know you have your first (of many) Z-Phase.
ulong lastZPhasePosition = controller.NetworkInputValueGet(TOUCH_PROBE_VALUE_INDEX);
}
// SDO Method
static void CapturePositionOnFallingEdgeOfSI6(MotionController controller, Axis axis)
{
// 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.
const int TOUCH_PROBE_OUTPUT_INDEX = 3; // NetworkOutput #3 - Touch Probe Function
const int TOUCH_PROBE_STATUS_INDEX = 6; // NetworkInput #6 - Touch Probe Status
const int TOUCH_PROBE_2_FALLING_EDGE_VALUE_INDEX = 0x60BD;
const int TOUCH_PROBE_2_FALLING_EDGE_VALUE_SUB_INDEX = 0x0;
const int TOUCH_PROBE_2_FALLING_EDGE_VALUE_SIZE = 0x4;
// 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)
// Our Touch Probe Function should be binary xx1x x001 xxxx xxxx -or- 0x2100
// Note if you are making use of Touch Probe 1, some of the above bits will become significant
const ulong TOUCH_PROBE_2_ON_FIRST_FALLING_EXT2_COMMAND = 0x2100;
// Enable
controller.NetworkOutputValueSet(TOUCH_PROBE_OUTPUT_INDEX, TOUCH_PROBE_2_ON_FIRST_FALLING_EXT2_COMMAND);
// Evaluate
ulong currentStatus = controller.NetworkInputValueGet(TOUCH_PROBE_STATUS_INDEX);
// 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.
// After you've observed currentStatus Bit 10 go high, you know the following value is useful.
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);
}
static void Main(string[] args)
{
// Initialize RapidCode Objects
MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/); // Insert the path location of the RMP.rta (usually the RapidSetup folder)
HelperFunctions.CheckErrors(controller); // [Helper Function] Check that the controller has been initialized correctly.
HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
Axis axis = controller.AxisGet(0);
CaptureEachIndexPulseDuringMotion(controller);
CapturePositionOnFallingEdgeOfSI6(controller, axis);
}
}
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:5694
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5664
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:762
int32_t ServiceChannelRead(int32_t index, int32_t subIndex, int32_t byteCount)
Read a number from the SDO.