APIs, concepts, guides, and more
Monitoring: Recorder

Learn how to use Recorders in C#.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


In this page:


📜 Recorder

Learn how to use the Recorder 📖 to track multiple controller parameters over time. Shows how to configure the recorder, record axis position and digital input values, and retrieve recorded data to find when specific events occurred.

/* 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");
// 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
try
{
Helpers.CheckErrors(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
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
controller.RecorderDataAddressSet(1, digitalInput.AddressGet()); // record digital input state
// start recording
controller.RecorderStart();
controller.OS.Sleep(RECORD_TIME); // record 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
double positionRecord = controller.RecorderRecordDataDoubleGet(0); // get axis position value
int digitalInputValue = controller.RecorderRecordDataValueGet(1); // get digital input value
// 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();
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
Constants used in the C# sample apps.
Definition _constants.cs:3
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:11
uint64_t AddressGet(RSIAxisAddressType addressType)
Get the an address for some location on the Axis.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
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:11550
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
RSIControllerAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:405
RSIAxisAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:434
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21