Saturday, October 13, 2012

October 13th Meeting

Ben's secondary robot.
Today, Ian worked on our chain-related components of our robots, as Jared worked on organizing the wiring on the robot and fixing other small details in the robot. Ben started to make a second robot, primarily for testing things that require another robot to test, like our endgame task. I worked on making our infrared values more accurate with a spinning radar-like mount. It is working good and is around 90% bug free at the moment. A code sample is posted below:

#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     HTIRS2,         sensorI2CCustom)
#pragma config(Motor,  motorA,          spinner,       tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_1,     Wheel_Left,    tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     Wheel_Right,   tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/HTIRS2-driver.h"

task spin();

task main ()
{
    int _dirDC = 0;
    int _dirAC = 0;
    int _distDCsum = 0;
    int dcS1, dcS2, dcS3, dcS4, dcS5 = 0;
    int acS1, acS2, acS3, acS4, acS5 = 0;
   
    int total = 0;
    int count = 0;
    int combinedavg = 0;

    nxtDisplayTextLine(1, "Display Error!");
   
    StartTask(spin);

    while (true)
    {
        _dirDC = HTIRS2readDCDir(HTIRS2);
        if (_dirDC < 0)
            break;
        _dirAC = HTIRS2readACDir(HTIRS2);
        if (_dirAC < 0)
            break;
        if (!HTIRS2readAllDCStrength(HTIRS2, dcS1, dcS2, dcS3, dcS4, dcS5))
            break;
        if (!HTIRS2readAllACStrength(HTIRS2, acS1, acS2, acS3, acS4, acS5 ))
            break;
        _distDCsum = (dcS1 + dcS2 + dcS3 + dcS4 + dcS5);
        ClearTimer(T1);
        while(time1[T1] < 1600)
        {
            total = total + _dirDC;
           
            if (_dirDC != 0)
            {
                count = count + 1;
            }
        }
       
        int _dirAvgSpin = 0;
        _dirAvgSpin = abs(total / count);
        combinedavg = (combinedavg + _dirAvgSpin) / count;
       
        nxtDisplayTextLine(4, "DistAvg: %d", _dirAvgSpin);
        nxtDisplayTextLine(3, "AverageAvg: %d", combinedavg);
    }
}

task spin()
{
    while(true)
    {
        motor[spinner] = 15;
        wait1Msec(800);
        motor[spinner] = -15;
        wait1Msec(800);
    }
}

No comments:

Post a Comment