Shop OBEX P1 Docs P2 Docs Learn Events
Servo Motor not opertaing properly — Parallax Forums

Servo Motor not opertaing properly

StereoPonyzStereoPonyz Posts: 82
edited 2009-12-15 10:43 in General Discussion
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.

Comments

  • StereoPonyzStereoPonyz Posts: 82
    edited 2009-12-13 08:09
    Below is the codes i had tested the servo when using Bs2sx.

    ' {$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...
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-12-13 08:47
    You need to click in the 'one line' input window first otherwise you
    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
  • StereoPonyzStereoPonyz Posts: 82
    edited 2009-12-13 09:12
    I have tried out the mtd by inserting a println in every case, but the servo does not respond. to what i type, it kept spinning in Anti-Clockwise direction.. Could it be that my Javelin Stamp got Burn-out?

    Post Edited (StereoPonyz) : 12/13/2009 9:18:45 AM GMT
    793 x 688 - 73K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-12-13 12:52
    The BS2sx uses 2usec resolution pulsecounts
    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
  • StereoPonyzStereoPonyz Posts: 82
    edited 2009-12-14 08:07
    Thank you peter... cos vlaue 173 does not exactly matches 1500usec so that it will spin when it suppose to stop.

    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
  • StereoPonyzStereoPonyz Posts: 82
    edited 2009-12-15 06:20
    Hi Peter, I still have the weird problem stated in the earlier mails. However, if i mount the Javelin onto Boe-Bot (B) it can function correctly. Only, when i mounted back the Javelin onto Boe-Bot (A), it did not function, it kept spinning Anti-Clockwise.

    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?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-12-15 10:43
    That is strange.
    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
Sign In or Register to comment.