View unanswered posts | View active topics It is currently Sat Apr 19, 2014 7:32 pm






Reply to topic  [ 5 posts ] 
Motor only turning one direction! ?? 
Author Message
Rookie
User avatar

Joined: Tue Feb 01, 2011 10:31 pm
Posts: 6
Location: Houston, TX
Post Motor only turning one direction! ??
Hello everybody, I am new to FTC and Tetrix and I'm having this weird problem. For some reason, one of the motors only turns one direction and not the other. Can anyone help me please!?
Thanks!

_________________
VRC 6197A Mentor 2012-
FRC 441 Mentor 2012-
FRC 441 Alumni 2009-2012
VRC 441B Alumni 2010-2012
FTC 4673 Alumni 2011-2012
FRC 1484 Alumni 2006-2008


Tue Feb 01, 2011 10:36 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1343
Post Re: Motor only turning one direction! ??
What does your code look like?


Wed Feb 02, 2011 12:57 am
Profile
Rookie
User avatar

Joined: Tue Feb 01, 2011 10:31 pm
Posts: 6
Location: Houston, TX
Post Re: Motor only turning one direction! ??
Here it is but, today, I moved that motor to another port on another controller and it turned in
both directions.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  none)
#pragma config(Hubs,  S2, HTMotor,  none,     none,     none)
#pragma config(Motor,  motorA,          ,              tmotorNormal, openLoop)
#pragma config(Motor,  motorB,          ,              tmotorNormal, openLoop)
#pragma config(Motor,  motorC,          ,              tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motorF,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C2_2,     motorG,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     motorH,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     motorI,        tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                           Tele-Operation Mode Code Template
//
// This file contains a template for simplified creation of an tele-op program for an FTC
// competition.
//
// You need to customize two functions with code unique to your specific robot.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

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


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                    initializeRobot
//
// Prior to the start of tele-op mode, you may want to perform some initialization on your robot
// and the variables within your program.
//
// In most cases, you may not have to add any code to this function and it will remain "empty".
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

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.

  return;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                         Main Task
//
// The following is the main code for the tele-op robot operation. Customize as appropriate for
// your specific robot.
//
// Game controller / joystick information is sent periodically (about every 50 milliseconds) from
// the FMS (Field Management System) to the robot. Most tele-op programs will follow the following
// logic:
//   1. Loop forever repeating the following actions:
//   2. Get the latest game controller / joystick settings that have been received from the PC.
//   3. Perform appropriate actions based on the joystick + buttons settings. This is usually a
//      simple action:
//      *  Joystick values are usually directly translated into power levels for a motor or
//         position of a servo.
//      *  Buttons are usually used to start/stop a motor or cause a servo to move to a specific
//         position.
//   4. Repeat the loop.
//
// Your program needs to continuously loop because you need to continuously respond to changes in
// the game controller settings.
//
// At the end of the tele-op period, the FMS will autonmatically abort (stop) execution of the program.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

task main()
{

  while(1)
  {
    getJoystickSettings(joystick);

    motor[motorF] = joystick.joy1_y1;
    motor[motorE] = joystick.joy1_y2;

      getJoystickSettings(joystick);

      if(joy1Btn(4))
      {
      motor[motorG] = 50
      }
      else
      {
      motor[motorG] = 10
      }

      if(joy1Btn(2))
      {
      motor[motorG] = -50
      }
      else


   if(joy1Btn(6))
   {
   servo[servo1] = 135;
   }

   if(joy1Btn(5))
   {
   servo[servo1] = 250;
   }

 }
}

_________________
VRC 6197A Mentor 2012-
FRC 441 Mentor 2012-
FRC 441 Alumni 2009-2012
VRC 441B Alumni 2010-2012
FTC 4673 Alumni 2011-2012
FRC 1484 Alumni 2006-2008


Wed Feb 02, 2011 9:03 pm
Profile WWW
Rookie

Joined: Sun Feb 21, 2010 4:19 pm
Posts: 9
Post Re: Motor only turning one direction! ??
Looks like you forgot several semicolons in the middle of your button commands.

In addition to that, you probably have to finish up the else statement for the second button command.

Pressing F7 will compile your program and show you any errors you have.

You probably only want to refer to motor G using only 1 if statement at a time - unless you use a seperate condition for each if statement. Otherwise, you will merely overwrite your robots commands using a second statement.

Finally, you can make your program much clearer if you go to Robot - Motors and Sensors setup and then apply names to some of your motors. This will allow you to refer to your motors as something clearer than motor A or motor G.


Thu Feb 10, 2011 9:14 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1343
Post Re: Motor only turning one direction! ??
In addition, it seems you are doing tank drive but you are applying your joystick readings directly to your motors. Please note that the motor range is -100 to 100 but the joystick range is -128 to 127. So you may have unexpected result if you don't convert the range properly. Do something like this. And also, the second getJoystickSettings(joystick) is not necessary.
Code:
//
// The DEAD_BAND macro makes sure non-zero-centered joystick won't move the robot.
//
#define DEAD_BAND(n, t) ((abs(n) < (t))? 0: (n))
//
// The MOTOR_POWER macro translates the joystick range of (-128 to 127) to the motor
// power range of (-100 to 100) after applying DEAD_BAND to the joystick value.
//
#define MOTOR_POWER(n)  (DEAD_BAND(n, 15)*100/128)

    motor[motorF] = MOTOR_POWER(joystick.joy1_y1);
    motor[motorE] = MOTOR_POWER(joystick.joy1_y2);


Thu Feb 10, 2011 9:30 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.