Gantry sample application.
This sample will configure two parallel axes (X1, X2) connected to the same load, and configure them so that X1 will be used to command linear motion, and X2 will be used to command yaw motion.
#include "rsi.h"
#include "HelperFunctions.h"
using namespace RSI::RapidCode;
#pragma region GantryDeclares
int linearAxisNumber = 0;
int yawAxisNumber = 1;
int defaultEncoderNumerator = 0;
int defaultEncoderDenominator = 0;
int gantryEncoderNumerator = 1;
int gantryEncoderDenominator = 2;
double x1PrimaryCoeff = 1.0;
double x2PrimaryCoeff = 1.0;
double x1SecondaryCoeff = 1.0;
double x2SecondaryCoeff = -1.0;
double defaultPrimaryCoeff = 1.0;
double defaultSecondaryCoeff = 0.0;
uint64 x1EncoderAddress;
uint64 x2EncoderAddress;
uint64 x1FilterPrimaryPointerAddress;
uint64 x1FilterSecondaryPointerAddress;
uint64 x2FilterPrimaryPointerAddress;
uint64 x2FilterSecondaryPointerAddress;
uint64 x1FilterPrimaryCoefficientAddress;
uint64 x1FilterSecondaryCoefficientAddress;
uint64 x2FilterPrimaryCoefficientAddress;
uint64 x2FilterSecondaryCoefficientAddress;
uint64 x1AxisLinkAddress;
uint64 x2AxisLinkAddress;
#pragma endregion
#pragma region GantryMethods
void ReadAddressesFromMotionController()
{
}
void SetupEncoderMixing(bool enableGantry)
{
if (enableGantry)
{
}
else
{
}
}
void SetupFilterMixing(bool enableGantry)
{
if (enableGantry)
{
mc->
MemoryDoubleSet(x1FilterSecondaryCoefficientAddress, x1SecondaryCoeff);
mc->
MemoryDoubleSet(x2FilterSecondaryCoefficientAddress, x2SecondaryCoeff);
}
else
{
mc->
MemoryDoubleSet(x1FilterPrimaryCoefficientAddress, defaultPrimaryCoeff);
mc->
MemoryDoubleSet(x1FilterSecondaryCoefficientAddress, defaultSecondaryCoeff);
mc->
MemoryDoubleSet(x2FilterPrimaryCoefficientAddress, defaultPrimaryCoeff);
mc->
MemoryDoubleSet(x2FilterSecondaryCoefficientAddress, defaultSecondaryCoeff);
}
}
void GantryEnable(bool enable)
{
ReadAddressesFromMotionController();
SetupEncoderMixing(enable);
SetupFilterMixing(enable);
}
#pragma endregion
void gantryMain()
{
SampleAppsCPP::HelperFunctions::CheckErrors(mc);
linearAxis = mc->
AxisGet(linearAxisNumber);
SampleAppsCPP::HelperFunctions::CheckErrors(linearAxis);
yawAxis = mc->
AxisGet(yawAxisNumber);
SampleAppsCPP::HelperFunctions::CheckErrors(yawAxis);
ReadAddressesFromMotionController();
GantryEnable(true);
GantryEnable(false);
}