Go to Post I'll guess those tie-dyed, numbered balls are used for alliance-partner lotto. :D - Richard Wallace [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 26-11-2011, 10:19
Team 2844 Team 2844 is offline
Registered User
FTC #2844
 
Join Date: Jan 2010
Location: Arizona
Posts: 2
Team 2844 is an unknown quantity at this point
Re: [FTC]: HiTechnic Magnetic Sensor

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  HTServo)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Sensor, S2,     HTMAG,               sensorHiTechnicMagnetic)
#pragma config(Sensor, S3,     ,                    sensorLightActive)
#pragma config(Motor,  motorA,          motorA,        tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorB,          motorB,        tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorC,          motorC,        tmotorNormal, PIDControl, reversed, encoder)
#pragma config(Motor,  mtr_S1_C1_1,     motorRight,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorLeft,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motorL,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     motorF,     tmotorNormal, openLoop, reversed)
#pragma config(Servo,  srvo_S1_C3_1,    Mag1,                 tServoStandard)
#pragma config(Servo,  srvo_S1_C3_2,    lift2,                tServoStandard)
#pragma config(Servo,  srvo_S1_C3_3,    leftflap3,            tServoStandard)
#pragma config(Servo,  srvo_S1_C3_4,    rightflap4,           tServoStandard)
#pragma config(Servo,  srvo_S1_C3_5,    MagR5,                tServoStandard)
#pragma config(Servo,  srvo_S1_C3_6,    MagG,                 tServoStandard)
#pragma config(Servo,  srvo_S1_C4_1,    fL7,               tServoStandard)
#pragma config(Servo,  srvo_S1_C4_2,    fR8,               tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"  //Include file to "handle" the Bluetooth messages.

bool btn2Pressed = false;
bool MagnetReleaseIsUp = false;

void initializeRobot()
{
  servoTarget[Mag1] = 127;
  servoTarget[lift2] = 0;
  servoTarget[leftflap3] = 23;
  servoTarget[rightflap4] = 112;
  servoTarget[fL7] = 0;
  servoTarget[fR8] = 0;
  servoTarget[MagR5] = 0;

  return;
}

void processMagnet()
{
    if(SensorValue[HTMAG] > 670) // Magnetic Ball
    {
      servoTarget[Mag1] = 230;
      wait1Msec(1000);
    }
    else if(SensorValue[HTMAG] < 660)// Magnetic Ball
    {
      servoTarget[Mag1] = 230;
      wait1Msec(1000);
    }
    else
    {
      servoTarget[Mag1] = 127;
    }
}

task main()
{
  initializeRobot();

  waitForStart();   // wait for start of tele-op phase

  while (true)
  {

    getJoystickSettings(joystick);
    processMagnet();
    motor[motorLeft] = joystick.joy1_y1;
    motor[motorRight] = joystick.joy1_y2;
In our case, we sort the magnetic ball by a servo. What we did was tap into the servo wires, negative and positive, and attached a LED to that. On our old robot we only determined the magnetic ball by a LED that was hooked into the motor port, really just acting like a motor turning off and on.

Up above you can see the beginning of our teleopcode, you need to have the void magnet before the while true like we have above. put the processMagnet in the while true like we have above too.

I know how you feel, it took me and another team forever last year to find out this.

Hope this helps.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi