View unanswered posts | View active topics It is currently Tue Jul 29, 2014 10:58 pm






Reply to topic  [ 7 posts ] 
Need help with Program from Cortex to Controller 
Author Message
Rookie

Joined: Sun Sep 18, 2011 2:20 pm
Posts: 8
Post Need help with Program from Cortex to Controller
We are very confused please help!!!!!! Could someone post a program that will allow all the channels on the cortex to function with the remote?

Ours only allows chanels 1-4. We really need channels 5 and 6 to work!

Heres what we have...it's probably not correct:

#pragma config(Motor, port2, boom, tmotorNormal, openLoop)
#pragma config(Motor, port3, ldrive, tmotorNormal, openLoop)
#pragma config(Motor, port4, rdrive, tmotorNormal, openLoop)
#pragma config(Motor, port5, intake, tmotorServoStandard, openLoop)
#pragma config(Motor, port6, intake1, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
while (1 == 1)
{
motor[port2] = vexRT(Ch2);
motor[port3] = vexRT(Ch3);
motor[port4] = vexRT(Ch4);
motor[port5] = vexRT(Ch5);
motor[port6] = vexRT(Ch6);

}

}


Fri Nov 18, 2011 9:32 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Need help with Program from Cortex to Controller
The problem that you're having is that there are no Channels 5 and 6 on the VEXnet Joystick. These are valid names because the older style Radio Control Transmitter did have Channels 5 and 6.

All of the buttons on the VEXnet remote are accessed using the letters "Btn" + the number closest to the button + the letter etched into the button. For example, "vexRT[Btn5D]". These buttons provide values of 0 or 1, not -127 to 127.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Fri Nov 18, 2011 10:02 am
Profile
Rookie

Joined: Sun Sep 18, 2011 2:20 pm
Posts: 8
Post Re: Need help with Program from Cortex to Controller
That makes sense! Can you give a small example of how that looks in the code?


Fri Nov 18, 2011 10:05 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Need help with Program from Cortex to Controller
Here's a sample program that we use in our video tutorials and is included in ROBOTC:

Code:
task main()
{

  while(vexRT[Btn7D] == 0)
  {
  }

  ClearTimer(T1);
  while(time1[T1] < 90000)
  {
    motor[leftMotor] = vexRT[Ch3] / 2;
    motor[rightMotor] = vexRT[Ch2] / 2;

    if(vexRT[Btn6U] == 1)
    {
      motor[armMotor] = 40;
    }
    else if(vexRT[Btn6D] == 1)
    {
      motor[armMotor] = -40;
    }
    else
    {
      motor[armMotor] = 0;
    }
  }

  motor[leftMotor] = 0;
  motor[rightMotor] = 0;

}

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Fri Nov 18, 2011 10:11 am
Profile
Rookie

Joined: Sun Sep 18, 2011 2:20 pm
Posts: 8
Post Re: Need help with Program from Cortex to Controller
If I copy and paste that code and Compile it, I get 3 errors:

**Error**:Undefined variable 'leftMotor'. 'short' assumed.
**Error**:Undefined variable 'rightMotor'. 'short' assumed.
**Error**:Undefined variable 'armMotor'. 'short' assumed.

How do you assign the 0 or 1 to each motor. Assuming that means On or Off. ???


Fri Nov 18, 2011 10:21 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Need help with Program from Cortex to Controller
You get an error because you haven't configured the motors in the Robot > Motors and Sensors setup menu.

If you want to drive the motors with the buttons, you can't just use a 1 or 0 as the value. Instead you have to say something like...

Code:
 if(vexRT[Btn6U] == 1)
    {
      motor[port6] = 127;
    }
    else if(vexRT[Btn6D] == 1)
    {
      motor[port6] = -127;
    }
    else
    {
      motor[armMotor] = 0;
    }
  }


We have tutorial videos that give good, detailed explanations about all of this. If you're just getting started I highly recommend checking them out: http://www.education.rec.ri.cmu.edu/pro ... tc_cortex/ For topics related to this, you should go to the Remote Control section and watch the videos in the Joystick Mapping and Buttons sections.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Fri Nov 18, 2011 10:34 am
Profile
Rookie

Joined: Sun Sep 18, 2011 2:20 pm
Posts: 8
Post Re: Need help with Program from Cortex to Controller
Code:
#pragma config(Motor,  port1,           x,             tmotorServoStandard, openLoop)
#pragma config(Motor,  port2,           boom,          tmotorServoStandard, openLoop)
#pragma config(Motor,  port3,           ldrive,        tmotorServoStandard, openLoop)
#pragma config(Motor,  port4,           rdrive,        tmotorServoStandard, openLoop)
#pragma config(Motor,  port5,           armMotor,      tmotorServoStandard, openLoop)
#pragma config(Motor,  port6,           armMotor,      tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  while (1 == 1)
  {
       motor[port2] = vexRT(Ch2);
        motor[port3] = vexRT(Ch3);
        motor[port4] = vexRT(Ch4);
        motor[port5] = vexRT(Ch5);
      }
      
      
if(vexRT[Btn5U] == 1)
    {
      motor[port5] = 127;
    }
    else if(vexRT[Btn5D] == 1)
    {
      motor[port5] = -127;
    }
    else
    {
      motor[armMotor] = 0;
    }    
}





Fri Nov 18, 2011 10:51 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 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:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.