Velocity Set by Analog Input Value Sample Application.
This Sample App was created using the EL3002 Analog Input module. Please note that some variable values might changed based on your analog input module. The functionality used with many other Analog Input modules, not only Beckhoff's.
Learn more about the EL3XXX analog input modules from beckhoff. (https://www.beckhoff.com/english/ethercat/analog.htm)
- 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 © 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.
using RSI.RapidCode.dotNET;
using System;
{
class VelocitySetByAnalogInputValue
{
static void Main(string[] args)
{
double analogMaxValue = 65536;
double currentVelocity = 0;
double analogCurrentValue = 0;
double analogValuePrecentage = 0;
double velocityAbsoluteSum = 0;
const int AXIS_NUMBER = 0;
const int NODE_NUMBER = 0;
const int ANALOG_INPUT_0 = 0;
const int MIN_VEL = -10;
const int MAX_VEL = 10;
const int ACC = 100;
const int USER_UNITS = 1048576;
IO ioNode = controller.
IOGet(NODE_NUMBER);
try
{
Console.WriteLine("Velocity Move Initialized.");
Console.WriteLine("Max Speed = " + MAX_VEL);
Console.WriteLine("Min Speed = " + MIN_VEL);
Console.WriteLine("\nPress SPACEBAR to exit.");
do
{
while (!Console.KeyAvailable)
{
velocityAbsoluteSum = Math.Abs(MIN_VEL) + Math.Abs(MAX_VEL);
analogCurrentValue = (double)ioNode.
AnalogInGet(ANALOG_INPUT_0);
analogValuePrecentage = analogCurrentValue / analogMaxValue;
if (analogValuePrecentage * 100 > 99 || analogValuePrecentage * 100 < 1)
currentVelocity = 0;
else if (analogValuePrecentage * 100 < 50)
currentVelocity = velocityAbsoluteSum * analogValuePrecentage;
else
currentVelocity = -velocityAbsoluteSum + (velocityAbsoluteSum * analogValuePrecentage);
}
} while (Console.ReadKey(true).Key != ConsoleKey.Spacebar);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}