Tutorials/Getting Started/Getting Started with the VEX CORTEX

From ROBOTC API Guide
Jump to: navigation, search
Tutorials → Tutorials/Getting Started/Getting Started with the VEX CORTEX



Getting Started with the VEX CORTEX

Configuring the VEX Cortex for a WIRED connection using USB

This is a guide for setting up the VEX Cortex using the USB A-to-A cable. These steps are required the first time you use your computer to program a specific VEX Cortex, or after you've upated ROBOTC to the latest verstion. Once you've successfully completed these steps you can download your own programs without revisiting them. Note: Administrative privileges are required for some of these steps.


Driver Installation

ROBOTC 3.05 and later automatically installs the necessary drivers for the VEX Cortex, VEXnet Joysticks, and USB-to-Serial Programming cable. If you need to download the drivers for troubleshooting purposes, you can still find them at www.ROBOTC.net/download/cortex.


Download ROBOTC Firmware

The ROBOTC Firmware enables you to download ROBOTC programs to your robot and utilize the various debugger windows.

Prerequisites:

  • Connect the Cortex to your computer (over VEXnet or USB) and power it on
  • Make sure VEX 2.0 Cortex is selected as the Platform Type


Go to Robot > Download Firmware > ROBOTC Firmware and select "Standard File" to download the ROBOTC Firmware to your robot.
Tut-dl-robotc-fw-vex2.png


A Download Progress window will appear and begin the download process.
Robotc download-vex2-tut.png


Once the Download Progress window closes, the ROBOTC Firmware download is complete. Your VEX Cortex is now ready to be programmed in ROBOTC over the USB A-to-A cable.
Robotc success.png


Note: You only need to download the ROBOTC Firmware once, when you first start using a VEX Cortex with ROBOTC, or when you upgrade to a newer version of ROBOTC. You do not need to re-download the ROBOTC firmware every time you want to download code.

If you are also using the VEXnet Joysticks, you will need to update its firmware and establish a wireless VEXnet link between it and the Cortex.


Download VEXnet Joystick Firmware

The VEXnet Joystick includes two joysticks (each having an X and Y-axis), 8 buttons on the front, and 4 additional trigger buttons on the top. Inside, there is also 3-Axis accelerometer, capable of providing X-Y-Z acceleration values. Values from the joysticks, buttons, and accelerometer are sent as a constant stream of information over VEXnet to the robot, enabling a user to control the robot in real-time.

You will need to update the firmware on the VEXnet Joystick to ensure that it will operates correctly.

Placing your VEXnet Joystick in "Bootload" mode is necessary before downloading the VEXnet Joystick Firmware. Keep the VEXnet Joystick powered OFF. The process of placing your VEXnet Joystick in Bootload mode is easier if you start by plugging one end of the USB A-to-A cable into the device. Keep the VEXnet Joystick turned OFF, and do not plug the other end of the USB A-to-A cable in yet.
Joy01.jpg


Use a paperclip to press and hold in the CONFIG button on the front of the VEXnet Joystick.
Joy02.JPG


Keeping the CONFIG button pressed in, connect the other end of the USB A-to-A cable to your computer.
Joy03.JPG


After a few seconds, release the CONFIG button. The ROBOT and GAME lights will blink green.
Joy04.JPG


Downloading VEXnet Joystick Firmware
Go to Robot > Download Firmware > VEXnet Joystick Firmware and select "Standard File" to download the latest VEXnet Joystick Firmware to the controller.
Joystick.png


A Download Progress window will appear and begin the download process.
Download master.png


When the window closes, the firmware download is complete.
Joysticksuccess.png


Note: You only need to download the VEXnet Joystick Firmware once, when you first start using it with ROBOTC, or when you upgrade to a newer version of ROBOTC.


Setting up VEXnet Communication

In this section, you will learn how to pair a VEX Cortex Microcontroller to a VEXnet Remote Control, allowing them to communicate over VEXnet. This section assumes that you have already updated the master firmware on the VEX Cortex and VEXnet Remote Control. VEXnet is an 802.11 WiFi communication system between the VEX Cortex and VEXnet Remote Control.

VEXnet features include:

  • Easy to connect (No IP addresses, MAC addresses, passwords, or special security modes)
  • Multiple layers of security built-in and always on
  • No wireless access point needed; each VEXnet pair makes its own private network
  • Hundreds of robots can operate at once; every VEXnet robot has a hidden unique ID
  • Optional tether for wired communication
  • Optional 9V battery backup to maintain wireless link during a main 7.2V power loss
  • LED scheme displays the status of the Robot, VEXnet link, and Game (Competition Mode)


1. Begin by connecting both the Cortex and VEXnet Remote Control to charged batteries.


