MotorFeedback.cs
Reads the primary and secondary feedback for a motor.
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using RSI.RapidCode.SynqNet.dotNET;
using RSI.RapidCode.SynqNet.dotNET.Enums;
namespace SampleApplications
{
[TestFixture]
public class MotorFeedback
{
MotionController controller;
Axis axis;
const int AXIS_NUMBER = 0;
const int VELOCITY = 8000;
const int ACCELERATION = 6000;
const int DECELERATION = 6000;
[Test]
public void Main()
{
try
{
controller = MotionController.Create();
axis = controller.AxisGet(AXIS_NUMBER);
Console.WriteLine("Motor Type: ");
switch(axis.MotorTypeGet())
{
case RSIMotorType.RSIMotorTypeSERVO:
Console.WriteLine("Servo\n");
break;
case RSIMotorType.RSIMotorTypeSTEPPER:
Console.WriteLine("Stepper\n");
break;
case RSIMotorType.RSIMotorTypePHANTOM:
Console.WriteLine("Phantom\n");
break;
default:
Console.WriteLine("Invalid\n");
break;
}
Console.WriteLine("Encoder Type : ");
switch(axis.EncoderTypeGet())
{
case RSIMotorEncoderType.RSIMotorEncoderTypeQUAD_AB:
Console.WriteLine("QUAD_AB\n");
break;
case RSIMotorEncoderType.RSIMotorEncoderTypeDRIVE:
Console.WriteLine("DRIVE\n");
break;
case RSIMotorEncoderType.RSIMotorEncoderTypeSSI:
Console.WriteLine("SSI\n");
break;
default:
Console.WriteLine("Invalid\n");
break;
}
while (true)
{
Console.WriteLine("\nPrimary: " + axis.EncoderPositionGet(RSIMotorEncoder.RSIMotorEncoderPRIMARY) +
"\nSecondary: " + axis.EncoderPositionGet(RSIMotorEncoder.RSIMotorEncoderSECONDARY));
controller.OS.Sleep(1000);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}