Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
#include "sys/axon.h" #include "uart.h"#include "rprintf.h"#include "servos.h"#include "a2d.h"//Change the ports according to your servo connections:SERVO &Leg1_servo_1 = MAKE_SERVO(FALSE, C7,1500, 500);SERVO &Leg1_servo_2 = MAKE_SERVO(FALSE, A6,1500, 500); SERVO &Leg1_servo_3 = MAKE_SERVO(FALSE, E7,1500, 500);SERVO &Leg2_servo_1 = MAKE_SERVO(FALSE, H2,1500, 500);SERVO &Leg2_servo_2 = MAKE_SERVO(FALSE, C1,1500, 500);SERVO &Leg2_servo_3 = MAKE_SERVO(FALSE, A5,1500, 500);SERVO &Leg3_servo_1 = MAKE_SERVO(FALSE, E2,1500, 500);SERVO &Leg3_servo_2 = MAKE_SERVO(FALSE, H6,1500, 500);SERVO &Leg3_servo_3 = MAKE_SERVO(FALSE, C0,1500, 500);SERVO &Leg4_servo_1 =MAKE_SERVO(FALSE, A4,1500, 500);SERVO &Leg4_servo_2 =MAKE_SERVO(FALSE, E3,1500, 500);SERVO &Leg4_servo_3 =MAKE_SERVO(FALSE, H5,1500, 500);SERVO &Leg5_servo_1 =MAKE_SERVO(FALSE, C3,1500, 500);SERVO &Leg5_servo_2 =MAKE_SERVO(FALSE, J6,1500, 500);SERVO &Leg5_servo_3 =MAKE_SERVO(FALSE, E6,1500, 500);SERVO &Leg6_servo_1 =MAKE_SERVO(FALSE, H4,1500, 500);SERVO &Leg6_servo_2 =MAKE_SERVO(FALSE, C4,1500, 500);SERVO &Leg6_servo_3 =MAKE_SERVO(FALSE, A1,1500, 500);//make sure you know which servos are in which bank (better not change this arrangement)SERVO_LIST servo1[] = {&Leg1_servo_1};SERVO_LIST servo2[] = {&Leg2_servo_1};SERVO_LIST servo3[] = {&Leg3_servo_1};SERVO_LIST servo4[] = {&Leg4_servo_1};SERVO_LIST servo5[] = {&Leg5_servo_1};SERVO_LIST servo6[] = {&Leg6_servo_1};SERVO_LIST servo7[] = {&Leg1_servo_2,&Leg1_servo_3};SERVO_LIST servo8[] = {&Leg2_servo_2,&Leg1_servo_3};SERVO_LIST servo9[] = {&Leg3_servo_2,&Leg1_servo_3};SERVO_LIST servo10[]= {&Leg4_servo_2,&Leg1_servo_3};SERVO_LIST servo11[]= {&Leg5_servo_2,&Leg1_servo_3};SERVO_LIST servo12[]= {&Leg6_servo_2,&Leg1_servo_3};//Corresponding banks:SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(servo1);SERVO_DRIVER bank2 = MAKE_SERVO_DRIVER(servo2);SERVO_DRIVER bank3 = MAKE_SERVO_DRIVER(servo3); SERVO_DRIVER bank4 = MAKE_SERVO_DRIVER(servo4);SERVO_DRIVER bank5 = MAKE_SERVO_DRIVER(servo5);SERVO_DRIVER bank6 = MAKE_SERVO_DRIVER(servo6);SERVO_DRIVER bank7 = MAKE_SERVO_DRIVER(servo7);SERVO_DRIVER bank8 = MAKE_SERVO_DRIVER(servo8);SERVO_DRIVER bank9 = MAKE_SERVO_DRIVER(servo9);SERVO_DRIVER bank10 = MAKE_SERVO_DRIVER(servo10);SERVO_DRIVER bank11 = MAKE_SERVO_DRIVER(servo11);SERVO_DRIVER bank12 = MAKE_SERVO_DRIVER(servo12);#define threshold 8void appInitHardware(void){uartInit(UART1, 115200);rprintfInit(&uart1SendByte); // Initialising the servo controllerservosInit(&bank1, TIMER1_COMPAREA);servosInit(&bank2, TIMER3_COMPAREB);servosInit(&bank3, TIMER1_COMPAREB);servosInit(&bank4, TIMER1_COMPAREC);servosInit(&bank5, TIMER5_COMPAREB);servosInit(&bank6, TIMER3_COMPAREC);servosInit(&bank7, TIMER5_COMPAREA);servosInit(&bank8, TIMER3_COMPAREA);servosInit(&bank9, TIMER4_COMPAREA);servosInit(&bank10, TIMER4_COMPAREB);servosInit(&bank11, TIMER4_COMPAREC);servosInit(&bank12, TIMER5_COMPAREC);}// The loopStart parameter has the current clock value in uSTICK_COUNT appInitSoftware(TICK_COUNT loopStart){return 0;}TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){//now instead of 'values' (currently: 0) you can use variables later on...act_setSpeed{&Leg1_servo_1,0};act_setSpeed{&Leg2_servo_1,0};act_setSpeed{&Leg3_servo_1,0};act_setSpeed{&Leg4_servo_1,0};act_setSpeed{&Leg5_servo_1,0};act_setSpeed{&Leg6_servo_1,0};act_setSpeed{&Leg1_servo_2,0};act_setSpeed{&Leg2_servo_2,0};act_setSpeed{&Leg3_servo_2,0};act_setSpeed{&Leg4_servo_2,0};act_setSpeed{&Leg5_servo_2,0};act_setSpeed{&Leg6_servo_2,0};act_setSpeed{&Leg1_servo_3,0};act_setSpeed{&Leg2_servo_3,0};act_setSpeed{&Leg3_servo_3,0};act_setSpeed{&Leg4_servo_3,0};act_setSpeed{&Leg5_servo_3,0};act_setSpeed{&Leg6_servo_3,0};return 0; }
servosDisconnect(&bank2);servosDisconnect(&bank3);servosDisconnect(&bank4);servosDisconnect(&bank5);servosDisconnect(&bank6);servosDisconnect(&bank7);servosDisconnect(&bank8);servosDisconnect(&bank9);servosDisconnect(&bank10);servosDisconnect(&bank11);servosDisconnect(&bank12);
So basically, you'll be disconnecting all the servos except for the one is bank1. So now compile again, run, and check if servo: 'Leg1_servo_1' is running. If so, then try removing the disconnect command for more banks and see how many servos work, until Axon resets.Which battery do you use, 6V? _____mAh? .. and is your robot too heavy?
2300mAh is actually not so good for 18 servos... BUT... that is something that you should worry about later...If you've not built the robot yet, then the servos have no external torque, and your battery can easily handle all at a time, especially when fully charged.Later on, when you'd build the robot, you might notice, that due to the weight of the robot the servos get extra torque and the battery can't take it [btw, it still might take it when 'fully' charged]...But, you can simply buy another battery pack, and attach it in parallel, so that you have 6V and (2300+2300) 3600mAh [good enough]...However, do that only when you've built the robot, and you really require more Power.The other problem you would face is the Servos that would not hold extremely tight...but if your robot is not heavy enough (let me estimate and guess, up to 2kg) would work !...otherwise, if you can imagine, the legs/arm servos will slip due to weight. Good Luck.
#define threshold 8}// The loopStart parameter has the current clock value in uSTICK_COUNT appInitSoftware(TICK_COUNT loopStart){return 0;}TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){//now instead of 'values' (currently: 0) you can use variables later on...act_setSpeed{&Leg1_servo_1,0};act_setSpeed{&Leg2_servo_1,0};act_setSpeed{&Leg3_servo_1,0};act_setSpeed{&Leg4_servo_1,0};act_setSpeed{&Leg5_servo_1,0};act_setSpeed{&Leg6_servo_1,0};act_setSpeed{&Leg1_servo_2,0};act_setSpeed{&Leg2_servo_2,0};act_setSpeed{&Leg3_servo_2,0};act_setSpeed{&Leg4_servo_2,0};act_setSpeed{&Leg5_servo_2,0};act_setSpeed{&Leg6_servo_2,0};act_setSpeed{&Leg1_servo_3,0};act_setSpeed{&Leg2_servo_3,0};act_setSpeed{&Leg3_servo_3,0};act_setSpeed{&Leg4_servo_3,0};act_setSpeed{&Leg5_servo_3,0};act_setSpeed{&Leg6_servo_3,0};return 0; }
It can actually hold the load/weight and run all the 21 servos "when is it fully charged" for a few seconds (or minutes) depending on the load etc....