APIs, concepts, guides, and more
touch-probe.cs
/* This sample demonstrates how to use Touch Probe with Panasonic Drives.
Touch Probes allow capturing axis positions when triggered by external signals or Z-phase events.
Things you need to know for Panasonics:
1. There are two Touch Probes available.
2. They default to SI5 (EXT1) & SI6 (EXT2) and are configurable.
3. Do not try to capture on both the Positive and Negative Edge of a Signal on the same Touch Probe.
4. Do not configure to the Falling Edge of the Z-phase.
5. If you change configuration of a Touch Probe after you have enabled it, you will need to disable it for changes to take place.
6. Depending on your Configuration you may have to use PDO or SDO calls. By default, Touch Probe 1 is available as a cyclically exchanged value.
TOUCH PROBE FUNCTION (0x60B8 Sub 0 Size 2)
Bit 0 - Enable(1) Touch Probe 1
Bit 1 - First Event(0), Continuous(1) [Continuous will overwrite old values on each new signal]
Bit 2 - Trigger on EXT1(0), Z-phase(1)
Bit 4 - Sample Positive Edge(1) (Store position to 0x60BA Sub 0 Size 4)
Bit 5 - Sample Negative Edge(1) (Store position to 0x60BB Sub 0 Size 4)
Bit 8 - Enable(1) Touch Probe 2
Bit 9 - First Event(0), Continuous(1) [Continuous will overwrite old values on each new signal]
Bit 10 - Trigger on EXT2(0), Z-phase(1)
Bit 12 - Sample Positive Edge(1) (Store position to 0x60BC Sub 0 Size 4)
Bit 13 - Sample Negative Edge(1) (Store position to 0x60BD Sub 0 Size 4)
TOUCH PROBE STATUS (0x60B9 Sub 0 Size 2)
Bit 0 - Touch Probe 1 Enabled(1)
Bit 1 - Positive Edge Value Stored(1)
Bit 2 - Negative Edge Value Stored(1)
Bit 8 - Touch Probe 2 Enabled(1)
Bit 9 - Positive Edge Value Stored(1)
Bit 10 - Negative Edge Value Stored(1)
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Touch Probe: Panasonic");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
//Helpers.NetworkStart(controller);
// check is network is started
if (controller.NetworkStateGet() != RSINetworkState.RSINetworkStateOPERATIONAL)
{
Console.WriteLine("Network not started. Please start it before running this app.");
return;
}
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
Console.WriteLine("\n--- Method 1: Capture Each Index Pulse During Motion ---");
CaptureEachIndexPulseDuringMotion(controller);
Console.WriteLine("\n--- Method 2: Capture Position on Falling Edge of SI6 ---");
CapturePositionOnFallingEdgeOfSI6(controller, axis);
Console.WriteLine("\nTouch probe examples complete.");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
// PDO Method - captures position on each Z-phase (index pulse) during motion
void CaptureEachIndexPulseDuringMotion(MotionController controller)
{
// these constants likely will not be those you use - adjust based on your network configuration
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
// enable touch probe:
// bit 0 = 1 (enable touch probe 1)
// bit 1 = 1 (continuous capture - overwrites old values)
// bit 2 = 1 (trigger on z-phase)
// bit 4 = 1 (sample positive edge)
// binary: xxxx xxxx xx01 x111 = 0x17
const ulong TOUCH_PROBE_ON_EACH_Z_PHASE_COMMAND = 0x17;
// enable touch probe
controller.NetworkOutputValueSet(TOUCH_PROBE_OUTPUT_INDEX, TOUCH_PROBE_ON_EACH_Z_PHASE_COMMAND);
// evaluate status
ulong currentStatus = controller.NetworkInputValueGet(TOUCH_PROBE_STATUS_INDEX);
Console.WriteLine($"Touch Probe Status: 0x{currentStatus:X}");
// initiate motion so you get a new position every z-phase
// (your motion code here)
// after currentStatus bit 1 goes high, you have your first (of many) z-phase
ulong lastZPhasePosition = controller.NetworkInputValueGet(TOUCH_PROBE_VALUE_INDEX);
Console.WriteLine($"Last Z-Phase Position: {lastZPhasePosition}");
}
// SDO Method - captures position on falling edge of external input SI6 (EXT2)
void CapturePositionOnFallingEdgeOfSI6(MotionController controller, Axis axis)
{
// assuming touch probe status is still available as pdo entries
const int TOUCH_PROBE_OUTPUT_INDEX = 3; // networkoutput #3 - touch probe function
const int TOUCH_PROBE_STATUS_INDEX = 6; // networkinput #6 - touch probe status
// sdo addresses for touch probe 2 falling edge value
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;
// enable touch probe 2:
// bit 8 = 1 (enable touch probe 2)
// bit 9 = 0 (first event only)
// bit 10 = 0 (trigger on ext2)
// bit 13 = 1 (sample negative/falling edge)
// binary: xx1x x001 xxxx xxxx = 0x2100
const ulong TOUCH_PROBE_2_ON_FIRST_FALLING_EXT2_COMMAND = 0x2100;
// enable touch probe 2
controller.NetworkOutputValueSet(TOUCH_PROBE_OUTPUT_INDEX, TOUCH_PROBE_2_ON_FIRST_FALLING_EXT2_COMMAND);
// evaluate status
ulong currentStatus = controller.NetworkInputValueGet(TOUCH_PROBE_STATUS_INDEX);
Console.WriteLine($"Touch Probe 2 Status: 0x{currentStatus:X}");
// after currentStatus bit 10 goes high, 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);
Console.WriteLine($"Falling Edge EXT2 Position: {fallingEdgeExt2}");
}
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
NetworkNode * NetworkNode
Gets the associated NetworkNode object.
Definition rsi.h:5892
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5862
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
RSINetworkState NetworkStateGet()
static MotionController * Get()
Get an already running RMP EtherCAT controller.
uint64_t NetworkInputValueGet(int32_t index)
void NetworkOutputValueSet(int32_t index, uint64_t outputValue)
Sets a PDO output directly.
void Delete(void)
Delete the MotionController and all its objects.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
int32_t ServiceChannelRead(int32_t index, int32_t subIndex, int32_t byteCount)
Read a 32-bit integer value from the SDO.
RSINetworkState
State of network.
Definition rsienums.h:568