ROBOTC.net forums
http://robotc.net/forums/

What is going on?
http://robotc.net/forums/viewtopic.php?f=52&t=7795
Page 1 of 1

Author:  RobotDaddy [ Thu Jan 23, 2014 1:00 pm ]
Post subject:  What is going on?

I have no ides whats going on. My Nxt Connects, but then i compile it and then I lose connection. I don't know how to fix it. I don't think anything in my code could do it, but maybe.
Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S2, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S3, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S4, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Sensor, S3,     ,               sensorI2CMuxController)
#pragma config(Sensor, S4,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motorF,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorG,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     motorD,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     motorE,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S2_C2_1,     motorH,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C2_2,     motorI,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C1_1,     motorH,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C1_2,     motorI,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C2_1,     motorH,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C2_2,     motorI,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C1_1,     motorH,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C1_2,     motorH,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S4_C2_1,     motorI,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C2_2,     motorQ,        tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
{

while(true)
    {
        getJoystickSettings(joystick);
        motor[motorD] = joystick.joy1_y1;
        motor[motorE] = joystick.joy1_y2; //Motor E is Reversed

        getJoystickSettings(joystick);
         {if(abs(joystick.joy2_y1) > 10){
         {
        motor[motorF] = joystick.joy2_y1/1.75;
        motor[motorG] = joystick.joy2_y1/1.75; //Motor G is reversed
      }
      }else{
           motor[motorF] = 0;
           motor[motorG] = 0;
      }}}
            {if(abs(joystick.joy2_y2) > 10){
        motor[motorH] = joystick.joy2_y2/1.75;
        motor[motorI] = joystick.joy2_y2/1.75; //Motor I is reversed
      }
        else{
           motor[motorH] = 0;
           motor[motorI] = 0;
        }}}


If you could give me any idea as to whats wrong , or how to fix it.

Author:  BurningLights [ Thu Jan 23, 2014 6:57 pm ]
Post subject:  Re: What is going on?

Are you connecting using USB or Bluetooth? Because that makes a big difference on the kinds of problems you could be encountering.

Author:  RobotDaddy [ Mon Jan 27, 2014 12:56 pm ]
Post subject:  Re: What is going on?

BurningLights wrote:
Are you connecting using USB or Bluetooth? Because that makes a big difference on the kinds of problems you could be encountering.

I've tried both, neither are working. :?

Author:  JohnWatson [ Mon Jan 27, 2014 1:22 pm ]
Post subject:  Re: What is going on?

Out of curiosity, what happens when you replace the #pragmas at the top with a version that follows the alphabetic naming system properly (motors H and I are assigned to multiple chains/ports)?

Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S2, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S3, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S4, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Sensor, S3,     ,               sensorI2CMuxController)
#pragma config(Sensor, S4,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motorF,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorG,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     motorD,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     motorE,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S2_C2_1,     motorH,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C2_2,     motorI,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C1_1,     motorJ,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C1_2,     motorK,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C2_1,     motorL,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C2_2,     motorM,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C1_1,     motorN,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C1_2,     motorO,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S4_C2_1,     motorP,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C2_2,     motorQ,        tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


Besides that, I don't see anything in particular that could be causing a disconnect issue. However, there is another potential coding issue that I've come across:

Code:
#include "JoystickDriver.c"

task main()
{

   while(true)
   {
      getJoystickSettings(joystick);
      motor[motorD] = joystick.joy1_y1;
      motor[motorE] = joystick.joy1_y2; //Motor E is Reversed

      getJoystickSettings(joystick);
      {
         if(abs(joystick.joy2_y1) > 10)
         {
            {
               motor[motorF] = joystick.joy2_y1/1.75;
               motor[motorG] = joystick.joy2_y1/1.75; //Motor G is reversed
            }
         }
         else
         {
            motor[motorF] = 0;
            motor[motorG] = 0;
         }
      }
   }
   
   {
      if(abs(joystick.joy2_y2) > 10)
      {
         motor[motorH] = joystick.joy2_y2/1.75;
         motor[motorI] = joystick.joy2_y2/1.75; //Motor I is reversed
      }
      else
      {
         motor[motorH] = 0;
         motor[motorI] = 0;
      }
   }
}


There is a misplaced closing brace } after the first 'else' statement that is encapsulating your infinite while loop. You will either need to remove both it and the opening brace directly after the second 'getJoystickSettings();' command, or move the closing brace to the end of the program in order to 'encapsulate' both sets of if/else statements inside of the while loop.

Author:  BurningLights [ Mon Jan 27, 2014 1:24 pm ]
Post subject:  Re: What is going on?

So, just to be clear, you're navigating in the menus to Robot>NXT Brick>Communication Link Setup, ROBOTC is finding your NXT, and you're successfully connect to it? Then, when you go to download a program, it tells you that you are not connected to an NXT?

