Log in

View Full Version : Logitech USB Controller Programming Issues


speckz
26-10-2014, 12:57
We cannot get our Logitech USB controllers to work properly with our code in RobotC. The debugger picks up when buttons are pressed and joysticks are moved correctly but when the code is run the code will not pick up what is going on with the controller.

Here is the code:


#pragma config(Hubs, S1, MatrxRbtcs, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_Matrix_S1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_3, motorF, tmotorMatrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_4, motorG, tmotorMatrix, openLoop)
#pragma config(Servo, srvo_Matrix_S1_1, servo1, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_2, servo2, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_3, servo3, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_4, servo4, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{
servo[servo1] = -127;
wait1Msec(500);

while (true)
{
getJoystickSettings(joystick);
if(joy1Btn(00) == true)
servo[servo1] = 127
}
}


This is a matrix robot for the First Tech Challenge. Moving motors and servos normally works fine but when we try to do it with a USB controller the code does not pick anything up.
We are using NXT brick which has the correct firmware from RobotC 4.26.

What might we be doing wrong? Thank you.

ehochstein
26-10-2014, 17:09
#pragma config(Hubs, S1, MatrxRbtcs, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_Matrix_S1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_3, motorF, tmotorMatrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_4, motorG, tmotorMatrix, openLoop)
#pragma config(Servo, srvo_Matrix_S1_1, servo1, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_2, servo2, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_3, servo3, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_4, servo4, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{
servo[servo1] = -127;
wait1Msec(500);

while (true)
{
getJoystickSettings(joystick);
if(joy1Btn(00) == true)
servo[servo1] = 127;
}
}

Try this and see if you can figure out what I changed.

speckz
29-10-2014, 15:44
#pragma config(Hubs, S1, MatrxRbtcs, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_Matrix_S1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_3, motorF, tmotorMatrix, openLoop)
#pragma config(Motor, mtr_Matrix_S1_4, motorG, tmotorMatrix, openLoop)
#pragma config(Servo, srvo_Matrix_S1_1, servo1, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_2, servo2, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_3, servo3, tServoNone)
#pragma config(Servo, srvo_Matrix_S1_4, servo4, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{
servo[servo1] = -127;
wait1Msec(500);

while (true)
{
getJoystickSettings(joystick);
if(joy1Btn(00) == true)
servo[servo1] = 127;
}
}

Try this and see if you can figure out what I changed.


Yes I realize I missed a semicolon but that's not the problem it still doesn't work. I know my code is right I'm positive it's something with the setup but find nothing wrong with the setup.