View unanswered posts | View active topics It is currently Wed Oct 22, 2014 6:32 pm






Reply to topic  [ 4 posts ] 
RobotC 3.5, my program will not work with my robot. 
Author Message
Rookie

Joined: Tue Sep 25, 2012 2:18 pm
Posts: 2
Post RobotC 3.5, my program will not work with my robot.
RobotC 3.5, my program will not work with my robot!
I am having a problem with my program. I am making this so we can run a basic robot with two rear wheels. But, when I try and rum the program, it will not work. It compiled and downloaded just fine, and when I run the program with the robot, the display will read "Running [Insert program name]". Yet, when I press a button on the controller that is supposed to move the wheel, nothing happens. Is there something I have to change so it will run right? If so, can you explain so I can better understand the program and my error.

It is Lego Mindstorms with Tetrix Motors and a Tetrix Motor Controller. Logitec Game Controller.

Here is my program below(which is based off of our program from last year, with a small change so it will make it past debug and compile and download). Thank you for the assistance.
----------------------------------------------------------------------------
#pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorA, tmotorTetrix, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_2, motorB, tmotorTetrix, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{while(true)

getJoystickSettings(joystick);

motor[motorA] = joystick.joy1_y1;
motor[motorB] = -joystick.joy1_y2;

if (joy1Btn(8))
{
motor[motorA] = 65;
}
else if (joy1Btn(6))
{
motor[motorA] = -65;
}

else
{
motor[motorA] = 0;
}
if (joy1Btn(7))
{
motor[motorB] = 65;
}
else if (joy1Btn(5))
{
motor[motorB] = -65;
}

else
{
motor[motorB] = 0;
}}


Tue Sep 25, 2012 2:48 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 593
Post Re: RobotC 3.5, my program will not work with my robot.
There are two possible issues here. The first is that you are assigning joystick values to the motors in the
Code:
motor[motorA] = joystick.joy1_y1;
motor[motorB] = -joystick.joy1_y2;

commands, but then immediately after you are reassigning motor values off of the button commands. What you will run into is that both of these commands will 'cancel out' each other. If you are using the joysticks, the joysticks will return a value to the motors (for instance, a motor power level of 50) but then immediately after that, the program checks for a button press and if false, turns the motors back off. You may see slight, jerky movement in the robot if doing this. You will have to decide if you want to control the robot via joysticks or via buttons:

Code:
while(abs(joystick.joy1_y1) > 10 || abs(joystick.joy1_y2) > 10)
{
getJoystickSettings(joystick);
motor[motorA] = joystick.joy1_y1;
motor[motorB] = -joystick.joy1_y2;
}

while (joy1Btn(5) || joy1Btn(6) || joy1Btn(7) || joy1Btn(8))
{
getJoystickSettings(joystick);
button control code
}

motor[motorA]=0;
motor[motorB]=0;

}


This code will check the joysticks for a value over or less than 10 (a threshold value which can be tweaked per specific controllers) and while at least one of the joystick controllers are 'active' will continually update the motors. Then, once the joysticks return to the center position and aren't controlling the robot, the program checks for the button presses and will control the motors that way. If neither the joysticks nor the buttons are pressed, the motors stop. You will have to tweak this (such as adding in the 'button code' code), but it should get you started.

The second issue is making sure you have the Joystick Control - Competition window in order to use the USB Joystick Controllers. You can open this debug window by navigating to the Robot-> Debugger Windows menu and selecting "Joystick Control - Competition". Alternatively, you can use the new pragma statement, debuggerWindows. If you add '#pragma DebuggerWindows("JoystickSimple")' to the pragma statements, you can have the Basic (not competition, yet) joystick control menu pop up every time you compile and download the program.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Sep 25, 2012 4:16 pm
Profile
Rookie

Joined: Wed Jul 21, 2010 11:23 pm
Posts: 39
Post Re: RobotC 3.5, my program will not work with my robot.
Once we upgraded from 3.05 to 3.50 we had issues making a USB tethered joystick work. The joystick window on the PC correctly shows joystick activity, but nothing appears to get passed through to the NXT. Curiously, the AUDIBLE FEEDBACK causes the NXT to beep continually so the data packets seem to be going through, just no joystick information contained in them.

Rolling back to V3.05 and everything started working normally again using the same exact (very simple and basic) program.

Can others confirm that they've definitely seen a USB tethered joystick work in the latest release?


Wed Sep 26, 2012 1:23 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3225
Location: Rotterdam, The Netherlands
Post Re: RobotC 3.5, my program will not work with my robot.
Ron,

Perhaps you should try with 3.51, it fixes a LOT of bugs that were in 3.50.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Sep 26, 2012 1:31 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.