Author:  RobotDaddy [ Mon Jan 27, 2014 1:31 pm ]
Post subject:  Re: What is going on?

BurningLights wrote:
So, just to be clear, you're navigating in the menus to Robot>NXT Brick>Communication Link Setup, ROBOTC is finding your NXT, and you're successfully connect to it? Then, when you go to download a program, it tells you that you are not connected to an NXT?

Yes

Author:  RobotDaddy [ Mon Jan 27, 2014 1:33 pm ]
Post subject:  Re: What is going on?

JohnWatson wrote:
Out of curiosity, what happens when you replace the #pragmas at the top with a version that follows the alphabetic naming system properly (motors H and I are assigned to multiple chains/ports)?

Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S2, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S3, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S4, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Sensor, S3,     ,               sensorI2CMuxController)
#pragma config(Sensor, S4,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motorF,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorG,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     motorD,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     motorE,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S2_C2_1,     motorH,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C2_2,     motorI,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C1_1,     motorJ,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C1_2,     motorK,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C2_1,     motorL,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C2_2,     motorM,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C1_1,     motorN,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C1_2,     motorO,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S4_C2_1,     motorP,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S4_C2_2,     motorQ,        tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


Besides that, I don't see anything in particular that could be causing a disconnect issue. However, there is another potential coding issue that I've come across:

Code:
#include "JoystickDriver.c"

task main()
{

   while(true)
   {
      getJoystickSettings(joystick);
      motor[motorD] = joystick.joy1_y1;
      motor[motorE] = joystick.joy1_y2; //Motor E is Reversed

      getJoystickSettings(joystick);
      {
         if(abs(joystick.joy2_y1) > 10)
         {
            {
               motor[motorF] = joystick.joy2_y1/1.75;
               motor[motorG] = joystick.joy2_y1/1.75; //Motor G is reversed
            }
         }
         else
         {
            motor[motorF] = 0;
            motor[motorG] = 0;
         }
      }
   }
   
   {
      if(abs(joystick.joy2_y2) > 10)
      {
         motor[motorH] = joystick.joy2_y2/1.75;
         motor[motorI] = joystick.joy2_y2/1.75; //Motor I is reversed
      }
      else
      {
         motor[motorH] = 0;
         motor[motorI] = 0;
      }
   }
}


There is a misplaced closing brace } after the first 'else' statement that is encapsulating your infinite while loop. You will either need to remove both it and the opening brace directly after the second 'getJoystickSettings();' command, or move the closing brace to the end of the program in order to 'encapsulate' both sets of if/else statements inside of the while loop.


Changing the pragma didn't work, In fact none of my codes are working. I can connect to regular Nxt bots, but not my competition bot. Also, I changed the closing brace and it didn't change.

Author:  JohnWatson [ Mon Jan 27, 2014 1:51 pm ]
Post subject:  Re: What is going on?

RobotDaddy wrote:

Changing the pragma didn't work, In fact none of my codes are working. I can connect to regular Nxt bots, but not my competition bot. Also, I changed the closing brace and it didn't change.


Ok, so this definitely seems like a connection issue and not a code issue, BurningLights has the correct thinking on this one. When you plug in and turn on your NXT brick, what does it appear as under the Windows Device Manager? Also, does it boot as normal (with the NXT boot sound/menu visible) or is it 'clicking' with a blank screen?

Author:  RobotDaddy [ Tue Jan 28, 2014 2:03 pm ]
Post subject:  Re: What is going on?

JohnWatson wrote:
Also, does it boot as normal (with the NXT boot sound/menu visible) or is it 'clicking' with a blank screen?

It boots up normal with a visible menu and a sound, but I try to run the code it freezes and starts to click. I have tried with multiple NXT's and the firmware is updated. :-( :?

Author:  MHTS [ Tue Jan 28, 2014 6:26 pm ]
Post subject:  Re: What is going on?

My experience with RobotC tells me that when the brick is clicking, it is hung waiting for something. When it's waiting for something, it seems it stops communicating that causes the laptop to "disconnect". A quick glance at the code doesn't reveal anything obviously wrong but I would recommend checking the configuration of the robot against your pragmas to make sure all the motors are connected as specified by the pragma. I can imagine that if the configuration doesn't match, RobotC may be waiting for a non-existing motor controller to respond. If you still can't find anything wrong, start with simpler code with only one set of motors and work up from there. For example:
Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motorF,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorG,        tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
{
   while(true)
   {
      getJoystickSettings(joystick);
      if(abs(joystick.joy2_y1) > 10)
      {
               motor[motorF] = joystick.joy2_y1/1.75;
               motor[motorG] = joystick.joy2_y1/1.75; //Motor G is reversed
      }
      else
      {
            motor[motorF] = 0;
            motor[motorG] = 0;
      }
      wait1Msec(100);
  }
}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/