View unanswered posts | View active topics It is currently Sun Nov 23, 2014 12:36 pm






Reply to topic  [ 5 posts ] 
The NXT keeps freezing 
Author Message
Rookie

Joined: Thu Jan 08, 2009 4:19 pm
Posts: 7
Post The NXT keeps freezing
I don't know why but every time I put in the code:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  HTMotor,  none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop, )
#pragma config(Motor,  mtr_S1_C3_1,     motorF,        tmotorNormal, openLoop, )
#pragma config(Motor,  mtr_S1_C3_2,     motorG,        tmotorNormal, openLoop, )
#pragma config(Servo,  servo1,          serv1,                tServoNormal)

#include "JoystickDriver.c"

task main()
{

   while (true)
  {
    getJoystickSettings(joystick);
    motor[motorD] = joystick.joy1_y1;
    motor[motorE] = joystick.joy1_y2;
    motor[motorF] = joystick.joy1_x1;
    motor[motorG] = joystick.joy1_x2;

      if(joy1Btn(1))
      {
         motor[motorA] = 100;
      }
      else
      {
         motor[motorA] = 0;
     }
     if(joy1Btn(3))
      {
         motor[motorB] = -100;
      }
      else
      {
         motor[motorB] = 0;
     }

    if (joy1Btn(2))
      {
      servo[serv1] = 0;
    }
    else
    {
      servo[serv1] = 180;
      }
   }
}


I don't know what to do, I got the newest version of ROBOTC, but for some reason the code won't work, it worked last week, and its the exact same code, I don't know what is wrong, so please help if you know what the problem is.


Fri Jan 23, 2009 5:02 pm
Profile
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: The NXT keeps freezing
The range of the joystick.joy### variables (-128 to 127) is bigger than the range of your motors (-100 to 100). This means that you are sending illegal values to the motors. Illegal values cause unexpected results, like freezing. Illegal values can not always be detected by the compiler, so don't blame robotC.

Decrease the value of the joystick to -100 to 100 by dividing the values by 1.28 and the freezes will be history. But, you'll have to convert the values to a float first, otherwise you'll encounter other problems.

Code:
motor[motorD] = ((float)joystick.joy1_y1)/1.28;

_________________
My most recent blog: A grain of sugar


Fri Jan 23, 2009 7:46 pm
Profile WWW
Rookie

Joined: Thu Jan 08, 2009 4:19 pm
Posts: 7
Post Re: The NXT keeps freezing
I did what you said and it still doesn't work, the NXT still freezes, it works when I put the sample program for the joystick drive, but when I change the motors, it freezes.


Mon Jan 26, 2009 4:52 pm
Profile
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: The NXT keeps freezing
OK,

I didn't look at your program to good. Only now I see you have servo's attached and not NXT motors as I assumed. I do not know servos at all, so I can't tell how they are controlled and what values they accept. I would suggest that you check that out yourself and see if the error is in illegal values.

If not, try to isolate the problem. To do so, start dropping parts of your code, test it, and drop some more lines of code. Until you find the code that is causing the freeze. If you know where the problem is the solution is more easy to find (for you or for us).

_________________
My most recent blog: A grain of sugar


Mon Jan 26, 2009 7:23 pm
Profile WWW
Rookie

Joined: Thu Jan 08, 2009 4:19 pm
Posts: 7
Post Re: The NXT keeps freezing
this is getting weird, the freezing has stopped and now the problem is that when i download the program to the NXT the robot c page closes as soon as the debugger shows up on the screen. I dont remember exactly what the textbox says but right bofore it closes a textbox shows up and says something like "something has caused for the application to close unexpectedly, please contact tech support for assistance" if someone like an admin could help that be great, and i also need the number for this tech support thing.


Mon Jan 26, 2009 9:02 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.