by PaulL » Sat Dec 11, 2010 3:29 pm
by PaulL
Sat Dec 11, 2010 3:29 pm
To get dynamic movement (not point-to-point as is done in the frame capture of the demo, but programatically controlled), you need to update the servo position gradually (and frequently to get smoothness) over time. There are a number of posts in my "Roboard Experience" thread regarding servo movement. My efforts are in VB.Net, but the methods are the same.
When you tell a typical servo to move to a position, it knows nothing of speed, and just moves immediately to the position, as you have witnessed. So, you need to give it MANY positions to transition smoothly from one position to another.
My method:
I use PWM in "continuous" mode on the servos, and set the position using a Windows Multimedia Timer event (4mS interval seems to work fine), but I use RDTSC to calculate actual time elapsed and set the position accordingly. Distance = Speed / Time, so there's that.
You need:
* Start Position
* End Position
* Duration
From there, you just interpolate the position of the move based on time elapsed since start of move:
Position = (Fraction of Move * (EndPosition - StartPosition)) + StartPosition
That's the basic method in a nutshell.
You could even redo my accel / decel code from the "Roboard Experience" thread in C++, it will work the same way.
Paul
To get dynamic movement (not point-to-point as is done in the frame capture of the demo, but programatically controlled), you need to update the servo position gradually (and frequently to get smoothness) over time. There are a number of posts in my "Roboard Experience" thread regarding servo movement. My efforts are in VB.Net, but the methods are the same.
When you tell a typical servo to move to a position, it knows nothing of speed, and just moves immediately to the position, as you have witnessed. So, you need to give it MANY positions to transition smoothly from one position to another.
My method:
I use PWM in "continuous" mode on the servos, and set the position using a Windows Multimedia Timer event (4mS interval seems to work fine), but I use RDTSC to calculate actual time elapsed and set the position accordingly. Distance = Speed / Time, so there's that.
You need:
* Start Position
* End Position
* Duration
From there, you just interpolate the position of the move based on time elapsed since start of move:
Position = (Fraction of Move * (EndPosition - StartPosition)) + StartPosition
That's the basic method in a nutshell.
You could even redo my accel / decel code from the "Roboard Experience" thread in C++, it will work the same way.
Paul