Saturday, April 26, 2014

Coordinated Movement

In order to achieve smooth movement of the panels, we devised a panel pan function to step through the servo positions with a delay.

void panelPan(void const *args) {
    int* argv = (int*) args;
    int panel = argv[0];
    int deg = argv[1];
    int depth = argv[2];
    int speed = argv[3];
    printf("depth = %d\r\n", speed);
    //speed =10 default
    if(speed == NULL) speed = 10;
    int i;
    for(i=0;i<depth;i++) {
        setPanelAngle(panel,deg,i);
        wait(speed);
        }
    for(i=depth;i>=0;i--) {
        setPanelAngle(panel,deg,i);
        wait(speed);
    }
   }


Due to the presence of the wait function, the movement of one panel would lock up the entire mBed and only one panel would be able to move at a time. To overcome this problem we turned to the mBed RTOS library. We ran each panelPan function in a separate thread and terminated all threads at the end of a specified motion, see the left to right function below.

void leftToRight() {
    

    int p0[] = {0,0,30,4};
    int p1[] = {1,0,30,4};
    int p2[] = {2,0,30,4};
    int p3[] = {3,0,30,4};
    int p4[] = {4,0,30,4};
    int p5[] = {5,0,30,4};
    int p6[] = {6,0,30,4};
   
    Thread panel1(panelPan, (void *) &p1);
    Thread panel6(panelPan, (void *) &p6);
    wait(.2);
   
    Thread panel2(panelPan, (void *) &p2);
    Thread panel0(panelPan, (void *) &p0);
    Thread panel5(panelPan, (void *) &p5);
    wait(.2);
   
    Thread panel3(panelPan, (void *) &p3);
    Thread panel4(panelPan, (void *) &p4);
    wait(1);
   
    panel0.terminate();
    panel1.terminate();
    panel2.terminate();
    panel3.terminate();
    panel4.terminate();
    panel5.terminate();
    panel6.terminate();
    wait(.3);


This allowed us to achieve a variety of movements as shown in the following video




One of the main challenges that we faced from a hardware perspective was current limitations. When the servo's were first powered on they draw about 1.5x their load amperage, so the power supply current limit had to be raised to provide this, in hindsight it would have been prudent to attach a large capacitor to the servo controller board to account for the spike in current draw. Additionally, in the video above, the bottom left panel never moves on the y axis. We discovered that the stabilizer axle was too tight and as a result the servo burned out and the internal gears fused preventing motion. Idle amperage draw further increased to between 1 and 2 amps due to the increased weight of the final panel design.

No comments:

Post a Comment