View unanswered posts | View active topics It is currently Sat Dec 15, 2018 2:43 pm






Reply to topic  [ 2 posts ] 
vex edr getting started 
Author Message
Rookie

Joined: Tue Sep 29, 2015 12:42 am
Posts: 1
Post vex edr getting started
Hi, i'm trying to get started on the vex edr using the clawbot+cortex as the starting point. I have built the clawbot and the default code works as advertised. I'm now trying to see if I can modify the default code. I have a license to RobotC and trying to find a matching sample. The closest I can find is Robotc Vex Cortex Default.c, which I assume matches. It looks a lot more complicated that the 4 simple controls expected by the clawbot - I guess that is so it can be useful for more than one sample robot?

Thanks,
-Z :shock: 8)


Tue Sep 29, 2015 12:57 am
Profile
Moderator
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Post Re: vex edr getting started
So the sample you are looking at is under the advanced section of the sample program directory. This deals with several sensors and support for more motors to be plugged in. Just for simple driving with the clawbot I would suggest ClawBot Single Joystick Control found under the remote control category in the sample programs.
Code here

Code:
#pragma config(Motor,  port1,           leftMotor,     tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port6,           clawMotor,     tmotorVex269, openLoop, reversed)
#pragma config(Motor,  port7,           armMotor,      tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port10,          rightMotor,    tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*----------------------------------------------------------------------------------------------------*\
|*                                - Clawbot Single Joystick Control -                                 *|
|*                                      ROBOTC on VEX 2.0 Cortex                                      *|
|*                                                                                                    *|
|*  This program uses a single joystick, either right or left to drive the robot. Use notes below     *|
|*  to reconfigure which joystick is used. The joystick buttons are used to raise and lower the arm.   *|
|*  The joystick buttons are used to open and close the claw.                                                               *|
|*                                                                                                                                                      *|
|*                                        ROBOT CONFIGURATION                                         *|
|*    NOTES:                                                                                          *|
|*    1)   Ch1 is the X axis and Ch2 is the Y axis for the RIGHT joystick.                             *|
|*    2)   Ch3 is the Y axis and Ch4 is the X axis for the LEFT joystick.                              *|
|*      3)   Button 5U and 5L are on the front left side of the joystick.                                                *|
|*      3)   Button 6U and 6L are on the front right side of the joystick.                                                *|
|*                                                                                                    *|
|*    MOTORS & SENSORS:                                                                               *|
|*    [I/O Port]        [Name]          [Type]                               [Description]            *|
|*    Motor - Port 2   rightMotor    VEX 393 Motor                         Right drive motor          *|
|*    Motor - Port 6   clawMotor     VEX 393 Motor w/ Motor Controler 29   Claw motor                 *|
|*    Motor - Port 7   armMotor      VEX 393 Motor w/ Motor Controler 29   Arm motor                  *|
|*    Motor - Port 10  leftMotor     VEX 393 Motor                         Left drive motor           *|
\*----------------------------------------------------------------------------------------------------*/

//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
task main ()
{

   while(1 == 1)
   {
      motor[leftMotor]  = (vexRT[Ch2] + vexRT[Ch1])/2;  // (y + x)/2
      motor[rightMotor] = (vexRT[Ch2] - vexRT[Ch1])/2;  // (y - x)/2

// Raise, lower or do not move arm
      if(vexRT[Btn5U] == 1)          //If button 5U is pressed...
      {
         motor[armMotor] = 127;       //...raise the arm.
      }
      else if(vexRT[Btn5D] == 1)     //Else, if button 5D is pressed...
      {
         motor[armMotor] = -127;      //...lower the arm.
      }
      else                            //Else (neither button is pressed)...
      {
         motor[armMotor] = 0;         //...stop the arm.
      }

// Open, close or do not more claw
      if(vexRT[Btn6U] == 1)          //If Button 6U is pressed...
      {
         motor[clawMotor] = 127;        //...close the gripper.
      }
      else if(vexRT[Btn6D] == 1)     //Else, if button 6D is pressed...
      {
         motor[clawMotor] = -127;       //...open the gripper.
      }
      else                            //Else (neither button is pressed)...
      {
         motor[clawMotor] = 0;          //...stop the gripper.
      }
   }
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Sat Nov 07, 2015 7:24 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.