Offline
Jr. Member
Karma: 0
Posts: 92
|
 |
« on: November 13, 2012, 08:21:35 pm » |
Hi all, I would like to know if is possible adjust the rc servo motor speed without use loop for?
With loop for I can control the speed adjusting the time.
for(int i=0; i<180; i++){ servo.Write(i); delay(15);
And this way, how do I control the speed rotation? servo.Write(150); Servo.Write(30); ...
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 78
Posts: 2087
|
 |
« Reply #1 on: November 13, 2012, 09:07:31 pm » |
servo.Write(150); // should go one direction servo.Write(30); // should go the other direction.
servo.Write(90); // should stop. servo.Write(80); // should go one direction slowly. servo.Write(100); // should go the other direction slowly.
|
|
|
|
« Last Edit: November 13, 2012, 09:10:49 pm by oric_dan(333) »
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 92
|
 |
« Reply #2 on: November 13, 2012, 09:53:56 pm » |
I understood, I will make some tests, thanks for now.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #3 on: November 13, 2012, 10:11:29 pm » |
servo.Write(150); // should go one direction servo.Write(30); // should go the other direction.
servo.Write(90); // should stop. servo.Write(80); // should go one direction slowly. servo.Write(100); // should go the other direction slowly.
That is for a servo modified for continous rotation and not an unmodified servo.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 92
|
 |
« Reply #4 on: November 14, 2012, 05:43:55 am » |
I made a test, really didn't work like I want. I looking for a way to make that control, some idea let me know. att luis andrade
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 78
Posts: 2087
|
 |
« Reply #5 on: November 14, 2012, 12:36:26 pm » |
I made a test, really didn't work like I want. So, what happened?
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 92
|
 |
« Reply #6 on: November 14, 2012, 03:21:54 pm » |
The motor went until the position called but in high speed.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 45
|
 |
« Reply #7 on: November 14, 2012, 03:34:09 pm » |
I am assuming you are controlling the servos directly and not using a separate servo controller ? An SD21 servo controller gives you an option to set a speed register but that is over kill if you are using 2 or 3 servos. The example used in the SD 21 documentation to explain the speed is shown below, but this handled by the servo controller The servo pulses are automatically refreshed every 20mS. If the Speed register is zero (0x00) then the servo is simply set to the requested position. On power up the Speed registers are set to zero to give full speed, so unless you need to slow them down the Speed registers can be ignored. If the Speed register is set to something other than zero then that value is added to the current position every 20mS until the target position is reached. If you wish to move from 1000 to 2000 and the Speed register is set to 10, then it will take 2 seconds to reach the set position. The formula for the time it will take to make the move is:
((Target position-Start position)/Speed Reg)*20mS
Here are some examples:
Start Position Target Position Speed Reg Time for Move 2000 1000 10 2000mS (2Sec) 1000 2000 10 2000mS (2Sec) 1000 2000 1 20000mS (20Sec) 1000 2000 100 200mS (0.2Sec) 1234 1987 69 220mS (0.22Sec)
Basically doing what your loop does but the load is moved to the servo controller. This post may help http://arduino.cc/forum/index.php/topic,21975.0.html It is titled Servo timer so it may have the functionality you need.
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 78
Posts: 2087
|
 |
« Reply #8 on: November 14, 2012, 09:11:39 pm » |
That is for a servo modified for continous rotation and not an unmodified servo. Yeah, I think I made a big mistake. My first comment should have been "is it a regular or modified servo?" Apparently, it's regular, which is why the for-loop works. The only way to control the movement speed of an unmodified servo is to keep updating the position values every 20-msec or so. IE, interpolation, (start_pos - end_pos)/velocity = pos_increment per unit time. That's probably what the long thread pointed to talks about. Either code this into the Arduino, or as indicated, use a servo controller with this feature built-in.
|
|
|
|
« Last Edit: November 14, 2012, 09:13:13 pm by oric_dan(333) »
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 92
|
 |
« Reply #9 on: November 14, 2012, 10:14:12 pm » |
I'm using a normal servo motor 0-180 degrees, I'm building a arm robot, the control is made directly without servo controller.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #10 on: November 14, 2012, 10:31:16 pm » |
Try the "sweep" servo code example to see how it makes the servo move slower than usual.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #11 on: November 15, 2012, 11:19:37 am » |
The maximum speed a servo can move is strictly a function of the servo's design and what mechanical load it is attached to. However in your software you can make the servo move slower by issuing smaller step changes in position commands from start to ending desired position, and by waiting the appropriate amount of time between those issued incremental position commands. It would be pretty simple to write a user general purpose function such as:
void moveServo(int finalPosition, int stepTime);
Lefty
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 78
Posts: 2087
|
 |
« Reply #12 on: November 15, 2012, 12:27:26 pm » |
void moveServo(int finalPosition, int stepTime); The hard part is integrating this thing into the rest of the program, so the updates are made on nice even 20-msec time intervals, but it doesn't impact operation of other routines. Probably need a timer interrupt to call the update code.
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15293
Measurement changes behavior
|
 |
« Reply #13 on: November 15, 2012, 01:12:06 pm » |
void moveServo(int finalPosition, int stepTime); The hard part is integrating this thing into the rest of the program, so the updates are made on nice even 20-msec time intervals, but it doesn't impact operation of other routines. Probably need a timer interrupt to call the update code. The best solution is if the servo library (class) had such a function built into it so that it might be made non-blocking and closely synced up with the automatic servo framing rate being generated so that step change timing could be a even number of frame rates, 1 to 'very slow' . But alas I'm not up to the task as I just play being a programmer on this site, as solder is my real programming language.  Lefty
|
|
|
|
« Last Edit: November 15, 2012, 01:16:24 pm by retrolefty »
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 78
Posts: 2087
|
 |
« Reply #14 on: November 15, 2012, 02:24:45 pm » |
luis, what Arduino board are you using?
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
|