View Single Post
  #1   Spotlight this post!  
Unread 21-01-2014, 14:41
Sasha Sasha is offline
Registered User
AKA: Alexander Kirillov
FTC #4137 (IslandBots)
Team Role: Coach
 
Join Date: Sep 2010
Rookie Year: 2008
Location: Long Island, NY
Posts: 58
Sasha is just really niceSasha is just really niceSasha is just really niceSasha is just really niceSasha is just really nice
Re: [FTC]: FTC Multiplexer

Yes, we are using the sensor multiplexor, using the 3rd party driver suite
Here is the appropriate part of our autonomous program. Hope it helps.

Code:
#pragma config(Hubs,  S2, HTMotor,  HTServo,  HTMotor,  none)
#pragma config(Sensor, S1,     HTSMUX,              sensorI2CCustom)
#pragma config(Sensor, S3,     IRsensor,       sensorI2CCustom)
#pragma config(Sensor, S4,     GyroSensor,     sensorI2CHiTechnicGyro)
#pragma config(Motor,  motorA,          BlockDrop,     tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  mtr_S2_C1_1,     winch,         tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     right,         tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S2_C3_1,     arm,           tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C3_2,     left,          tmotorTetrix, openLoop, reversed)
#pragma config(Servo,  srvo_S2_C2_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_6,    grabber,              tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/hitechnic-gyro.h"
#include "drivers/hitechnic-irseeker-v2.h"
#include "drivers/hitechnic-sensormux.h"
#include "drivers/lego-light.h"
#include "JoystickDriver.c"
const tMUXSensor LightSensorLeft = msensor_S1_1;
const tMUXSensor LightSensorRight = msensor_S1_4;

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Global variables
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
int initialLightLeft, initialLightRight;

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Checks whether light sensor sees white line
//
/////////////////////////////////////////////////////////////////////////////////////////////////////



bool LeftOnBlack(){ //returns true if left light sensor is on black
  return (LSvalNorm(LightSensorLeft) <= 10 + initialLightLeft);
}

bool RightOnBlack(){ //returns true if right light sensor is on black
  return (LSvalNorm(LightSensorRight) <= 10 + initialLightRight);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                    initializeRobot
/////////////////////////////////////////////////////////////////////////////////////////////////////

void initializeRobot()
{
  // Place code here to sinitialize servos to starting positions.
  // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.
  LSsetActive(LightSensorLeft);//turn on the light
  LSsetActive(LightSensorRight);//turn on the light
  initialLightLeft=LSvalNorm(LightSensorLeft);
  initialLightRight=LSvalNorm(LightSensorRight);
  return;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                         Main Task
//
/////////////////////////////////////////////////////////////////////////////////////////////////////


task main()
{
  initializeRobot();
  StartTask(printStuff);
  waitForStart(); // Wait for the beginning of autonomous phase.
  
  motor[right]=30;motor[left]=30;
  //wait until one of the sensors sees white
  while (LeftOnBlack() && RightOnBlack() ) {
   wait1Msec(1);
  }
  motor[right]=0;motor[left]=0;
  PlaySound(soundBeepBeep);
  wait10Msec(50);
}
Reply With Quote