1a. Connect a 7.2V robot battery to the Cortex, but do not power it ON.
SS-2010-10-13 17.05.00.png


1b. Remove the battery cover plate on the remote control. Install 6 AAA batteries, and replace the battery cover plate. Do not power the remote control ON.
SS-2010-10-13 17.05.16.png


2. Tether the USB port on the VEXnet Remote Control to the USB port on the Cortex using a USB A-to-A cable.


2a. Plug one end of the USB A-to-A cable into the USB port on the VEXnet Remote Control.
SS-2010-10-13 17.05.30.png


2b. Plug the other end of the USB A-to-A cable into the USB port on the VEX Cortex.
SS-2010-10-13 17.05.48.png


3. Power the Cortex ON. After a few seconds, ROBOT and VEXnet LEDs will blink green, indicating that the Cortex and VEXnet Remote Control have successfully paired


3a. Turn the Cortex ON
SS-2010-10-13 17.07.00.png


3b.The ROBOT and VEXnet LEDs will blink green once the Cortex and VEXnet Remote Control have successfully paired. The GAME LED will also blink green if a program is stored on your Cortex.
DSCF8674.jpg


4. Turn the Cortex OFF.
SS-2010-10-13 17.06.15.png


5. Remove the USB A-to-A cable from the VEXnet Remote Control and Cortex.
SS-2010-10-13 17.06.42.png


6. Insert VEXnet USB Keys into both the VEXnet Remote Control and Cortex.
DSCF8692.jpg


Note: It does not matter which VEXnet USB Key you insert into the Cortex versus the VEXnet Remote Control. Pairing the Cortex and VEXnet Remote Control establishes the link; the VEXnet USB Keys act as antennas for the link.

7. Power the Cortex and Remote Control ON. After roughly 15 seconds, the ROBOT and VEXnet LED’s will blink green, indicating that the VEXnet communication link has been established.


7a. Turn the Cortex ON
SS-2010-10-13 17.07.00.png


7b. Turn the VEXnet Remote Control ON
SS-2010-10-13 17.07.19.png


7c. After roughly 15 seconds, the ROBOT and VEXnet status LEDs will start blinking green. With the VEXnet link established, you should power OFF your Cortex and VEXnet Remote Control to preserve battery.
SS-2010-10-13 17.07.33.png


Troubleshooting

Issue: Slow blinking green ROBOT light on the Cortex Solution: Download the Cortex Master Firmware using ROBOTC.

Issue: Slow blinking ROBOT green light on the VEXnet Remote Control Solution: Push and hold CONFIG button for about 5 seconds, until the status LEDs starts blinking green. Release it, wait for another 5 seconds, and then turn the VEXnet Remote Control OFF and then back ON. If that fails, download the VEXnet Joystick Firmware using ROBOTC.

Issue: Yellow or red ROBOT light on the Cortex Solution: Make sure you are using fully charged Robot battery.

Issue: Yellow or red ROBOT light on the VEXnet Remote Control, even though they are both green on the Cortex. Solution: Power cycle both the VEXnet Remote Control and CORTEX.


VEXnet Remote Control Calibration

This document contains the procedure for calibrating the VEXnet Remote Control joysticks. Some steps are time-sensitive, so it’s recommended that you read through the instructions once before following along.

The VEXnet Remote Control includes two joysticks (each having an X and Y-axis), 8 buttons on the front, and 4 additional trigger buttons on the top. Inside, there is also 3-Axis accelerometer, capable of providing X-Y-Z acceleration values. Values from the joysticks, buttons, and accelerometer are sent as a constant stream of information over VEXnet to the robot, enabling a user to control the robot in real-time. To ensure that the VEXnet Remote Control sends out accurate joystick values, the joysticks must be calibrated before their first use, and after any firmware updates are applied to the remote control.

You will need:

  • A VEXnet Remote Control with batteries
  • A VEX Cortex with robot battery
  • A small Allen wrench (1/16” or smaller) or paper clip


1. Power on the VEXnet Remote Control and VEX Cortex. Allow them to sync over VEXnet.
SS-2010-10-13 15.10.44.png


2. Press and hold the 6U trigger button.
SS-2010-10-13 15.12.05.png


3. While keeping the 6U trigger button pressed in, use your Allen wrench or paper clip to press in the internal CONFIG button until the JOYSTICK LED blinks red and green.


3a. While still pressing in the 6U trigger button, use an Allen wrench or paper clip to press in the CONFIG button.
SS-2010-10-13 15.12.19.png


3b. Once the JOYSTICK LED begins to blink red and green, release both the 6U and CONFIG buttons.
SS-2010-10-13 15.12.33.png


Important - Time Sensitive Instructions
There is a 10 second time limit to complete steps 4 and 5. If they are not completed in time, the calibration process will timeout and the VEXnet LED will blink red briefly.

