32 double analogMaxValue = 65536;
33 double currentVelocity = 0;
34 double analogCurrentValue = 0;
35 double analogValuePrecentage = 0;
36 double velocityAbsoluteSum = 0;
39 const int AXIS_NUMBER = 0;
40 const int NODE_NUMBER = 0;
41 const int ANALOG_INPUT_0 = 0;
42 const int MIN_VEL = -10;
43 const int MAX_VEL = 10;
45 const int USER_UNITS = 1048576;
52 Axis axis = controller.
AxisGet(AXIS_NUMBER);
55 IO ioNode = controller.
IOGet(NODE_NUMBER);
61 Console.WriteLine(
"Velocity Move Initialized.");
62 Console.WriteLine(
"Max Speed = " + MAX_VEL);
63 Console.WriteLine(
"Min Speed = " + MIN_VEL);
64 Console.WriteLine(
"\nPress SPACEBAR to exit.");
67 axis.UserUnitsSet(USER_UNITS);
68 axis.ErrorLimitTriggerValueSet(1);
70 axis.DefaultAccelerationSet(ACC);
71 axis.DefaultDecelerationSet(ACC);
74 axis.AmpEnableSet(
true);
78 while (!Console.KeyAvailable)
80 velocityAbsoluteSum = Math.Abs(MIN_VEL) + Math.Abs(MAX_VEL);
81 analogCurrentValue = (double)ioNode.AnalogInGet(ANALOG_INPUT_0);
82 analogValuePrecentage = analogCurrentValue / analogMaxValue;
91 if (analogValuePrecentage * 100 > 99 || analogValuePrecentage * 100 < 1)
94 else if (analogValuePrecentage * 100 < 50)
95 currentVelocity = velocityAbsoluteSum * analogValuePrecentage;
98 currentVelocity = -velocityAbsoluteSum + (velocityAbsoluteSum * analogValuePrecentage);
100 axis.MoveVelocity(currentVelocity);
103 }
while (Console.ReadKey(
true).Key != ConsoleKey.Spacebar);
109 Console.WriteLine(e.Message);