APIs, concepts, guides, and more

◆ RecorderConfigureToTriggerOnMotion() [5/5]

void RecorderConfigureToTriggerOnMotion ( MultiAxis * multiAxis,
bool triggerOnMotion )
Parameters
multiAxisMultiAxis object to trigger on.
triggerOnMotionA boolean value to set the trigger configuration. TRUE = trigger on Motion.
Description:
RecorderConfigureToTriggerOnMotion sets the recorder to trigger on motion. The recording will start when motion begins, and it will automatically stop when the Motion Done condition is true.

Part of the Recorder method group.

Sample Code:
/* This sample demonstrates how to use the Recorder to track multiple controller parameters.
Shows how to configure the recorder, record axis position and digital input values,
and retrieve recorded data to find when specific events occurred.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Recorder");
int exitCode = 0;
// set sample config params
const int VALUES_PER_RECORD = 2; // how many values to store in each record
const int RECORD_PERIOD_SAMPLES = 1; // how often to record data (samples between consecutive records)
const int RECORD_TIME = 250; // how long to record (milliseconds)
const int INPUT_INDEX = 0;
// get rmp objects
MotionController controller = MotionController.Get();
try
{
Helpers.CheckErrors(controller);
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
// set recorder count before any RapidCodeObject get/create other than the controller
controller.RecorderCountSet(1);
// get axis
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(axis);
// configure phantom axis
if (!Constants.USE_HARDWARE) Helpers.PhantomAxisReset(axis);
// create simulated digital input using user buffer memory
ulong userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0);
IOPoint digitalInput = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX);
// stop recorder if already running
if (controller.RecorderEnabledGet() == true)
{
controller.RecorderStop(); // stop recording
controller.RecorderReset(); // reset controller
}
// configure recorder
controller.RecorderPeriodSet(RECORD_PERIOD_SAMPLES); // record every n samples
controller.RecorderCircularBufferSet(false); // do not use circular buffer
controller.RecorderDataCountSet(VALUES_PER_RECORD); // number of values per record
controller.RecorderDataAddressSet(0, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeACTUAL_POSITION)); // record axis position
RSIDataType actualPositionDataType = axis.AddressDataTypeGet(RSIAxisAddressType.RSIAxisAddressTypeACTUAL_POSITION);
Console.WriteLine($"Axis Actual Position data type: {actualPositionDataType}"); // print actual position type
controller.RecorderDataAddressSet(1, digitalInput.AddressGet()); // record digital input state
// start recording
controller.RecorderStart();
controller.OS.Sleep(RECORD_TIME / 2); // record for specified time
controller.MemorySet(digitalInput.AddressGet(), 1 << INPUT_INDEX); // simulate input trigger
controller.OS.Sleep(RECORD_TIME / 2); // continue recording for specified time
// retrieve recorded data
int recordsAvailable = controller.RecorderRecordCountGet();
Console.WriteLine($"There are {recordsAvailable} records available");
// process records to find when input triggered
for (int i = 0; i < recordsAvailable; i++)
{
controller.RecorderRecordDataRetrieve(); // retrieve one record
FirmwareValue positionFirmwareValue = controller.RecorderRecordDataFirmwareValueGet(0); // get axis position value
double positionRecord = positionFirmwareValue.Double;
FirmwareValue digitalInputFirmwareValue = controller.RecorderRecordDataFirmwareValueGet(1); // get digital input value
int digitalInputValue = digitalInputFirmwareValue.Int32;
// check if digital input bit is high
if ((digitalInputValue & digitalInput.MaskGet()) == digitalInput.MaskGet())
{
Console.WriteLine($"Encoder position was: {positionRecord} when input triggered");
break;
}
}
// stop and reset recorder
controller.RecorderStop();
controller.RecorderReset();
exitCode = Constants.EXIT_SUCCESS;
}
// handle errors as needed
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
exitCode = Constants.EXIT_FAILURE;
}
finally
{
controller.Delete(); // dispose
}
return exitCode;
Constants used in the C# sample apps.
Definition _constants.cs:3
const bool USE_HARDWARE
Default: false.
Definition _constants.cs:10
const int EXIT_FAILURE
Exit code for failed execution.
Definition _constants.cs:69
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:20
const int EXIT_SUCCESS
Exit code for successful execution.
Definition _constants.cs:68
uint64_t AddressGet(RSIAxisAddressType addressType)
Get the an address for some location on the Axis.
RSIDataType AddressDataTypeGet(RSIAxisAddressType type)
Get the data type for an address the Axis.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5921
uint64_t AddressGet()
Get the Host Address for the I/O point.
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
int32_t MaskGet()
Get the bit mask for the I/O point.
Represents one specific point: Digital Output, Digital Input, Analog Output, or Analog Input....
Definition rsi.h:11597
RSIControllerAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:405
RSIDataType
Data types for User Limits and other triggers.
Definition rsienums.h:664
RSIAxisAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:439
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21
Union representing a generic RMP firmware value with multiple data types, stored in 64-bits.
Definition rsi.h:468
double Double
Double precision (64-bit) floating-point.
Definition rsi.h:477
int32_t Int32
32-bit signed integer.
Definition rsi.h:474
See also
RecorderDataCountSet, RecorderTriggerOnMotionGet This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.