View unanswered posts | View active topics It is currently Wed Nov 13, 2019 11:21 pm






Reply to topic  [ 12 posts ] 
Trouble running progra 
Author Message
Rookie

Joined: Wed Nov 05, 2014 2:53 pm
Posts: 6
Location: Petoskey, MI
Post Trouble running progra
I have an issue with running a teleop program. I have robotc and my program opened. I have the debug window for the joystick open. I see the joystick input. The program was compiled and downloaded with the USB cable and it is still connected via usb. The NXT indicates that the program that I downloaded is running. I have checked all the wiring and it is correct. Any thoughts?


Wed Nov 05, 2014 3:06 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Trouble running progra
Please post the entirety of your code using the [code] tags as we will need this in order to debug the program for any potential errors. Thank you!

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Wed Nov 05, 2014 3:30 pm
Profile
Rookie

Joined: Wed Nov 05, 2014 2:53 pm
Posts: 6
Location: Petoskey, MI
Post Re: Trouble running progra
Sorry about that. Here it is
Code:
#include "JoystickDriver.c"

task main()
{
  int threshold = 20;             /* Int 'threshold' will allow us to ignore low       */
                                  /* readings that keep our robot in perpetual motion. */
  int SwpArmPos = 42;

  while(true)                                              // Infinite loop:
  {
    getJoystickSettings(joystick);
    if(abs(joystick.joy1_y2) > threshold)               // If the right analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[mtr_S1_C1_1] = joystick.joy1_y2;
      motor[mtr_S2_C1_1] = joystick.joy1_y2;           // Motor B is assigned a power level equal to the right analog stick's Y-axis reading.
    }
    else                                    // Else if the readings are within the threshold:
    {
         motor[mtr_S1_C1_1] = 0;
      motor[mtr_S2_C1_1] = 0;                    // Motor B is stopped with a power level of 0.
    }

    if(abs(joystick.joy1_y1) > threshold)   // If the left analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[mtr_S1_C1_2] = joystick.joy1_y1;
      motor[mtr_S2_C1_2] = joystick.joy1_y1;         // Motor C is assigned a power level equal to the left analog stick's Y-axis reading.
    }
    else                                    // Else if the readings are within the threshold:
    {
         motor[mtr_S1_C1_2] = 0;
      motor[mtr_S2_C1_2] = 0;                      // Motor C is stopped with a power level of 0.
    }
  }
/////////////////////////////////
//Sweeper arm config begin
// Up
      if(joy1Btn(4)== 1 && SwpArmPos == 0)
      {
      servo[srvo_S1_C3_1] = 42;
      SwpArmPos = 42;
   }
//Dwn
   if (joy1Btn(6) == 0 && SwpArmPos == 42)
     {
      servo[srvo_S1_C3_1] = 0;
      SwpArmPos = 0;
  }
//  Sweeper arm config ends
/////////////////////////////
//  Sweeper rotoation begins
//

         if(joy1Btn(5)== 0)
         {
            if (joy1Btn (7) == 1)
               motor[mtr_S1_C2_2] = -50;      // Forward
            else
               motor[mtr_S1_C2_2] = 0;
      }
         else
         {motor[mtr_S1_C2_2] = 50;            // Reverse
      }

//  End Sweeper direction
///////////////////////////////////
//  Begin Pin Section

        if (joy1Btn(1)== 1)                     // Pin Down
      {
        servo[srvo_S1_C3_2]= 0;
     }
        if (joy1Btn(2)== 1)                     // Pin Up
     {
        servo[srvo_S1_C3_2]= 127;
      }

//  End Pin Section
//   End Controller 1
////////////////////////////////////
//  Begin Hopper Up/Down
        if (joy2Btn(1)== 1)                     // Hopper Down
      {
              servo[srvo_S1_C3_3]= 0;
  }
        if (joy2Btn(2)== 1)                     // Hopper Up
     {
              servo[srvo_S1_C3_3]= 127;
           }
//  End Hopper Up/Down
////////////////////////////////////////
//  Lift Up/Down Begin

 if(abs(joystick.joy2_y1) > threshold)               // If the right analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[mtr_S1_C2_1] = joystick.joy1_y2;
        }
    else                                    // Else if the readings are within the threshold:
    {
         motor[mtr_S1_C2_1] = 0;

      }
}


However, I do not believe it is an issue with code because I have since run numerous of the prewritten example codes.


Wed Nov 05, 2014 4:42 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Trouble running progra
Well, I can tell you that anything below your drive code will not run, since your infinite while (true) loop ends directly after it. You need to move all of the other control code inside of that main loop for it to work correctly.

Anyhow, I don't think that's your main problem right now. Are you using ROBOTC 4.26? If so, make sure the Natural Language feature is disabled under the Robot->Platform Type menu.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Wed Nov 05, 2014 5:51 pm
Profile
Rookie

