Go to Post Putting 2 and 2 together, and then mixing them back up for someone else to try and get 4 in a different way is just plain fun. - Elgin Clock [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-10-2014, 21:55
FRC Team CC FRC Team CC is offline
Registered User
FRC #6560 (Charging Champions)
 
Join Date: Sep 2014
Rookie Year: 2012
Location: Southern California
Posts: 102
FRC Team CC is an unknown quantity at this point
FTC Dual Joystick Problem

Hello FTC teams,

We are the Charging Champions, FTC team 8660 from SoCal. While programming our joysticks, we ran into some trouble trying to use the dual joystick function. We were able to connect to our Samantha wifi module and got it to work wirelessly with one joystick. However, if we ran a program using both joysticks, the program would only execute commands from one joystick.

We were wondering if someone could help us with our dilemma and provide a sample code that works with dual joysticks.

Here is a copy of our program:

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, motorA, , tmotorNXT, openLoop)
#pragma config(Motor, motorB, , tmotorNXT, openLoop)
#pragma config(Motor, motorC, , tmotorNXT, openLoop)
#pragma config(Motor, mtr_S1_C1_1, leftMotor, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, rightMotor, tmotorTetrix, openLoop, reversed)
#pragma config(Servo, srvo_S1_C2_1, armLift, tServoStandard)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c" //Include joystickdriver.c

task main() //Task main.
{
while(true) //Forever loop.
{
getJoystickSettings(joystick); //Continually updates the joystick readings

int servo1 = ServoValue[armLift]; //Sets the variable as the power of the servo motor

if(abs(joystick.joy1_y1) > 10) //If the absolute value of the left joystick value is over 10, then the left motor will move
{
motor[leftMotor] = joystick.joy1_y1 * 75/127;
}
else if(abs(joystick.joy1_y2) > 10) //If the absolute value of the right joystick value is over 10, then the right motor will move
{
motor[rightMotor] = joystick.joy1_y2 * 75/127;
}
else
{
motor[leftMotor] = 0;
motor[rightMotor] = 0;
}
if(abs(joystick.joy2_TopHat) == 0) //If the north arrow is pressed on the tophat, the servo motor will go up.
{
servo[armLift] = servo1--;
}
else if(abs(joystick.joy2_TopHat) == 2) //If the west arrow is pressed on the tophat, the nxt motor will move back.
{
motor[motorA] = -50;
}
else if(abs(joystick.joy2_TopHat) == 4) //If the south arrow is pressed on the tophat, the servo motor will go down.
{
servo[armLift] = servo1++;
}
else if(abs(joystick.joy2_TopHat) == 6) //If the west arrow is pressed on the tophat, the nxt motor will move back.
{
motor[motorA] = 50;
}
else //Otherwise, all motors will stop moving.
{
motor[motorA] = 0;
servo[armLift] = servo1;
}


wait1Msec(5); //Wait for 5 milliseconds.
}


}

Please let us know if there is anything wrong with our program. All help is appreciated. Go FTC Teams!!!

Thanks,
Charging Champions
FTC Team 8660
Reply With Quote
  #2   Spotlight this post!  
Unread 11-10-2014, 03:37
Jeremy Germita's Avatar
Jeremy Germita Jeremy Germita is offline
Co-Advisor/Lead Engineering Mentor
AKA: wood is good. plastic is fantastic.
FRC #5012 (Gryffingear) / (Antelope Valley FIRST Teams)
Team Role: Coach
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Lancaster, CA
Posts: 282
Jeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond repute
Re: FTC Dual Joystick Problem

Your code looks solid.

How are you trying to run your program?

If it's through the robotC debugger or Joystick control windows, make sure you have the dual joystick option selected and that joystick 1 is selected on the left pane of the window and joystick 2 on the right pane.

If through the FCS(also applicable to RobotC), make sure that both joysticks are connected and configured within the software.

For future reference, it's good to use the [code] BBCode tabs when posting your code in a post.
Code:
while(true) 
{
  printf("Easier to read like this :) \n");
}
__________________
Drive Coach Team 5012 Gryffingear / Antelope Valley FIRST teams / EWCP - (2013 - Current)
Student / Driver / Programmer / CAD - FRC Team 399: Eagle Robotics / FTC Team 72: GarageBots - (2009 - 2013)
Los Angeles Region FTC FTA/CSA/Head Ref
[FF] FIRST Pick
2014 FTC Los Angeles Regional Compass Award Winner.

2017 - Sacramento Regional / Las Vegas Regional
2016 - Los Angeles Regional Creativity + Winners (1197, 987, 5012) / Las Vegas Regional Team Spirit + SF (5012, 5851, 5049) / Galileo Subdivision
2015 - Inland Empire QF (597, 5012, 4413) / Las Vegas Imagery + Winners (148, 987, 5012) / Newton Subdivision and World Champions (118, 1678, 1671, 5012)
2014 - Inland Empire Rookie All Star + Highest Rookie Seed + SF (2339, 1967, 5012) / Las Vegas Rookie All Star / Galileo Division Imagery

Last edited by Jeremy Germita : 11-10-2014 at 03:47.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi