Shop OBEX P1 Docs P2 Docs Learn Events
Activity Board Question — Parallax Forums

Activity Board Question

ajwardajward Posts: 1,129
edited 2014-12-31 00:35 in Robotics
Hi All...

I'm having a problem getting my Activity Board to behave with my Boe Bot Chassis. I'm trying to run this code:
#include "simpletools.h"
#include "abdrive.h"

int main()                    
{
  drive_servoPins(12, 13);
  drive_speed(128, 128);
  pause(5000);
 }

When I load the code into EEPROM, the right servo only turns a couple of seconds and stops suddenly. The left keeps spinning a while longer and then slowly comes to a stop. I thought a bad servo, but if I reverse the leads, the left servo stops short and the right keeps spinning.
Something odd with the servo headers? I get the same results on pairs 12/13, 14/15 and 16/17.
Something wonky with my Activity Board? I get the same results with my Prop BOE.
Activity Board is new as are the high speed servos. Batteries are new and voltages are good. I can run a test program from spin and everything is fine.

I can only think it's something in the code that doesn't like not having encoder feedback, but I have no idea where to look! I would like to get the thing running without the encoders at first... if possible.

I'd appreciate any guidance!!! (Yeah... I'm getting the encoders when finances permit. Been off work a while waiting for knee surgery. BLEAH!)

Amanda

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-12-30 07:31
    ajward wrote: »
    I can only think it's something in the code that doesn't like not having encoder feedback, but I have no idea where to look! I would like to get the thing running without the encoders at first... if possible.

    I'm far from an expert on the ActivityBot but I'm pretty sure many of the functions in "abdrive.h" require encoder feedback. You'll want to find example code to just control a normal servo and control your CR servos with position commands.
  • Courtney JacobsCourtney Jacobs Posts: 903
    edited 2014-12-30 08:10
    To make your robot run without encoder feedback, add this just inside the main function:
    drive_feedback(0);
    

    Hopefully that solves your issue; if not, let us know.
  • ratronicratronic Posts: 1,451
    edited 2014-12-30 09:29
    You can use this code to make your Activity bot roll forward and backward for 1 second each way 4 times then stop without the encoders.
    #include "simpletools.h"                    
    #include "abdrive.h"
    
    int cntr = 0;
    
    int main() {
      
      drive_feedback(0);
      
      while(1) {
        
        drive_speed(50, 50);
        pause(1000);
        drive_speed(-50, -50);
        pause(1000);
        
        if (cntr++ > 2) {
          drive_speed(0, 0);
          break;
        }      
      }  
    }
    
  • ajwardajward Posts: 1,129
    edited 2014-12-30 09:31
    To make your robot run without encoder feedback, add this just inside the main function:
    drive_feedback(0);
    

    Hopefully that solves your issue; if not, let us know.

    Ah... That seems to have done the job!

    I'd noticed that in the header file, but by then I'd made so many changes I didn't want to muck up something else. I did a complete re-install of SimpleIDE thinking I'd =really= hosed something.

    Many thanks,

    Amanda
  • ajwardajward Posts: 1,129
    edited 2014-12-30 14:39
    Okey dokey... another question has come up. If I read the tutorials correctly, the command... drive_speed( -x, -x) "should" rotate the servos in "reverse". Somehow, it doesn't. When I issue a drive_speed command with a negative parameter the servo(s) with a negative parameter stop(s) immediately or never starts moving.

    I am back to using my Prop BOE, but I don't "think" that could be the problem... could it?

    I'm using SimpleIDE and coding in C... I find C easier that I thought it would be and, at the same time, quite maddening.

    Again, asking for guidance!

    Amanda
  • ratronicratronic Posts: 1,451
    edited 2014-12-30 14:54
    Have you made sure the left servo is plugged into P12 and the right servo to P13?

    Also are you using the high speed servo's? If your using regular cont. rot. servos the speed in the code I posted needs to be bumped up a bit.

    With the high speed servo's positive #'s go forward and negative #'s in reverse for both sides.
  • ajwardajward Posts: 1,129
    edited 2014-12-30 15:04
    ratronic wrote: »
    Have you made sure the left servo is plugged into P12 and the right servo to P13?

    Also are you using the high speed servo's? If your using regular cont. rot. servos the speed in the code I posted needs to be bumped up a bit.

    With the high speed servo's positive #'s go forward and negative #'s in reverse for both sides.

    I'm using the Prop BOE and the servos are connected to pins 14/15. I'm using HS servos. Running your code, the servos run forward and stop four times. Never backward!?

    Amanda
  • ratronicratronic Posts: 1,451
    edited 2014-12-30 15:21
    I'm sure you have already centered the servos for stop. Maybe try this code with using the servo library. They should spin forward for one second then reverse for one second.

    Edit You can change the pin#'s I can't remember where the PropBOE servo's are connected.
    #include "simpletools.h"                    
    #include "servo.h"
    
    int main() {
     servo_set(12, 1550);
     servo_set(13, 1450);
     pause(1000);
     servo_set(12, 1450);
     servo_set(13, 1550);
     pause(1000);
     servo_set(12, 1500);
     servo_set(13, 1500);
    }
    
  • Courtney JacobsCourtney Jacobs Posts: 903
    edited 2014-12-30 15:43
    Hi Amanda.

    So I didn't realize (though I probably should have) that you were using a robot that hadn't been calibrated before, and that would definitely be the cause of the issue you're having.

    The abdrive library works by assuming you have initial calibration data, even if your encoders are not providing feedback. Without being able to calibrate your robot you'll need to use the servodiffdrive library instead, and its functions are similar but not exactly the same as abdrive.

    Andy Lindsay provided a little program to test my theory here (below):
    #include "simpletools.h"
    #include "servodiffdrive.h"
    
    int main()
    {
      drive_pins(12, 13);
      drive_speeds(64, 64);
      pause(2000);
      drive_speeds(-64, 64);
      pause(2000);
      drive_speeds(64, -64);
      pause(2000);
      drive_speeds(-64, -64);
      pause(2000);
      drive_speeds(0, 0);  
    }
    

    Try that and let us know how it goes.
  • ajwardajward Posts: 1,129
    edited 2014-12-31 00:35
    Hi Amanda.

    So I didn't realize (though I probably should have) that you were using a robot that hadn't been calibrated before, and that would definitely be the cause of the issue you're having.

    The abdrive library works by assuming you have initial calibration data, even if your encoders are not providing feedback. Without being able to calibrate your robot you'll need to use the servodiffdrive library instead, and its functions are similar but not exactly the same as abdrive.

    Andy Lindsay provided a little program to test my theory here (below):

    *code snipped*

    Try that and let us know how it goes.

    So far that seems to work! I didn't realize how much abdrive depended on the encoders.
    I'm working on the "Detect and Turn From Obstacle" lesson. Still doesn't do quite what I expect, but I no longer think the servos are munging things up.
    Burning the midnight oil! :-)

    Amanda

    Edit: Actually, it does do what it should. My expectations were different than what the code was supposed to do.
    Many thanks to Courtney and Dave for their prompt responses and assistance!!!!!!!!!!!
Sign In or Register to comment.