4. Move both joysticks through their full ranges of motion. When the remote control detects that the joysticks have been fully rotated, the JOYSTICK LED stops blinking red and green, and switches to a solid green.

4a. Move the joysticks through their full ranges of motion - Up, Down, Left, Right, and in a circle.
SS-2010-10-13 15.12.49.png


4b. Once the remote control detects that the joysticks have been fully rotated, the JOYSTICK LED switches to solid green, indicating that you can stop moving the joysticks.
SS-2010-10-13 15.13.09.png


5. Press the 8U button to save the joystick calibration on your remote control. The JOYSTICK LED will blink green for a few seconds.
SS-2010-10-13 15.13.27.png


Additional Information

  • If the calibration is not saved, the process will timeout after 10 seconds and the VEXnet LED will blink red.
  • To cancel a calibration, press the 7U button. The calibration process will be discontinued and the VEXnet LED will blink red.
  • Once the calibration is discontinued or saved, all of the remote control LEDs will resume their normal function.
  • The joysticks must be calibrated any time the firmware on the remote control is downloaded.


Sample Programs

One of the best ways to start working with ROBOTC and learning how to program is to look at already developed programs. ROBOTC comes with over 75 sample programs to help the programmer learn how to program their robotics controllers.

To access these sample programs, open the "Sample Programs" folder by going to the "File" menu and selecting "Open Sample Program."
Sampleprograms menu.png


Inside of the sample programs folder, there are a number of samples organized by topic. ROBOTC will automatically open the sample programs folder of the platform you currently have selected.
Sampleprogram files.png


Just double click on one of the sample programs to open it up and learn more about ROBOTC programming.


Compiling and Downloading

ROBOTC is considered to be an "Integrated Development Environment." This means that ROBOTC has a custom text editor for developing code that will assist the programmer by color coding different potions of code to differentiate between integers, reserved words, functions and parameters.

SS-2010-10-14 11.33.22.png


ROBOTC also contains a compiler for turning this user generated code in a byte-code language that the different controller platforms can understand. To run the compiler, access the compile function from the "Robot" menu.
SS-2010-10-14 11.33.57.png


When the compiler runs, ROBOTC will check your program for errors and warnings that would cause your program to not run properly on the robot. Rather than send this broken code to your robot, ROBOTC will inform you of these errors so they can be corrected.

In the example below:

  • The reserved word 'motor' was incorrectly typed as 'Motor', generating a warning. A warning tells the user that they've created an error, but ROBOTC is able to correct this error itself when the program is sent to the controller. A program with warning will compile successfully, but users should use good programming practice to avoid warnings. Warnings are denoted by a yellow "X".
  • The code on line 5 is missing a semicolon, which is generating an error. An error will prevent the program from being sent to the controller. ROBOTC will do its best to explain what the error to assist the user. In this example, ROBOTC is informing the user they left a semicolon off a line of their program which is preventing the program from being compiled. Errors are denoted by a red "X".

SS-2010-10-14 11.34.58.png


Before downloading code to your robot, you should verify that the "VEX Cortex Download Method" matches your setup.
SS-2010-10-14 11.35.39.png


Option 1: Download Using VEXnet or USB
With this option selected, ROBOTC will download ROBOTC firmware and programs to your Cortex using a VEXnet or USB connection. In this mode, when the Cortex is powered ON it will look for a VEXnet or USB connection before running your program. (The Communication Port > Automatic Selection option in the ROBOTC Preferences should be selected if you plan on switching between VEXnet and USB as your download method.)

Option 2: Download Using USB Only
With this option selected, ROBOTC will download firmware and programs to your Cortex using only the USB connection. In this mode, when the Cortex is powered ON it will immediately run your program. This option is NOT recommended if you are using the VEXnet Joysticks to download to the Cortex, or remotely control it.

Option 3: Download for Competition (VEXnet)
This option disables the ROBOTC debugger, and is not recommended for classroom use.

Note: Switching between Download Modes may require you to power cycle your Cortex before it takes effect.

Once your program has successfully compiled and you've selected the appropriate Download Method, you can send the program to the controller by clicking the "Compile and Download Program" option under the "Robot" menu. Note: Your robot must be turned on and connected to the computer before you can download a program.
SS-2010-10-14 11.36.04.png


Once the download starts, a "Download Progress" bar will appear. This bar will show the status of the transfer of the compiled byte-code to the controller.
SS-2010-10-13 14.05.46.png


Once the download finishes, ROBOTC's built in debugger will be launched. There will be a number of windows that launch, such as the Global Variables window, the Devices window and the Program Debug window. You can start your programs execution by clicking the "Start" button on the "Program Debug" window. Learn more about these windows in the 'Debugger' section of the help file.
Compiler.png