Shop OBEX P1 Docs P2 Docs Learn Events
ActivityBot Does not want to Stop — Parallax Forums

ActivityBot Does not want to Stop

I used the code below to try to program my ActivityBot to stop moving once it is 20cm away from an object. Instead of stopping completely, it keeps turning around slowly. It seems the problem is that drive_ramp(0, 0) is causing the wheels to turn for some reason.
#include "simpletools.h"                      
#include "abdrive.h"                         
#include "ping.h"                             

int main()                                  
{
  drive_setRampStep(10);                     

  drive_ramp(128, 128);                     

 
  while(ping_cm(8) >= 20) pause(5);           

  drive_ramp(0, 0);                           
                    
  drive_speed(0, 0);                                                                           

  while(ping_cm(8) < 20);                    

  drive_ramp(0, 0);                           
}

Comments

  • ercoerco Posts: 20,254
    Did you null your servos?
  • ........And run the Calibration program?
  • Courtney JacobsCourtney Jacobs Posts: 903
    edited 2016-02-02 18:58
    Sometimes servos can be so out of center that the calibration program does not work properly.

    If you run the calibration program and still get some slight rotation when the robot should be still, try manually centering the servos (gently) using a screwdriver and then run the calibration program again. It is very important to always re-calibrate after manual centering of ActivityBot servos; do not forget to do so or you will see strange behaviour.

    Here is some code to run that will allow you to manually center ActivityBot servos:
    /*
      ActivityBot Centering.c
    */
    #include "simpletools.h"                      // Include simple tools
    #include "servo.h"
    
    int main()                                    // Main function
    {
      servo_set(12, 1500);                 // Left servo
      servo_set(13, 1500);                 // Right servo
    }
    
  • ercoerco Posts: 20,254
    edited 2016-02-02 21:05
    Another issue is the battery condition. The null point of analog servos can drift if the supply voltage changes enough. Aren't AB's servos powered directly by Vin? Alkaline batteries are dreadful, always dying, voltage dropping, and the source of many woes WRT a "stopped" servo not actually stopping. Rechargeable NiMH batteries are better, LiPo or Li-Ion the best. Analog servos really need their own separate voltage regulator for consistent performance.
  • BleuBoxBleuBox Posts: 13
    edited 2016-02-12 22:06
    That probably is the problem.
Sign In or Register to comment.