View unanswered posts | View active topics It is currently Mon Jul 28, 2014 12:50 am






Reply to topic  [ 8 posts ] 
Drive, Motors Problem 
Author Message
Novice

Joined: Mon Oct 18, 2010 9:31 pm
Posts: 86
Post Drive, Motors Problem
Hello FTC RobotC world Again. Nice to be in another season of FTC.

For some reason, I am having a problem with the basic, drive two motors... I dont know why. I am on a new laptop this year, and wondering if that could be the problem that I am having. I dont know.

I am using the part of the same code as last year right now, just to get the robot started. It worked on the old robot then, but wont work now. Could you help me? Code is below. I am using Windows 7 if that has to do anything with it.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  HTServo)
#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,     motorLeft,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorRight,    tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motorF,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     motorG,     tmotorNormal, openLoop, reversed)
#pragma config(Servo,  srvo_S1_C3_1,    trailer1,             tServoStandard)
#pragma config(Servo,  srvo_S1_C3_2,    trailer2,             tServoStandard)
#pragma config(Servo,  srvo_S1_C3_3,    Gate,                 tServoStandard)
#pragma config(Servo,  srvo_S1_C3_4,    servo4,               tServoStandard)
#pragma config(Servo,  srvo_S1_C3_5,    servo5,               tServoStandard)
#pragma config(Servo,  srvo_S1_C3_6,    Twist,                tServoStandard)
#pragma config(Servo,  srvo_S1_C4_1,    Gauge,                tServoStandard)
#pragma config(Servo,  srvo_S1_C4_2,    servo8,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_3,    servo9,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_4,    servo10,              tServoNone)
#pragma config(Servo,  srvo_S1_C4_5,    servo11,              tServoNone)
#pragma config(Servo,  srvo_S1_C4_6,    servo12,              tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

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

void initializeRobot()
{
  servoTarget[trailer1] = 0;
  servoTarget[trailer2] = 0;
  servoTarget[Gate] = 0;
  servoTarget[servo4] = 0;
  servoTarget[servo5] = 0;
  servoTarget[Twist] = 0;

  return;
}

void processMagnet()
{
    if(SensorValue[HTMAG] > 790) // Baton #1
    {
      motor[motorLift] = 120;
      wait1Msec(500);
    }
    else if(SensorValue[HTMAG] > 700)//Baton #2
    {
      motor[motorLift] = 120;
      wait1Msec(500);
    }
    else if(SensorValue[HTMAG] > 670)//Baton #3
    {
      motor[motorLift] = 120;
      wait1Msec(500);
    }
    else if(SensorValue[HTMAG] < 600)// Baton #1
    {
      motor[motorLift] = 120;
      wait1Msec(500);
    }
    else if(SensorValue[HTMAG] < 640)//Baton #2
    {
      motor[motorLift] = 120;
      wait1Msec(500);
    }
    else if(SensorValue[HTMAG] < 661)//Baton #3
    {
      motor[motorLift] = 120;
      wait1Msec(500);
    }
    else
    {
      motor[motorLift] = 0;
    }
}

task main()
{
  initializeRobot();

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

  while (true)
  {

    processMagnet();
    motor[motorLeft] = joystick.joy1_y1;
    motor[motorRight] = joystick.joy1_y2;
  }
}


Wed Oct 05, 2011 5:19 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Drive, Motors Problem
You didn't say what's not working. But from looking at the code, your teleop is definitely not working because you did not read the joystick packet. I don't have RobotC in front of me so I don't remember the exact statement but it is something like. And it should be in the while loop before processMagnet().
Code:
getJoystickSettings();


Wed Oct 05, 2011 6:41 pm
Profile
Novice

Joined: Mon Oct 18, 2010 9:31 pm
Posts: 86
Post Re: Drive, Motors Problem
Opps, sorry. When I run the program, the driving base motors wont move. I know the program is running though cause the magnetic sensor works and runs a motor when i put a ball next to it. I added that bit into the code, but I am getting alot of errors.

Code:
File "TeleOp 1.c" compiled on Oct 05 2011 16:25:41
**Error**:Ummatched left parenthesis '('
**Error**:Expected->')'. Found 'joystickCopy'
**Error**:Procedure call Parameters don't match declaration for 'memcpy(void & pToBuffer, const void & pFromBuffer, const short nNumbOfBytes)'
**Error**:Expected->';'. Found 'joystickCopy'
**Error**:Expected->';'. Found ','
**Error**:Unexpected scanner token-> ','
**Error**:Unexpected scanner token-> 'sizeof'
**Error**:Unexpected scanner token-> '('


Wed Oct 05, 2011 7:28 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Drive, Motors Problem
Like I said I do not have RobotC in front of me, but I went to our source control server and looked at our old code, the exact line should be:
Code:
getJoystickSettings(joystick);


Wed Oct 05, 2011 7:48 pm
Profile
Novice

Joined: Mon Oct 18, 2010 9:31 pm
Posts: 86
Post Re: Drive, Motors Problem
Haha, thank you so much. You have helpped me out more than I can count. That worked. I find it wierd though, cause we havent had that in our code for the last 3 years, and we have gotten it to work. haha. Thanks.


Wed Oct 05, 2011 8:16 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Drive, Motors Problem
You are welcome. How did last year's competition go? Did your code work as expected?


Wed Oct 05, 2011 8:19 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Drive, Motors Problem
Team2844 wrote:
I find it wierd though, cause we havent had that in our code for the last 3 years, and we have gotten it to work. haha. Thanks.

I don't have RobotC in front of me so I can't confirm at this moment but I think there may be a system task who's been calling getJoystickSettings for you in previous years. There are changes to the joystick support this year so it might have been stopped doing that. But in any case, it is always good to call it yourself not relying on other tasks doing it for you.


Wed Oct 05, 2011 8:25 pm
Profile
Rookie

Joined: Tue Dec 06, 2011 5:13 am
Posts: 1
Post Re: Drive, Motors Problem
your teleop is definitely not working




Mark
"training on the use of my expandable batons and mastering it"


Tue Dec 06, 2011 8:47 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.