I'm totally new to microcontroller/physical computing stuff, but I like to say that the resources in arduino community help me a lot to catch up with my level 1 mathematic & coding skill.
I use servo library here to build a kind of automatic video pan&tilt for video camera, which I plan to apply later for my video art project.
The problem is the fast movement of the servo and the sudden stop somehow make camera shaking. So I was wondering is there any resource about ease in/ease out library to make servo slowly move then slowly stop.
however, my programming skill is not good enough to realise it.
Can anyone give me a guide on how to apply this concept into coding?
Or is it possible to make a kind of ease in/out as a kind of function in a servo library somehow?
The subject of smooth motion control came up in this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1199497432
You may want to follow up with the poster, roypardi, I think he has been looking closely at ways smoothing mechanical movement.
well...
here is my level 1 coding skill attempt, its work. but I'm sure it must be a better way, so I share here incase someone want to improve or fix it, make library, add more complex interpolation for instance
I don't think that code is implementing the algorithm in the link you posted. I may be wrong, but it looks like you are calculating small movement steps by a values that vary by the cosines of all angles between 0 and 1 radian. I think what is wanted is to calculate the movement of each step by the cosine of the current angle. I think the fragment below is closer but its off the top of my head, I have not compiled or run it so probably needs some work but I hope it gets you closer.
It's a fragment, you need to add the macros for converting radians to degrees and back again. It also needs the logic to cope with decreasing angles.
#define FRAME_RATE 20 // milliseconds per frame
#define SERVO_SPEED 100 // this the time in ms to move 60 degrees
// adjust this for the specs of your servos
#define MAX_STEP_PER_FRAME (60 / (SERVO_SPEED/ FRAME_RATE)) // max degrees servo can move in one frame
void smoothmove(int cposition, int oldposition) {
int moveAngle;
while(cposition != oldposition) {
moveAngle = oldposition + MAX_STEP_PER_FRAME; //this is the raw uneased value
if( moveAngle > cposition)
moveAngle = cposition;
// code needed using similar logic for cposition < oldposition
oldposition += Rad2Angle( 0.5 - 0.5 * cos(Angle2Rad(moveAngle) * PI) );
myservo.write(oldposition);
myservos.refresh();
}
}
Hi, Im new here but Ive been using the Arduino for a year or so.
...Im still a total newb
Was wondering if there had been any developments on this topic. I see the last post is a couple of years old but there is little else I can find on the net (besides the roypardi link above ) and assumed it would be a common query.
Looking for a simple way to ease a servo in and out, any suggestions would be appreciated.
Did this problem ever get solved? I started playing around with Mem's code block but didn't get very far.
We're controlling a brush motor and need smooth starts and smooth stops.
(12v 100amp motor rotating the base of an art sculpture that will weight 2+ tons).
We're playing with the Servo library and it does move our 'lazy susan' table, but it a) tries to get there as fast as possible. and b) comes to a dead stop when it does, which causes the entire sculpture to 'shake' violently. Not good!! too much steel and weight involved for that... (we already have a 60:1 step down gear box inline)
Thus we need to very slowly start each move and very slowly stop each move to deal with the mass of the piece.
It seems like servo ramp acceleration/ramp deceleration is a common enough problem , but I've not found any sample code.
The servo "sweep" demonstration sketch shows how to have a servo move at slower speeds by making incremental servo move spaced apart by a time delay. You could make the time delay longer as the desired position is being approached.
We're looking for something less 'linear' than the sweep demo.
We also have the problem that even with tiny moves, the 'hard' stop effect can be seen. We need something that smooths the power curve on start and stop even on the tinniest moves.
I guess we could build something with fractional degree moves and variable delays.
If we fix a move increment at say 1/8 degree, would the cosine math mentioned above be applied to the time? Another words, if we say we want to move 5 degrees in 5 seconds, would we set our writes at 1/8 degree fixed, but then varies the amount of time delayed by some sort of cosine equation ???
It's this calculation of the delay curve/profile that seems like a problem that's already been solved, but I've not found it yet.
The problem is the fast movement of the servo and the sudden stop somehow make camera shaking.
Maybe not: people without experience tend to overestimate how strong and solid pan/tilt mounts are. Even though I had some background in astronomy, I couldn't believe the manufacturers' specs saying that mounts could only handle a payload of like a quarter their own weight. But I could sure see it when I tried to exceed their ratings, especially with long lenses.
Is your pan/tilt mount one you made yourself with one of those servo bracket kits? If so, the odds are very good that it's overloaded, and no tinkering with algorithms will fix the problem.
I guess we could build something with fractional degree moves and variable delays.
If you are using hobby grade servos, then it has been my experience that they are only capable of making descrete .5 deg moves at best. The arduino has the capability to send ~2000 discrete positions to the typical 180 deg rotation servo. There are new digital servos available that may better this. The question as to your pan/tilt construction and the size of the cam it is trying to move is very important. If you expect professional looking results, then you may need professional grade construction. Below are some servo based pan tilt units that might fit your needs.
We're using 1500 lb 18" industrial linear actuators and a rotational 'servo' of our own design which is a 12vDC 100 AMP motor with a 60:1 step-down gear box. (It is designed with POT feedback). The rotational one is a brush motor, so in theory, it's infinitely variable as it's just a mater of the precision of the feedback pot and the voltage we apply to the motor.
We're currently using RoboteQ AX2550 controllers, but after discussion with RoboteQ, we're upgrading to their newer controllers which is supposed to solve this problem, the HDC2400
We're using 1500 lb 18" industrial linear actuators and a rotational 'servo' of our own design which is a 12vDC 100 AMP motor with a 60:1 step-down gear box. (It is designed with POT feedback). The rotational one is a brush motor, so in theory, it's infinitely variable as it's just a mater of the precision of the feedback pot and the voltage we apply to the motor.
Well, I think that may explain the lack of precision of movement. It is hard to turn a bulldozer into a ballet dancer. Below is my 2000lb 150a "big" servo project.
That said, we know the table can rotate smoothly with our set up when we use a variac to manually control the voltage going to the unit. Works like a charm, nice smooth moves, no crazy harsh stops.
We're just trying to get that type of functionality replicated from our micro processor.
Seem like the problem with a lot of RC controller is that they're not really designed to do this. Most servos are designed to make a full range motion in in fractions of a second and don't have huge loads on them...
My understanding of the Servo library (which is limited) is that you tell it a position to send the servo to, but that's pretty much it. The Servo takes as long as it does go get from position A to Position B and you don't have much control over it's acceleration or deceleration profile.
It seems like a lot of the 'tricks' to ease in/ ease out are just dividing the move into smaller pieces and adding delays between them.
For example, going from 10 degree to 80 degrees might be broken up into 1 degree moves instead of just ending the command to move to 80, but you still don't have any control over the speed of each of your smallest increments.