|
Page 1 of 1
|
[ 3 posts ] |
|
| Author |
Message |
|
TRANSFORMERS
Rookie
Joined: Sat Jan 26, 2013 3:44 pm Posts: 2
|
 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 |
|
 |
|
amcerbu
Novice
Joined: Sun Oct 21, 2012 10:01 pm Posts: 76
|
 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 |
|
 |
|
TRANSFORMERS
Rookie
Joined: Sat Jan 26, 2013 3:44 pm Posts: 2
|
 Re: Motor issue
Thank you very much. We got it.
|
| Mon Jan 28, 2013 8:47 pm |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 7 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
|
|