| Author |
Message |
|
cyberpirate
Rookie
Joined: Mon Oct 04, 2010 8:40 am Posts: 13
|
 2nd controller help
Hi, I can't for the life of me figure out what is wrong with the second controller. Its not the controller because they both work as controller 1, but i can't get them to work at the same time. Controller one works fine. Here is my code.  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop, reversed) #pragma config(Servo, srvo_S1_C2_1, , tServoStandard) #pragma config(Servo, srvo_S1_C2_2, , tServoStandard) #pragma config(Servo, srvo_S1_C2_3, , tServoStandard) #pragma config(Servo, srvo_S1_C2_4, , tServoContinuousRotation) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() {
servo[servo1] = 255; servo[servo2] = 14; servo[servo3] = 0; for(;;) { getJoystickSettings(joystick);
// Move motors with joystick and prevent drifting if(joystick.joy1_y1 < 5 && joystick.joy1_y1 > -5) { motor[motorD] = 0; } else { motor[motorD] = joystick.joy1_y1; } if(joystick.joy1_y2 < 5 && joystick.joy1_y2 > -5) { motor[motorE] = 0; } else { motor[motorE] = joystick.joy1_y2; }
// Joystick button configuration if(joy1Btn(7) != 0) //If Joy1-Button7 is pressed { servo[servo1] = 87; // Move Arm to "down" position servo[servo2] = 173; } if(joy1Btn(5) != 0) //If Joy1-Button5 is pressed { servo[servo1] = 255; servo[servo2] = 14; // Move Arm to "up" position } if(joy1Btn(6) != 0) //If Joy1-Button6 is pressed move arm up slowly { servo[servo1] = ServoValue [servo1] + 1; // Adds an Integer to servo1's current position servo[servo2] = ServoValue [servo2] - 1; // Adds an Integer to servo1's current position } if(joy1Btn(8) != 0) //If Joy1-Button8 is pressed move arm down slowly { servo[servo1] = ServoValue [servo1] - 1; // Subtracts an Integer to servo1's current position servo[servo2] = ServoValue [servo2] + 1; // Subtracts an Integer to servo1's current position } if(joy1Btn(3) !=0) //move back hook up slowly { servo[servo3] = ServoValue [servo3] - 1; } if(joy1Btn(2) !=0) //move back hook down slowly { servo[servo3] = ServoValue [servo3] + 1; } if(joy1Btn(1) !=0) //move back hook down { servo[servo3] = 120; } if(joy1Btn(4) !=0) //move back hook up { servo[servo3] = 0; } if(joy2Btn(5) !=0) //rotate top dispenser left { servo[servo4] = 0; } if(joy2Btn(6) !=0) //rotate top dispenser right { servo[servo4] = 255; } else //halt servo if button isnt pressed { servo[servo4] = 127; } // CONTROLLER 2 MOTOR CONTROL (TMP TESTING CODE) if(joystick.joy2_y1 < 5 && joystick.joy2_y1 > -5) { motor[motorD] = 0; } else { motor[motorD] = joystick.joy2_y1; } if(joystick.joy2_y2 < 5 && joystick.joy2_y2 > -5) { motor[motorE] = 0; } else { motor[motorE] = joystick.joy2_y2; } } }
|  |  |  |  |
|
| Tue Nov 30, 2010 9:06 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: 2nd controller help
Are you talking about joystick controllers? At first, I thought you were talking about motor controllers. If so, why do you control motor D and E with both joystick 1 and 2. It won't work. The values written to the motors from joystick 1 are immediate overwritten by the values from joystick 2 and vice versa. What are you trying to do?
|
| Tue Nov 30, 2010 9:40 pm |
|
 |
|
cyberpirate
Rookie
Joined: Mon Oct 04, 2010 8:40 am Posts: 13
|
 Re: 2nd controller help
yes i am talking about the logitech controllers that kinda look like ps2 controllers. My team built a robot with 4 motors and 6 servos. I have the first controller set up to move the wheels and the front and back servos (the first 3 2 on the front 1 on the back). I was going to use the second controller to operate the baton dispenser at the top (first servo rotates the arm and the second two push out the batons). I have yet to program for the last two servos but I need the second controller to work first. The first controller works as expected but anything from the second controller doesn't work.
|
| Tue Nov 30, 2010 9:56 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: 2nd controller help
Are you running the code using the RobotC IDE with Bluetooth or are you using Samantha and running the Field Management System?
If you are using the IDE, did you enable dual joysticks? If you are using the FMS, did you associate with two joysticks?
|
| Tue Nov 30, 2010 10:00 pm |
|
 |
|
cyberpirate
Rookie
Joined: Mon Oct 04, 2010 8:40 am Posts: 13
|
 Re: 2nd controller help
i dont know what IDE is could you explain? but I am using robotc and bluetooth
|
| Tue Nov 30, 2010 10:26 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: 2nd controller help
IDE is "Integrated Development Environment". In order words, your RobotC 2.26 Editor. If that's the environment, did you enable Dual Joystick in the joystick control window?
|
| Tue Nov 30, 2010 10:36 pm |
|
 |
|
cyberpirate
Rookie
Joined: Mon Oct 04, 2010 8:40 am Posts: 13
|
 Re: 2nd controller help
ah ok yes thats what im using and no i didnt enable 2 joysticks if it's not enabled by default. where do you enable this?
|
| Tue Nov 30, 2010 10:45 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: 2nd controller help
When you open the joystick control window (e.g. Robot->Nxt Brick->Joystick control game), you will see a check-box for "Dual joystick". Make sure it's checked.
|
| Tue Nov 30, 2010 10:50 pm |
|
 |
|
cyberpirate
Rookie
Joined: Mon Oct 04, 2010 8:40 am Posts: 13
|
 Re: 2nd controller help
Thanks that was the problem  now i can get back to coding  i was using joystick control simple before. 
|
| Wed Dec 01, 2010 7:22 am |
|
|