servo inaccurate positioning

Supporting Visual Studio on Windows
Post Reply
zsoltmol
Fresh meat
Posts: 1
Joined: Tue Feb 19, 2019 2:49 pm
Contact:

servo inaccurate positioning

Post by zsoltmol »

Hi,

my 1066_1B controller with a 180 degr travel servomotor is not positioning very accurately. What I would like to achieve is to move an arm attached to the servo 180 degrees, and then back. When I run the app the 1st time, the 180 is more or less accurate, but even the second time of running the app, the 180 is no longer there, it is either more or less, sometimes as far as 30 degrees difference. The more times I run the app, the bigger the deviation from 180 degrees is.
Attached is some of my code.
At the moment I try to achieve two repositionings, both 180 degrees, in the same directions, once I achieve the accuracy, the next step will be to reverse the second repositioning (return the bar to it's starting position).
Any help in achieving accuracy in positioning would be appreciated. Thank you.

Code: Select all


servo.Acceleration = 280.00;
            servo.VelocityLimit = 120.00;

            servo.TargetPosition = 180.00;

            servo.Engaged = true;

            servo.TargetPosition = 177.00;

            Thread.Sleep(1400);

            servo.Engaged = true;

            servo.TargetPosition = 174.00;
           
            Console.Write("Position: ");
            Console.WriteLine(servo.Position);

            Thread.Sleep(1000);

            servo.TargetPosition = 0.00;
            double targetposition = servo.TargetPosition;

            Console.Write("Target Position: ");
            Console.WriteLine(targetposition);
...and the event handlers

Code: Select all

 void Servo_PositionChange(Object sender, RCServoPositionChangeEventArgs e)
            {
                string positionEvent = e.Position.ToString("F0");
                Console.WriteLine("Position changed to:...{0}", positionEvent);
            }

            void Servo_VelocityChange(Object sender, RCServoVelocityChangeEventArgs e)
            {
                Console.WriteLine("Velocity is changing...");
            }

            void Servo_TargetPositionReached(Object sender, RCServoTargetPositionReachedEventArgs e)
            {
                servo.Engaged = false;
                Console.WriteLine("Position reached!");
            }

jdecoux
Labview Developer
Posts: 180
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: servo inaccurate positioning

Post by jdecoux »

I recommend removing the servo.Engaged = false; from your TargetPositionReached event handler.

This will cause a chain of events that almost immediately disengages the motor after it has been engaged, as the 1066 will always immediately report is has reached its starting position.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest