perplexing problem with activity bot
solder_fumes
Posts: 18
I had my activity bot (remote control, with track treads) working nicely, then decided to add the Li-on power pack to it. I don't think the power pack is responsible for my issue, but something has changed.
My setup is this...a Propeller activity board on the bot, another Propeller board as the remote controller, and a total of three x-bee's, one one each propeller board, and one as a "traffic monitor"
.
The code is pretty simple, I send a "f", "b", "l" or "r" depending on which way I want it to go, or if no direction button is pressed (i.e., the five position switch is in the center) it send an "s" for "stand still".
When I power everything up, the "s" is continually transmitted (and I can see it on the traffic monitor xbee), and the bot sits there as is should. FIne.
As soon as I hit the forward switch, both servos turn to drive it forward. But after about 4 seconds, the right servo comes to a stop, while the left one keeps spinning.
When I send "b" (for backup), the right servo does nothing, and the left servo continues to drive forwards.In fact, regardless of which direction I toggle the switch (it's the Parallax 5 position switch), the left serve drives forwards. The right servo does nothing.
Occasionally, one servo will stop in mid-rotation and reverse itself.
If I power down the bot and start it again everything sits idle, then as soon as I hit the switch to send it in any direction, the above behavior is repeated.
I'm fairly new to the Propeller and C, so hopefully I've just done something dumb with the code.
Thoughts?
My setup is this...a Propeller activity board on the bot, another Propeller board as the remote controller, and a total of three x-bee's, one one each propeller board, and one as a "traffic monitor"
.
The code is pretty simple, I send a "f", "b", "l" or "r" depending on which way I want it to go, or if no direction button is pressed (i.e., the five position switch is in the center) it send an "s" for "stand still".
When I power everything up, the "s" is continually transmitted (and I can see it on the traffic monitor xbee), and the bot sits there as is should. FIne.
As soon as I hit the forward switch, both servos turn to drive it forward. But after about 4 seconds, the right servo comes to a stop, while the left one keeps spinning.
When I send "b" (for backup), the right servo does nothing, and the left servo continues to drive forwards.In fact, regardless of which direction I toggle the switch (it's the Parallax 5 position switch), the left serve drives forwards. The right servo does nothing.
Occasionally, one servo will stop in mid-rotation and reverse itself.
If I power down the bot and start it again everything sits idle, then as soon as I hit the switch to send it in any direction, the above behavior is repeated.
I'm fairly new to the Propeller and C, so hopefully I've just done something dumb with the code.
Thoughts?
/* Code for ActivityBot - motors only */ #include "simpletools.h" // Include libraries #include "fdserial.h" #include "abdrive.h" fdserial *xbee; int main() // Main function { xbee = fdserial_open( 9, 8, 0, 9600 ); // Begin the serial connection char data; // Create the variable that will be used to hold // the incoming data while ( 1 ) // Repeat this forever or until loss of power { data = fdserial_rxChar( xbee ); // Set data to the data received from the XBee board if ( data == 'f' ) // If the data incoming is telling the robot to move forward { drive_speed( 64, 64 ); // Move forward at 1/2 speed } else if ( data == 'b' ) // If the data incoming is telling the robot to move backward { drive_speed( -64, -64 ); // Move backward at 1/2 speed } else if ( data == 'l' ) // If the data incoming is telling the root to turn left { drive_speed( -32, 32 ); // Turn left in a spin turn at 1/2 speed } else if ( data == 'r' ) // If the data incoming is telling the robot to turn right { drive_speed( 32, -32 ); // Turn right in a spin turn at 1/2 speed } else if ( data == 's' ) // If the data incoming is telling the robot to stop { drive_speed( 0, 0 ); // Stop } } }
/* Five axis joystick control board code */ #include "simpletools.h" // Include simpletools #include "fdserial.h" fdserial *xbee; int main() // Main function { xbee = fdserial_open (29, 28, 0, 9600); while(1) // Loop repeats indefinitely { int button_forward = input(4); //assign inputs to direction and functional controls int button_reverse = input(2); //movement controls are wired as active-low pull-up int button_right = input(1); //firing and gripper controls are wired as active-high int button_left = input(3); int button_fire = input(8); //activates relay int button_open = input(7); //opens gripper int button_close = input(6); //closes gripper if (button_forward == 0) { dprint (xbee, "f" ); // send "go forward" command to robot, and so on... print("forward"); // prints verification of command to terminal and so on... pause(500); } else if (button_reverse == 0) { dprint (xbee, "b" ); // backup print("back up", CLS); pause(500); } else if (button_right == 0) { dprint (xbee, "r" ); //turn right print("right", CLS); pause(500); } else if (button_left == 0) { dprint (xbee, "l" ); //turn left print("left", CLS); pause(500); } else if (button_fire == 1) //fires relay { dprint (xbee, "x"); print("FIRE!", CLS); pause(500); } else if (button_open == 1) //open gripper { dprint (xbee, "o"); print("open", CLS); pause(500); } else if (button_close == 1) //close gripper { dprint (xbee, "c"); print("close", CLS); pause(500); } else if ( button_forward == 1, button_reverse == 1, button_right == 1, button_left == 1 ) { dprint (xbee, "s"); //stand still print("stand still", CLS); pause(500); } } }
Comments
I did find that if I leave things powered long enough, eventually one of the servos will come to a slow slow halt (that is, gradually slowing down then stopping...and this is with the bench power supply that is providing constant voltage). If I wait long enough, it will start up on its own. This without sending any directional input to it at all.
Thanks,
John
Weird.....Have you tried viewing what is being sent by your transmitting board continuously on the terminal? That will tell you whether the problem is the bot or your code.
Also if the problem is your bot, do you have other/another board/boards that you can use to test with?
Finally, do you have any other servos that you can use to test the connections to make sure it is not a problem with the servos? Have you calibrated your servos correctly?
Good luck,
ValeT