Shop OBEX P1 Docs P2 Docs Learn Events
Servo callibration? — Parallax Forums

Servo callibration?

pdmartpdmart Posts: 4
edited 2009-10-19 19:48 in General Discussion
I have around 40 BoEs and Javelin Stamps, and about 10 of the robots are experiencing difficulties when trying to run the servos. The servos are calibrated when sending a pulseOut of 173, and they seem to be calibrated but on reset they become uncalibrated. In fact, on sequential resets the servos go one way and then the other way without changing any code. Any ideas? These robots are working fine with the BASIC stamp.

Thanks in advance.

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-10-19 02:31
    pdmart,

    Can you send an example of the code that you are using?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • pdmartpdmart Posts: 4
    edited 2009-10-19 18:01
    I'm writing this by hand from another computer rather than copying and pasting, so if there are any syntax errors
    please ignore them.

    import stamp.core.*;
    public class ServoTest{
         public static void main(){
    
              // forward
              for(int i = 0; i < 1000; i++){
                   CPU.pulseOut(220, CPU.pin13);
                   CPU.pulseOut(130, CPU.pin12);
              }
              CPU.pulseOut(173, CPU.pin13);
              CPU.pulseOut(173, CPU.pin12);
    
              // still
              for(int i = 0; i < 1000; i++){
                   CPU.pulseOut(173, CPU.pin13);
                   CPU.pulseOut(173, CPU.pin12);
              }
              CPU.pulseOut(173, CPU.pin13);
              CPU.pulseOut(173, CPU.pin12);
    
              // backwards
              for(int i = 0; i < 1000; i++){
                   CPU.pulseOut(130, CPU.pin13);
                   CPU.pulseOut(220, CPU.pin12);
              }
              CPU.pulseOut(173, CPU.pin13);
              CPU.pulseOut(173, CPU.pin12);
    
              // calibrate
              for(int i = 0; i < 10000; i++){
                   CPU.pulseOut(173, CPU.pin13);
                   CPU.pulseOut(173, CPU.pin12);
              }
              CPU.pulseOut(173, CPU.pin13);
              CPU.pulseOut(173, CPU.pin12);
         }
    }
    
    
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-10-19 19:09
    pdmart,

    In addition to an "ON" time pulse ranging from 1ms to 2ms, you also need to have an "OFF" time of 15ms to 25ms (Typically 20ms). You may be setting the "OFF" time somewhere else in your code, but I don't see it in the code you have provided. The "ON" time looks ok to me.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-10-19 19:32
    Normally servos are controlled by using the PWM VP.
    Value 115 represents 1 msec
    Value 173 represents 1.5 msec
    Value 230 represents 2 msec
    Value 2304 represents 20 msec

    PWM servo = new PWM(CPU.pin0,173,2304)
    servo.update(115,2304) 'full left
    servo.update(173,2304) 'center
    servo.update(230,2304) 'full right

    Using pulseOut() is too awkward as pulses must be generated every 20 msec.
    The PWM VP does that·for·you in the background.

    regards·peter
  • pdmartpdmart Posts: 4
    edited 2009-10-19 19:48
    Thanks for the quick responses. I'll try this out.
Sign In or Register to comment.