Joined: Wed Nov 05, 2014 2:53 pm
Posts: 6
Location: Petoskey, MI
Post Re: Trouble running progra
No the coding doesn't seem to be our main problem. Before we started coding for our competition robot we put together a small base robot to start getting used to RobotC. We made a few basic programs for driving and those worked perfectly fine. Now, a few days later, we can't even get those to run even with the same FCS conditions as before.


Wed Nov 05, 2014 6:06 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Trouble running progra
Team8918 wrote:
No the coding doesn't seem to be our main problem. Before we started coding for our competition robot we put together a small base robot to start getting used to RobotC. We made a few basic programs for driving and those worked perfectly fine. Now, a few days later, we can't even get those to run even with the same FCS conditions as before.


I see. Does your code work when debugging it with ROBOTC, or are your issues just running it through the FCS?

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Wed Nov 05, 2014 10:07 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Trouble running progra
To clarify; with how the code is currently configured, this is the only code that should be running inside of task main (as the rest of the code currently resides outside of the infinite while loop):

Code:
int threshold = 20;             /* Int 'threshold' will allow us to ignore low       */
                                  /* readings that keep our robot in perpetual motion. */
  int SwpArmPos = 42;

  while(true)                                              // Infinite loop:
  {
    getJoystickSettings(joystick);
    if(abs(joystick.joy1_y2) > threshold)               // If the right analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[mtr_S1_C1_1] = joystick.joy1_y2;
      motor[mtr_S2_C1_1] = joystick.joy1_y2;           // Motor B is assigned a power level equal to the right analog stick's Y-axis reading.
    }
    else                                    // Else if the readings are within the threshold:
    {
         motor[mtr_S1_C1_1] = 0;
      motor[mtr_S2_C1_1] = 0;                    // Motor B is stopped with a power level of 0.
    }

    if(abs(joystick.joy1_y1) > threshold)   // If the left analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[mtr_S1_C1_2] = joystick.joy1_y1;
      motor[mtr_S2_C1_2] = joystick.joy1_y1;         // Motor C is assigned a power level equal to the left analog stick's Y-axis reading.
    }
    else                                    // Else if the readings are within the threshold:
    {
         motor[mtr_S1_C1_2] = 0;
      motor[mtr_S2_C1_2] = 0;                      // Motor C is stopped with a power level of 0.
    }
  }


Assuming the #pragmas are correct, this code should work as desired. Like BurningLights suggested, I recommend running just this code (with the appropriate #pragma setups) as a separate program (without the FTC competition control).

If the code runs, then the problem may be with with the FCS controls or the way the program is configured with the Program Chooser program. If the code does not run there may be other issues with the configuration of the robot's motors/controllers/power system, either programmatically or physically.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Thu Nov 06, 2014 11:24 am
Profile
Rookie

Joined: Wed Nov 05, 2014 2:53 pm
Posts: 6
Location: Petoskey, MI
Post Re: Trouble running progra
I backed up a bit and compiled an example program with the code configured for Tetrix motor controllers. Program compiled downloaded and ran fine. This proves that the NXT, wiring, motor controllers, and the motors themselves are functional. The thing that this removed was the joystick controls. Is there a difference in the hand controllers themselves? I have one that is completely a blue-ish color and the one that I used yesterday has colored a,b,x,y buttons.


Thu Nov 06, 2014 3:28 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Trouble running progra
The first controller you described sounds like the Logitech Dual Action gamepad. And the second one sounds like their F310. Both of these work fine with FTC and ROBOTC. The only thing with the F310 is that you've got to make sure the switch on the back is set to "D" and not "X".

At this point, I would recommend that you start by getting your joystick code working while debugging with ROBOTC. That proves that your code is fine and fully functional. Once you've got it working there, then you can move onto getting the robot to work wirelessly with the FCS, which has its own host of issues.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Thu Nov 06, 2014 4:52 pm
Profile
Rookie

Joined: Wed Nov 05, 2014 2:53 pm
Posts: 6
Location: Petoskey, MI
Post Re: Trouble running progra
Thanks for the help. I am going to look at the joystick code next. I actually did have this running with the FCS at one point. Not really sure what has happened. Onward and upward...


Fri Nov 07, 2014 12:29 am
Profile
Rookie

Joined: Wed Nov 05, 2014 2:53 pm
Posts: 6
Location: Petoskey, MI
Post Re: Trouble running progra
As Willie Nelson would say 'On the road again....' OK just beat me with a stick. It was a bad hand controller. Swapped out and all is working again. Grrrrrrr. Thanks for all the replies and help.... :bigthumb:


Fri Nov 07, 2014 1:55 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Trouble running progra
Team8918 wrote:
As Willie Nelson would say 'On the road again....' OK just beat me with a stick. It was a bad hand controller. Swapped out and all is working again. Grrrrrrr. Thanks for all the replies and help.... :bigthumb:

Well, I'm glad it was a simple fix. We actually had something like this happen at a scrimmage once last year. One of the teams we were scrimmaging with was having an issue that half of their robot's lift wasn't responding. They were trying to track the problem down, and then I remembered that one of the trigger buttons on the controller they were using was broken.... :oops:

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Fri Nov 07, 2014 10:44 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 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.