Servo Motor not opertaing properly
StereoPonyz
Posts: 82
Hi, i have followed the manual example to control the servo motors using the terminal
import stamp.core.*;
public class ServoControl {
static PWM servo = new PWM(CPU.pin12,173,2304);
public static void main() {
System.out.println("Welcome to Servo Control: ");
System.out.println(" r - right");
System.out.println(" l - left");
System.out.println(" c - center");
while (true) {
switch ( Terminal.getChar() ) {
case 'r':
servo.update(130,2304);
break;
case 'l':
servo.update(220,2304);
break;
case 'c':
servo.update(173,2304);
break;
}
}
}
}
However, the servo does not respond to what i typed in... Is it that the servo requires another calibration again? i had calibrated the servo motor before with Bs2sx stamp mounted, it was working fine then.
import stamp.core.*;
public class ServoControl {
static PWM servo = new PWM(CPU.pin12,173,2304);
public static void main() {
System.out.println("Welcome to Servo Control: ");
System.out.println(" r - right");
System.out.println(" l - left");
System.out.println(" c - center");
while (true) {
switch ( Terminal.getChar() ) {
case 'r':
servo.update(130,2304);
break;
case 'l':
servo.update(220,2304);
break;
case 'c':
servo.update(173,2304);
break;
}
}
}
}
However, the servo does not respond to what i typed in... Is it that the servo requires another calibration again? i had calibrated the servo motor before with Bs2sx stamp mounted, it was working fine then.
Comments
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "running"
counter VAR Word
FREQOUT 4, 2000, 3000
FOR counter = 1 TO 24 'forward
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
PAUSE 200
FOR counter = 1 TO 122 'stop
PULSOUT 13, 750
PULSOUT 12, 750
PAUSE 20
NEXT
FOR counter = 1 TO 24 'backward
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
END
It works fine. So if to use Javelin stamp, do i need to re-calibrate the servo motor with new settings? The manual did not teach how...
may type characters in the output window and these are not
send to the javelin.
You can add some text output so you know that what
you typed is received by the javelin.
case 'r':
System.out.println("turn right");
servo.update(130,2304);
break;
regards peter
Post Edited (StereoPonyz) : 12/13/2009 9:18:45 AM GMT
FOR counter = 1 TO 24 'forward
PULSOUT 12, 650 '1300usec
PAUSE 20
NEXT
PAUSE 200
FOR counter = 1 TO 122 'stop
PULSOUT 12, 750 '1500usec
PAUSE 20
NEXT
FOR counter = 1 TO 24 'backward
PULSOUT 12, 850 '1700usec
PAUSE 20
NEXT
Converted to javelin resolution pulsecounts:
1300usec = 1300/8.68 = 149.8 = 150 --> you use 130
1500usec = 1500/8.68 = 172.8 = 173
1700usec = 1700/8.68 = 195.9 = 196 --> you use 220
20msec = 20000/8.68 = 2304.1 = 2304
I would certainly recalibrate the servo, because value 173 does not exactly matches 1500usec.
regards peter
May i find out will the slight off measurement affect the whole operation of the servo? cos the servo continues to spin Anti-clockwise irregardless of wat commands i keyed in... For instance, the code which i use 220 to turn Anti-Clockwise and 130 to turn Clockwise, have got no effect on the servo.... It spins Anti-Clockwise no matter what i put in, i had tried out 150 and 196 too with no effect.
I had tot that the servo will at least spin according to other values except 173 since it does not match 1500usec exactly...
Post Edited (StereoPonyz) : 12/14/2009 8:25:18 AM GMT
Using Bs2sx stamp onto any of the Boe-Bots, the servos can function accordingly.
What may be the reason that Boe-Bot (A) is not working when Javelin is mounted onto it?
The javelin does consume more current (about 70mA) than a BS2 (less than 10mA).
Might be worth swapping the power units on the bots to see if that allows the
javelin to function on Boe-Bot A.
regards peter