Two Condition Digital Input User Limit sample application.
This sample code shows how to configure the RMP controller's User Limits to compare an two different input bits to a specific signal (high signal (1) OR low signal (0)). If the (2 conditions) patterns match, then the specified output bit is activated (turns high).
In this example we configure a user limit to trigger when both our INPUTS turns high(1). Once the INPUTS turn high(1) then our user limit will set the OUTPUT to high(1).
The INPUTS are specified in two different UserLimitConditionSet()
The OUTPUT is specified in UserLimitOutputSet()
In this example Beckhoff IO Terminals (Model EL1088 for Inputs and Model EL2008 for outputs) were used to control the Digital IO signals.
Make sure to check the correct digital IO signal indexes of your system in: RapidSetup -. Tools -. NetworkIO
- Precondition
- This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
- Warning
- This is a sample program to assist in the integration of your motion controller with your application. It may not contain all of the logic and safety features that your application requires.
- Copyright
- Copyright(c) 1998-2019 by Robotic Systems Integration, Inc. All rights reserved. This software contains proprietary and confidential information of Robotic Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth in the license agreement under which this software is supplied, disclosure, reproduction, or use with controls other than those provided by RSI or suppliers for RSI is strictly prohibited without the prior express written consent of Robotic Systems Integration.
#include "rsi.h"
#include "HelperFunctions.h"
void UserLimitDigitalInputTwoConditionMain()
{
const int NODE_INDEX = 0;
const int INPUT_INDEX0 = 0;
const int INPUT_INDEX1 = 1;
const int OUTPUT_INDEX = 0;
char rmpPath[] = "C:\\RSI\\X.X.X\\";
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
try
{
int userLimit = 1;
SampleAppsCPP::HelperFunctions::CheckErrors(input0);
SampleAppsCPP::HelperFunctions::CheckErrors(input1);
SampleAppsCPP::HelperFunctions::CheckErrors(output0);
int condition0 = 0;
unsigned long input0Address = input0->
AddressGet();
unsigned int input0Mask = (
unsigned int)input0->
MaskGet();
unsigned int limitValue0 = (
unsigned int)input0->
MaskGet();
int condition1 = 1;
unsigned long input1Address = input1->AddressGet();
unsigned int input1Mask = (unsigned int)input1->MaskGet();
unsigned int limitValue1 = (unsigned int)input1->MaskGet();
condition0,
logic,
input0Address,
input0Mask,
limitValue0);
condition1,
logic,
input1Address,
input1Mask,
limitValue1);
int axis = 0;
int duration = 0;
triggerType,
action,
axis,
duration);
unsigned int andMask = (unsigned int)output0->MaskGet();
unsigned int orMask = (unsigned int)output0->MaskGet();
unsigned long outputAddress = output0->AddressGet();
bool enableOutput = true;
andMask,
orMask,
outputAddress,
enableOutput);
printf("Waiting for the input bit to go high...\n");
{
}
printf("\nPress Any Key To Continue");
system("pause");
output0->Set(false);
}
{
printf(
"%s\n", err.
text);
}
system("pause");
}