Author |
Message |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
 Servo Control
I don't see any documentation on how to control a servo connected to the VEX controller, can you fill us in on the commands and functions if any?
Scott
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
Wed Apr 18, 2007 7:39 pm |
|
 |
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 620
|
You can use a servo motor as a regular motor with the motor[port] command... but to use a positional servo (like from 0-255), that is not yet supported in RobotC Vex.
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
Thu Apr 19, 2007 3:39 pm |
|
 |
jkjellman
Rookie
Joined: Sun Apr 22, 2007 9:01 pm Posts: 11
|
Any idea when this feature will come about?
Also, am I reading your post correctly in that the motor speed will determine the servo position?
Take care,
KJohn
|
Mon Apr 23, 2007 9:58 am |
|
 |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
Sadly no, what he means is you can move the servo forward and backward using the motor command, but there is currently no way of controlling it to a given position using its built in encoder.
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
Mon Apr 23, 2007 5:40 pm |
|
 |
jkjellman
Rookie
Joined: Sun Apr 22, 2007 9:01 pm Posts: 11
|
Sorry gents but after doing a bit of research I have to disagree. The motors in the Vex kit are continuous rotation servos (i.e. servos modified to turn 360 degrees).
So if a motor command can set the PWM pulse duration for a motor then the exact same function will set the position for a servo.
As a matter of fact, EasyC (the default Vex programming tool) has a single function called SetPWM which is used to control both motors and servos. EasyC has no way to tell if a servo or a motor is attached to a given motor port.
Hope this makes sense.
Take care,
KJohn
|
Sat Apr 28, 2007 12:55 am |
|
 |
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 620
|
Yes, you are correct about the Servo's going 360 degrees. They are modified servos that have the mechanical stops removed to allow full rotation.
Unless you would attach a hobby servo to the Vex controller, there would be no way to gain positional control. And even then, the functionality to use the build in encoders in RobotC is not there.
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
Tue May 01, 2007 3:26 pm |
|
 |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
Vex does have positional servos with the stops inside, they look exactly the same as the servo motors and are easily confused. The motors and Servos are labeled on the sides.
you can hook up normal hobby servos as well, you just have to have a male to male PWM cable converter of some sort.
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
Tue May 01, 2007 8:09 pm |
|
 |
jkjellman
Rookie
Joined: Sun Apr 22, 2007 9:01 pm Posts: 11
|
OK, I think we are all saying nearly the same thing. Here's my read just to be sure:
1) Vex motors are continuous rotation servos
2) Vex servos can have their position set via the motor command
3) Vex servos CANNOT use the RobotC PID routines as they have no exposed encoders
NOTE: In #2 above, I am basically saying that the Vex servo position is set like a normal R/C servo, the motor "speed" value provides a PWM'd series of pulses to the servo and it's internal electronics use this to position itself.
Hope this makes sense, I think I am clear here.
Take care,
KJohn
|
Wed May 02, 2007 12:27 am |
|
 |
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 616
|
JKjellman's not is almost correct. Some clarification on PID
RobotC supports a number of platforms. Some of those platform have classical PWM motor control and not servos. These platforms also support motor encoders. On these platforms, RobotC has integrated PID algorithms to provide precise positional and speed control.
Precise speed control is not required in the firmware because it is built into the servo itself. So this functionality is not built into the RobotC VEX firmware.
It is easy to write a PID control in RobotC code. It's only about 10 lines of code. There are VEX applications where this might be useful. In particular, using PID to control distance travelled (and not speed). In this case, want to use PID to have the motor move a precise distance-- for example four revolutions -- and stop precisely at that point.
|
Wed May 02, 2007 4:30 pm |
|
 |
mtl6
Rookie
Joined: Fri Nov 21, 2008 12:05 am Posts: 4
|
 Re: Servo Control
So to get this straight...
I have a servo mounted on top of a modded squarebot and I want to basically turn it to look for objects (The motor shaft turns a sonar rangefinder). Would I be better off using a regular motor for this application? Or is there actually a way to configure this setup using robot C to position the servo (and say, in a different application, store the distance value in an array corresponding to the servo position)?
I am new to the whole concept of PWM waves and how to generate them. How does one generate a pulsetrain with the VEX in Robot C?
-M
|
Mon Dec 08, 2008 9:56 pm |
|
 |
fryfrog
Rookie
Joined: Sat Aug 30, 2008 2:25 am Posts: 25
|
 Re: Servo Control
I'm pretty sure that if you send -127 or 127 to a servo module, it will go to its end position. Send it 60 or -60 and it'll go ~half way to the end position. 0 would be neutral or the middle. Obviously, it isn't going to be *perfect* but it is close. Pretty sure I built a sonar device that wiggled back and forth using a servo.
You could use a potentiometer to make it even more accurate, if you wanted, I imagine.
|
Tue Jan 27, 2009 10:25 pm |
|
|