View unanswered posts | View active topics It is currently Wed Jul 30, 2014 9:07 am






Reply to topic  [ 3 posts ] 
Motor issue 
Author Message
Rookie

Joined: Sat Jan 26, 2013 3:44 pm
Posts: 2
Post Motor issue
We are testing our program for Qualifier tournament. We configured two motor controllers, but when we run the program
Motor[lift] is not working. Please help. Following is the code:
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S2, touch, sensorTouch)
#pragma config(Sensor, S3, light, sensorLightActive)
#pragma config(Sensor, S4, sonar, sensorSONAR)
#pragma config(Motor, mtr_S1_C1_1, leftMotor, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C1_2, rightMotor, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S1_C2_1, lift, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_2, motorG, tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

//Joystick Program
//--------------------------------------
task main()

{
int threshold = 5; // to avoid unnecessary movement
int wt1, wt2;
wt1=50; wt2=1950;
while(true) //infinite loop
{
getJoystickSettings(joystick); //retrieves data from the joystick
//controlling robot's motors with joystick

if(abs(joystick.joy1_y1) < threshold)
{
motor[leftMotor] = 0;
}
else
{
motor[leftMotor] = joystick.joy1_y1/2; //y1 controller moves motorD
wait1Msec(2*wt1);
}
if(abs(joystick.joy1_y2) < threshold)
{
motor[rightMotor] = 0;
}
else
{
motor[rightMotor] = joystick.joy1_y2/2; //y2 controller moves motorE
wait1Msec(2*wt1);
}

//Left Turn
if(joy1Btn(1)==1)
{
motor[leftMotor] = -25;
motor[rightMotor] = 25;
wait1Msec(wt2);
}
//Right Turn
if(joy1Btn(3)==1)
{
motor[leftMotor] = 25;
motor[rightMotor] = -25;
wait1Msec(wt2);
}
//Forward movement
if(joy1Btn(4)==1)
{
motor[leftMotor] = 50;
motor[rightMotor] = 50;
wait1Msec(wt1);
}
//Backward movement
if(joy1Btn(2)==1)
{
motor[leftMotor]= -25;
motor[rightMotor] = -25;
wait1Msec(wt1);
}
if(joy1Btn(1)==0&&joy1Btn(2)==0&&joy1Btn(3)==0&&joy1Btn(4)==0)
{
motor[leftMotor] = 0;
motor[rightMotor] = 0;
wait1Msec(wt1);
}
if(joy1Btn(5)==1)
{
motor[lift] = 25;
wait1Msec(2*wt1);
}
if(joy1Btn(7)==1)
{
motor[lift] = -25;
wait1Msec(2*wt1);
}
if(joy1Btn(5)==0&&joy1Btn(7)==0)
{
motor[lift] = 0;
}
}
}


Sat Jan 26, 2013 3:55 pm
Profile
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post Re: Motor issue
You said the lift wasn't working. Is it possible that it has too great a load to move with power 25? Does it work with greater power values? What's your gearing setup?

Try this:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     touch,          sensorTouch)
#pragma config(Sensor, S3,     light,          sensorLightActive)
#pragma config(Sensor, S4,     sonar,          sensorSONAR)
#pragma config(Motor,  mtr_S1_C1_1,     leftMotor,     tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     rightMotor,    tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor,  mtr_S1_C2_1,     lift,          tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C2_2,     motorG,        tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

//Joystick Program
//--------------------------------------
task main()

{
   int threshold = 5; // to avoid unnecessary movement
   int wt1 = 50, wt2 = 1950;

   while(true) //infinite loop
   {
      getJoystickSettings(joystick); //retrieves data from the joystick

      //controlling robot's motors with joystick

      if(abs(joystick.joy1_y1) < threshold)
      {
         motor[leftMotor] = 0;
      }
      else
      {
         motor[leftMotor] = joystick.joy1_y1/2; //y1 controller moves motorD
      }
      if(abs(joystick.joy1_y2) < threshold)
      {
         motor[rightMotor] = 0;
      }
      else
      {
         motor[rightMotor] = joystick.joy1_y2/2; //y2 controller moves motorE
      }

      //Left Turn
      if(joy1Btn(1)==1)
      {
         motor[leftMotor] = -25;
         motor[rightMotor] = 25;
      }
      //Right Turn
      else if(joy1Btn(3)==1)
      {
         motor[leftMotor] = 25;
         motor[rightMotor] = -25;
      }
      //Forward movement
      else if(joy1Btn(4)==1)
      {
         motor[leftMotor] = 50;
         motor[rightMotor] = 50;
      }
      //Backward movement
      else if(joy1Btn(2)==1)
      {
         motor[leftMotor]= -25;
         motor[rightMotor] = -25;
      }
      else
      {
         motor[leftMotor] = 0;
         motor[rightMotor] = 0;
      }

      if(joy1Btn(5)==1)
      {
         motor[lift] = 25;
      }
      else if(joy1Btn(7)==1)
      {
         motor[lift] = -25;
      }
      else
      {
         motor[lift] = 0;
      }
      
      wait1Msec(wt1);
   }
}


Sat Jan 26, 2013 10:55 pm
Profile
Rookie

Joined: Sat Jan 26, 2013 3:44 pm
Posts: 2
Post Re: Motor issue
Thank you very much. We got it.


Mon Jan 28, 2013 8:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.