Difference between pages "ARDUINO MEGA Update Bootloader" and "Tutorials/Getting Started/Getting Started with the VEX CORTEX"

From ROBOTC API Guide
(Difference between pages)
Jump to: navigation, search
(Software Needed)
 
(Step 6: Updating VEXNet Key's firmware (2.0 and later only))
 
Line 1: Line 1:
'''Note: This document only applies to the MEGA 2560 and MEGA ADK Arduino Boards. All other Arduino boards bootloaders are good!'''
+
{{DISPLAYTITLE:Getting Started with the VEX Cortex}}
 +
<yambe:breadcrumb self="Getting Started with the VEX Cortex">Tutorials|Tutorials</yambe:breadcrumb>
 +
<br />
  
== Arduino 2560 Bootloader Issue ==
+
{{toc}}
The current bootloader burned onto the Arduino MEGA 2560/ADK is not compatible with ROBOTC. In its current form, you will be able to download the ROBOTC Firmware to the Arduino MEGA 2560/ADK, but you will not able to download any user programs.
+
<br />
  
The reason for this is because there is a bug in the Arduino MEGA 2560/ADK firmware that does not allow flash write commands to start at anywhere but the beginning of flash memory (0x000000). See the bottom of this page for more technical details.
+
== Configuring the VEX Cortex for a WIRED connection using USB ==
 +
{|width="740px"
 +
|-
 +
|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.'''
 +
|}
 +
<br />
  
Because ROBOTC is not able to burn a new bootloader as of today, you will need to use the Arduino's Open Source language with our a modified bootloader file to re-burn your bootloader on your Arduino MEGA 2560/ADK boards. '''The enhanced bootloader is backwards compatible with the original one.  That means you'll still be able to program it through the Arduino programming environment as before, in addition to ROBOTC for Arduino.'''
+
=== Note: Driver Installation ===
 +
{|width="740px"
 +
|-
 +
|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:<br />
 +
{{vex2-drivers}}
 +
|}
 +
<br />
  
== Hardware Needed  ==
+
=== Step 1: Connect the Cortex to your PC ===
To burn a new version of the Arduino bootloader to your MEGA 2560/ADK, you'll need an AVR ISP Compatible downloader.
+
{|width="740px"
 +
|-
 +
|Connect the VEX Cortex directly to a USB port on your computer using the USB A-to-A cable. Allow a few seconds for Windows to recognize the device.<br />
 +
[[File:vex2-getting-started-connect.JPG]]<br />
 +
<br />
 +
|-
 +
|Connect a 7.2V Robot battery to the Cortex and move the POWER switch to the ON position. Optionally, you can connect two motors to MOTOR Ports 2 and 3 for testing a sample program later in the sequence. You can connect 3-wire motors directly, or the newer 2-wire motors using Motor Controller 29 cables.<br />
 +
[[File:vex2-getting-started-battery_motors.JPG]]<br />
 +
''Note: Technically, the battery is not necessary for downloading Master CPU Firmware and ROBOTC Firmware, but it has helped in cases where the USB ports on the computer provide too little power to facilitate a reliable connection to the Cortex.''
 +
|}
 +
<br />
  
'''Using an AVR ISP (In System Programmer)'''
+
=== Step 2: Platform Type and Communication Port ===
*Your Arduino MEGA 2560/ADK (to program)
+
{|width="740px"
*An AVR Programmer such as the [http://www.sparkfun.com/products/9825 AVR Pocket Programmer]
+
|-
*An AVR Programming Cable (the pocket programmer comes with one)
+
|Specify that you are using the Cortex and how it is connected to your computer in ROBOTC. Go to Robot &rarr; Platform Type &rarr; Innovation First (IFI) and select "'''VEX 2.0 Cortex'''" or "'''Natural Language (VEX Cortex)'''".<br />
 +
[[File:vex2-getting-started-platform-selection.png]]<br />
 +
''Note: You should choose "'''VEX 2.0 Cortex'''" if you plan on programming using the standard ROBOTC language. Choose "'''Natural Language (VEX Cortex)'''" if you want to take advantage of the Natural Language commands in ROBOTC.''<br />
 +
<br />
 +
|-
 +
|Then go to View and choose Select Communication Port.<br />
 +
[[File:Comm port.png]]<br />
 +
<br />
 +
|-
 +
|The Select Communications Port for Platforms window will appear. From the Communications Port drop down list, you should see "Automatic Selection" and one of two additional options:
  
----
+
If your VEX Cortex is in "bootload mode" or running an older (2.x) version of the Master CPU Firmware, it will appear as a "USB Wired Cable" option in the list.<br />
 +
[[File:Comm port select.png]]<br />
 +
<br />
 +
|-
 +
|If your VEX Cortex is running a newer (3.x) version of the Master CPU Firmware, it will appear as a "Vex Robotics Comm Port" in the list.<br />
 +
[[File:vex2-getting-started-auto-select.png]]<br />
 +
''Make sure that "Automatic Selection" or one of the two legitimate options is selected. If you ever plan on programming your robot wirelessly over VEXnet, choosing "Automatic Selection" is recommended. Press OK to save your choice.''
  
If you have extra Arduino boards, but no ISP programmer, SparkFun.com has a cool tutorial on how to flash a bootloader using an Arduino as an ISP.
+
  
'''Using another Arduino as an ISP'''
+
'''''Important:''' If the "USB Wired Cable" or "Vex Robotics Comm Port" options do not appear in the drop down menu when a VEX Cortex is connected, this may indicate that Windows has not recognized the device or access to it is blocked. Ensure that the VEX Cortex Device Driver was successfully installed with Administrative Privileges, disconnect and reconnect your Cortex from the computer, and press "Refresh List" to force ROBOTC to repopulate the list.''
*Your Arduino MEGA 2560/ADK (to program)
+
|}
*A Working Arduino (doesn't matter what kind)
+
<br />
*Some Male-to-Male Jumper Cables
+
  
For instructions on this method, take a look at the SparkFun.com website: http://www.sparkfun.com/tutorials/247
+
=== Step 3: Updating VEX Cortex Firmware ===
 +
{|width="740px"
 +
|-
 +
|Go to Robot &rarr; Download Firmware and select "Automatically Update VEX Cortex".<br />
 +
[[File:vex2-getting-started-auto-update.png]]<br />
 +
<br />
 +
|-
 +
|A message will appear, informing you that the software will update your Cortex to the latest Master CPU and ROBOTC Firmware files. Press OK to begin the process.<br />
 +
[[File:vex2-getting-started-robotc-message.png]]<br />
 +
<br />
 +
|-
 +
|A Download Progress window will appear, showing the progress of the Master CPU Firmware download.<br />
 +
[[File:vex2-getting-started-download-progress.png]]<br />
 +
<br />
 +
|-
 +
|When the Master CPU Firmware download is complete, a ROBOTC Message will appear and inform you that it will now update the ROBOTC firmware, if needed. Press OK to continue the process.<br />
 +
[[File:vex2-getting-started-ROBOTC_Message-2012-01-06_12_59_37.png]]<br />
 +
<br />
 +
|-
 +
|''Note: If this is the first time a VEX Cortex running the 3.x Master CPU Firmware has been connected to your computer, Windows will recognize it as a new device, and may prompt you to verify the new hardware installation. Press Continue or Continue Anyway to complete the installation.''<br />
 +
[[File:New hw.png]]<br />
 +
<br />
 +
|-
 +
|If your ROBOTC Firmware is out-of-date, another Download Progress window will appear and begin the ROBOTC Firmware download.<br />
 +
[[File:vex2-getting-started-Download_Progress-2012-01-06_13_00_34.png]]<br />
 +
<br />
 +
|-
 +
|When the download completes, another ROBOTC Message will appear. Press OK to complete the process.<br />
 +
[[File:vex2-getting-started-ROBOTC_Message-2012-01-06_13_00_00.png]]<br />
 +
<br />
 +
|-
 +
|'''''Notes:'''''
  
== Software Needed ==
+
Once this step is complete, you should no longer need Administrative privileges on your computer; you should be able to download Master CPU Firmware, ROBOTC firmware, and ROBOTC programs in a permissions-restricted account. Only future updates to ROBOTC and the VEX Cortex Device Driver will require Administrative privileges. Exception: On some computers, Windows may prompt you to "install new hardware" each time the Cortex is plugged in on a different USB port. To alleviate the issue, connect the updated VEX Cortex on each USB port as an administrator (no need to redownload firmware), or dedicate one USB port for communication with the VEX Cortex.
ROBOTC is not currently able to burn a bootloader onto an Arduino board, so you'll need to download a copy of the latest version of the Arduino Open-Source programming language.
+
*Arduino Official Programming Language - [http://arduino.cc/en/Main/Software|Arduino Download Page]
+
  
In addition, you'll need the ROBOTC modified bootloader. You can download that here:
+
'''You only need to download the 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 firmware every time you want to download code. If the download fails, disconnect the VEX Cortex from your computer and turn it off. Then reconnect it to the computer, allow a few seconds to ensure that Windows recognizes it, turn it on, and try downloading the firmware again.
*ROBOTC Modified MEGA 2560/ADK Bootloader - [http://cdn.robotc.net/downloads/arduino/stk500boot_v2_mega2560.hex Modified Bootloader]
+
|}
 +
<br />
  
== Bootload Download Instructions ==
+
=== Step 4: Downloading and Running Code ===
* Download the [http://arduino.cc/en/Main/Software Arduino Open Source Software] and a copy of the [http://cdn.robotc.net/downloads/arduino/stk500boot_v2_mega2560.hex Modified Bootloader] File
+
{|width="740px"
* Copy the Modified Bootloader File into the /Arduino-1.0/hardware/arduino/bootloaders/stk500v2/ and overwrite the existing bootloader.
+
|-
[[File:CopyBootloader.png|800px]]
+
|ROBOTC contains a large library of sample programs to help you get started. These sample programs can be downloaded to your VEX Cortex using the USB A-to-A cable, or using a wireless VEXnet connection.<br />
* Power up your Arduino MEGA 2560/ADK (either via USB or external power)
+
<br />
* Plug in your AVR ISP Programmer to your computer (make sure you have any required drivers installed)
+
The VEX Cortex Communication Mode controls how ROBOTC downloads programs to your Cortex, as well as what types of connections your Cortex checks for when it is powered on. Confirm that your VEX Cortex Communication Mode is set to "VEXnet or USB" or "USB Only". "'''USB Only'''" is the recommended method for wired-only programming.<br />
* Connect your AVR ISP Programmer into your Arduino MEGA 2560/ADK Board via the ISP Header (the 2x3 header pins right above the Arduino Logo)
+
[[File:vex2-getting-started-usb-only.png]]<br />
* Launch the Arduino Open Source Software
+
<br />
[[File:ArduinoLaunch.png]]
+
'''Option 1: VEXnet or USB'''<br />
* Change your settings in the Arduino Software to look for an Arduino MEGA 2560/ADK
+
With this option selected, ROBOTC will download 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 for up to 15 seconds before running your program. (The Communication Port &rarr; Automatic Selection option in the ROBOTC Preferences should be selected if you plan on switching between VEXnet and USB as your download method.)<br />
[[File:ArduinoSelectPlatform.png]]
+
* Change your settings in the Arduino Software to select your ISP Programmer Type (Check your programmer's documentation for the exact model)
+
[[File:ArduinoSelectProgrammer.png]]
+
* Select the "Burn Bootloader" option under the "Tools" menu. The modified bootloader will now be sent to your Arduino. This typically take a minute or so.
+
[[File:BurnBootloader.png]]
+
* You should be all set to download ROBOTC firmware and start using your Arduino MEGA 2560/ADK with ROBOTC!
+
  
== Technical Details ==
+
'''Option 2: USB Only'''<br />
The Arduino Bootloader sets the "eraseAddress" to zero every time the bootloader is called. ROBOTC called the "Load Address" command to set the address in which we want to write/verify when downloading program.
+
With this option selected, ROBOTC will download 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 will NOT work if you are using the VEXnet Joysticks to download to the Cortex, or remotely control it.<br />
  
When writing a page of memory to the arduino, the Arduino bootloader will erase the existing page and write a whole new page.
+
'''Option 3: Competition (VEXnet)'''<br />
 +
This option disables the ROBOTC debugger, and is not recommended for classroom use.<br />
 +
<br />
 +
|-
 +
|To open a sample program, go to File &rarr; Open Sample Program.<br />
 +
[[File:vex2-getting-started-program 2.png]]<br />
 +
<br />
 +
|-
 +
|Navigate to the Basic Movement folder and open "Moving Forward.c".<br />
 +
[[File:vex2-getting-started-program 1.png]]<br />
 +
<br />
 +
|-
 +
|Make sure that your robot is connected to the computer and turned ON. Then go to Robot &rarr; Compile and Download Program.<br />
 +
[[File:vex2-getting-started-compile.png]]<br />
 +
<br />
 +
|-
 +
|'''''Important Note:''''' The VEX Cortex Communication Mode is stored in ROBOTC and on the Cortex. If you change the setting, it gets transferred to the Cortex the next time you download a program. The Cortex must be power cycled (disconnected from the computer, turned fully off, and then back on) before the change will take effect.<br />
 +
[[File:vex2-getting-started-download_method_chage.png]]<br />
 +
<br />
 +
|-
 +
|Download Progress window will appear while the program is downloading to the Cortex.<br />
 +
[[File:Robotc download-vex2-tut.png]]<br />
 +
<br />
 +
|-
 +
|When the Download Progress window closes, the Program Debug window will appear. You can run your program by pressing the "Start" button, or by disconnecting the robot and turning it OFF and back ON.<br />
 +
[[File:vex2-getting-started-program_debug.png]]<br />
 +
<br />
 +
|-
 +
|With the sample program above, you should observe motors plugged into Ports 2 and 3 spinning for 3 seconds.<br />
 +
[[File:vex2-getting-started-battery_motors.JPG]]<br />
 +
<br />
 +
|}
 +
<br />
  
In the scenario of downloading firmware, everything is great because the Erase Address and the Loaded Address both start at zero.
+
=== Step 5: Getting More Help ===
 +
{|width="740px"
 +
|-
 +
|ROBOTC includes a useful Help system. You can launch the help system by going to the '''Help''' menu and selecting '''Open Help''', or by pressing the '''F1''' key on your keyboard.<br />
 +
[[File:vex2-getting-started-help.png]]<br />
 +
<br />
 +
|-
 +
|The [http://www.education.rec.ri.cmu.edu/products/teaching_robotc_cortex/index.html VEX Cortex Video Trainer] provides many useful video tutorials for learning the VEX Cortex system and ROBOTC Programming.
  
In the scenario of writing a user program, we start writing at memory location 0x7000, but the Bootloader erases information starting at location zero because the "Load Address" command doesn't update where to erase.
 
  
Our modification is to set both the Load Address and the Erase Address so the activity of writing a user program doesn't cause the firmware to be accidentally erased!
+
Additional help and support can be found at http://www.robotc.net or by e-mailing support@robotc.net
 +
|}
 +
<br />
  
=== Original Bootloader ===
+
== Configuring the VEX Cortex for a WIRELESS connection using the VEXnet Joysticks ==
<syntaxhighlight lang="ROBOTC">
+
{|width="740px"
case CMD_LOAD_ADDRESS:
+
|-
#if defined(RAMPZ)
+
|This is a guide for configuring the VEX Cortex system to be programmed wirelessly using a VEXnet connection. 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.'''
  address = (((address_t)(msgBuffer[1])<<24)|((address_t)(msgBuffer[2])<<16)|
+
|}
            ((address_t)(msgBuffer[3])<<8)|msgBuffer[4]))<<1;
+
<br />
#else
+
  address = (((msgBuffer[3])<<8)|(msgBuffer[4]))<<1;  //convert word to byte address
+
#endif
+
msgLength = 2;
+
msgBuffer[1] = STATUS_CMD_OK;
+
break;
+
  
case CMD_PROGRAM_FLASH_ISP:
+
=== Note: Driver Installation ===
case CMD_PROGRAM_EEPROM_ISP:
+
{|width="740px"
{
+
|-
  unsigned int size = ((msgBuffer[1])<<8) | msgBuffer[2];
+
|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:<br />
  unsigned char *p = msgBuffer+10;
+
{{vex2-drivers}}
  unsigned int data;
+
|}
  unsigned char highByte, lowByte;
+
<br />
  address_t tempaddress = address;
+
  
  if ( msgBuffer[0] == CMD_PROGRAM_FLASH_ISP )
+
=== Step 1: Connect the Cortex to your PC ===
  {
+
{|width="740px"
    // erase only main section (bootloader protection)
+
|-
    if (eraseAddress < APP_END )
+
|Connect the VEX Cortex directly to a USB port on your computer using the USB A-to-A cable. Allow a few seconds for Windows to recognize the device.<br />
    {
+
[[File:vex2-getting-started-connect.JPG]]<br />
      boot_page_erase(eraseAddress); // Perform page erase
+
<br />
      boot_spm_busy_wait(); // Wait until the memory is erased.
+
|-
      eraseAddress += SPM_PAGESIZE; // point to next page to be erase
+
|Connect a 7.2V Robot battery to the Cortex and move the POWER switch to the ON position. Optionally, you can connect two motors to MOTOR Ports 2 and 3 for testing a sample program later in the sequence. You can connect 3-wire motors directly, or the newer 2-wire motors using Motor Controller 29 cables.<br />
    }
+
[[File:vex2-getting-started-battery_motors.JPG]]<br />
</syntaxhighlight>
+
''Note: Technically, the battery is not necessary for downloading Master CPU Firmware and ROBOTC Firmware, but it has helped in cases where the USB ports on the computer provide too little power to facilitate a reliable connection to the Cortex.''
=== ROBOTC Compatible Modification ===
+
|}
<syntaxhighlight lang="ROBOTC">
+
<br />
case CMD_PROGRAM_FLASH_ISP:
+
case CMD_PROGRAM_EEPROM_ISP:
+
{
+
  unsigned int size = ((msgBuffer[1])<<8) | msgBuffer[2];
+
  unsigned char *p = msgBuffer+10;
+
  unsigned int data;
+
  unsigned char highByte, lowByte;
+
  address_t tempaddress = address;
+
  
 +
=== Step 2: Platform Type and Communication Port ===
 +
{|width="740px"
 +
|-
 +
|Specify that you are using the Cortex and how it is connected to your computer in ROBOTC. Go to Robot &rarr; Platform Type &rarr; Innovation First (IFI) and select "'''VEX 2.0 Cortex'''" or "'''Natural Language (VEX Cortex)'''".<br />
 +
[[File:vex2-getting-started-platform-selection.png]]<br />
 +
''Note: You should choose "'''VEX 2.0 Cortex'''" if you plan on programming using the standard ROBOTC language. Choose "'''Natural Language (VEX Cortex)'''" if you want to take advantage of the Natural Language commands in ROBOTC.''<br />
 +
<br />
 +
|-
 +
|Then go to View and choose Select Communication Port.<br />
 +
[[File:Comm port.png]]<br />
 +
<br />
 +
|-
 +
|The Select Communications Port for Platforms window will appear. From the Communications Port drop down list, you should see "Automatic Selection" and one of two additional options:
  
  if ( msgBuffer[0] == CMD_PROGRAM_FLASH_ISP )
+
If your VEX Cortex is in "bootload mode" or running an older (2.x) version of the Master CPU Firmware, it will appear as a "USB Wired Cable" option in the list.<br />
  {
+
[[File:Comm port select.png]]<br />
    eraseAddress = address & 0xFFFFFF00;  // ROBOTC Custom Bootloader Addition
+
<br />
 +
|-
 +
|If your VEX Cortex is running a newer (3.x) version of the Master CPU Firmware, it will appear as a "Vex Robotics Comm Port" in the list.<br />
 +
[[File:vex2-getting-started-auto-select.png]]<br />
 +
''Make sure that "Automatic Selection" or one of the two legitimate options is selected. If you ever plan on programming your robot wirelessly over VEXnet, choosing "Automatic Selection" is recommended. Press OK to save your choice.''
  
    // erase only main section (bootloader protection)
+
    if (eraseAddress < APP_END )
+
 
    {
+
'''''Important:''' If the "USB Wired Cable" or "Vex Robotics Comm Port" options do not appear in the drop down menu when a VEX Cortex is connected, this may indicate that Windows has not recognized the device or access to it is blocked. Ensure that the VEX Cortex Device Driver was successfully installed with Administrative Privileges, disconnect and reconnect your Cortex from the computer, and press "Refresh List" to force ROBOTC to repopulate the list.''
      boot_page_erase(eraseAddress); // Perform page erase
+
|}
      boot_spm_busy_wait(); // Wait until the memory is erased.
+
<br />
      eraseAddress += SPM_PAGESIZE; // point to next page to be erase
+
 
    }
+
=== Step 3: Updating VEX Cortex Firmware ===
</syntaxhighlight>
+
{|width="740px"
 +
|-
 +
|Go to Robot &rarr; Download Firmware and select "Automatically Update VEX Cortex".<br />
 +
[[File:vex2-getting-started-auto-update.png]]<br />
 +
<br />
 +
|-
 +
|A message will appear, informing you that the software will update your Cortex to the latest Master CPU and ROBOTC Firmware files. Press OK to begin the process.<br />
 +
[[File:vex2-getting-started-robotc-message.png]]<br />
 +
<br />
 +
|-
 +
|A Download Progress window will appear, showing the progress of the Master CPU Firmware download.<br />
 +
[[File:vex2-getting-started-download-progress.png]]<br />
 +
<br />
 +
|-
 +
|When the Master CPU Firmware download is complete, a ROBOTC Message will appear and inform you that it will now update the ROBOTC firmware, if needed. Press OK to continue the process.<br />
 +
[[File:vex2-getting-started-ROBOTC_Message-2012-01-06_12_59_37.png]]<br />
 +
<br />
 +
|-
 +
|''Note: If this is the first time a VEX Cortex running the 3.x Master CPU Firmware has been connected to your computer, Windows will recognize it as a new device, and may prompt you to verify the new hardware installation. Press Continue or Continue Anyway to complete the installation.''<br />
 +
[[File:New hw.png]]<br />
 +
<br />
 +
|-
 +
|If your ROBOTC Firmware is out-of-date, another Download Progress window will appear and begin the ROBOTC Firmware download.<br />
 +
[[File:vex2-getting-started-Download_Progress-2012-01-06_13_00_34.png]]<br />
 +
<br />
 +
|-
 +
|When the download completes, another ROBOTC Message will appear. Press OK to complete the process.<br />
 +
[[File:vex2-getting-started-ROBOTC_Message-2012-01-06_13_00_00.png]]<br />
 +
<br />
 +
|}
 +
 
 +
=== Step 4: Updating VEXNet Joystick Controller Firmware ===
 +
{|width="740px"
 +
|-
 +
|Disconnect the USB cable from the Cortex and plug it into the USB port on the back of the VEXNet Joystick Controller.
 +
|-
 +
|Go to Robot &rarr; Download Firmware and select "Automatically Update VEXNet Joystick".<br />
 +
<br />
 +
|-
 +
|The Master CPU Firmware file will then be downloaded to the Joystick Controller (there is no ROBOTC firmware residing on the Joystick Controllers). Once the process is complete, you may disconnect the Joystick Controller from the computer.
 +
|-
 +
|}
 +
 
 +
=== Step 5: Pairing the VEXNet Joystick Controller and Cortex ===
 +
{|width="740px"
 +
|-
 +
|The Cortex and VEXNet Controller must be paired together before the VEXNet system will work properly. In order to pair the Cortex and VEXNet Joystick Controller, you must:<br /><br />
 +
*Unplug the Cortex from the computer and turn the Cortex off
 +
*Connect the Cortex to the Joystick Controller via the USB A-to-A cable (NOT the Programming Hardware kit)
 +
*Once the two devices are physically connected, turn on the Cortex and wait for the VEXNet light on the Cortex and Joystick Controller to turn green
 +
|-
 +
|This will connect the two devices and pair them properly so they will only communicate with one another. To pair the Cortex or Joystick Controller with another device, simply repeat the pairing process with the other device instead.
 +
|}
 +
 
 +
=== Step 6: Updating VEXNet Key's firmware (2.0 and later only) ===
 +
{|width="740px"
 +
|-
 +
|VEXNet 2.0 Keys have a separate firmware that resides inside of the individual keys, and may need to be upgraded before use. '''VEXnet 1.0 Key users can skip to Step 7'''.<br /><br />
 +
|-
 +
|First, download and run the '[http://www.vexrobotics.com/wiki/Software_Downloads#2_-_Update_Firmware_on_Cortex_Microcontroller.2C_VEXnet_Joystick.2C_and_VEXnet_Key_2.0 VEXNet Key 2.0 Firmware Upgrade Utility]' from VEX's download page.
 +
|-
 +
|Open the VEXNet 2.0 Firmware Upgrade Utility and plug the VEXNet 2.0 key you wish to upgrade into your computer's USB port. Click the 'Start Update' button within the Utility to start the firmware upgrade process.
 +
|-
 +
|Repeat the process with any remaining VEXNet 2.0 keys that require upgrading.
 +
|-
 +
|}
 +
 
 +
=== Step 7: Setting Cortex Communication Mode ===
 +
{|width="740px"
 +
|-
 +
|Open up a program you would like to load onto the Cortex. For the purposes of this tutorial, we selected the 'Dual Joystick Control' program from the 'Remote Control' Sample Programs folder.<br /><br />
 +
[[File:Cortex VEXNet Sample Prog.png]]<br /><br />
 +
|-
 +
|With the Cortex turned on and plugged in, navigate to 'VEX Cortex Communication Mode' under the 'Robot' menu. Select 'VEXNet or USB' as the communication type.<br /><br />
 +
[[File:Cortex Communication Type.png]] <br /><br />
 +
|-
 +
|Compile and download the program to the Cortex. ROBOTC will pop up a message telling you that the communication mode has been changed and that a power cycle is required in order for the changes to take affect. <br /><br />
 +
[[File:Cortex Communication Powercycle.png]]<br /><br />
 +
|-
 +
|Once the program has downloaded to the Cortex, turn the Cortex off and back on. This 'power cycle' commits the communication type to the Cortex. Remember, you must repeat this process to revert back to USB only (making sure that USB only is selected as the mode). The Cortex should now be set up for wireless communication over VEXNet.<br /><br />
 +
|}
 +
 
 +
'''''Note:'''''
 +
 
 +
Once these steps are complete, you should no longer need Administrative privileges on your computer; you should be able to download Master CPU Firmware, ROBOTC firmware, and ROBOTC programs in a permissions-restricted account. Only future updates to ROBOTC and the VEX Cortex Device Driver will require Administrative privileges. Exception: On some computers, Windows may prompt you to "install new hardware" each time the Cortex is plugged in on a different USB port. To alleviate the issue, connect the updated VEX Cortex on each USB port as an administrator (no need to redownload firmware), or dedicate one USB port for communication with the VEX Cortex.
 +
 
 +
'''You only need to download the Firmware''' 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 firmware every time you want to download code. If the download fails, disconnect the VEX Cortex from your computer and turn it off. Then reconnect it to the computer, allow a few seconds to ensure that Windows recognizes it, turn it on, and try downloading the firmware again.
 +
<br />

Latest revision as of 21:36, 11 April 2014

Tutorials → 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.


Note: 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:
The drivers for the CORTEX Microcontroller and VEXnet Joysticks are included in the ROBOTC 3.0 installers. If, for any reason, you need to download them separately, here are the downloads:
Download Network Driver (in addition to required driver) if ROBOTC will run from a network:


Step 1: Connect the Cortex to your PC

Connect the VEX Cortex directly to a USB port on your computer using the USB A-to-A cable. Allow a few seconds for Windows to recognize the device.

Vex2-getting-started-connect.JPG

Connect a 7.2V Robot battery to the Cortex and move the POWER switch to the ON position. Optionally, you can connect two motors to MOTOR Ports 2 and 3 for testing a sample program later in the sequence. You can connect 3-wire motors directly, or the newer 2-wire motors using Motor Controller 29 cables.

Vex2-getting-started-battery motors.JPG
Note: Technically, the battery is not necessary for downloading Master CPU Firmware and ROBOTC Firmware, but it has helped in cases where the USB ports on the computer provide too little power to facilitate a reliable connection to the Cortex.


Step 2: Platform Type and Communication Port

Specify that you are using the Cortex and how it is connected to your computer in ROBOTC. Go to Robot → Platform Type → Innovation First (IFI) and select "VEX 2.0 Cortex" or "Natural Language (VEX Cortex)".

Vex2-getting-started-platform-selection.png
Note: You should choose "VEX 2.0 Cortex" if you plan on programming using the standard ROBOTC language. Choose "Natural Language (VEX Cortex)" if you want to take advantage of the Natural Language commands in ROBOTC.

Then go to View and choose Select Communication Port.

Comm port.png

The Select Communications Port for Platforms window will appear. From the Communications Port drop down list, you should see "Automatic Selection" and one of two additional options:

If your VEX Cortex is in "bootload mode" or running an older (2.x) version of the Master CPU Firmware, it will appear as a "USB Wired Cable" option in the list.
Comm port select.png

If your VEX Cortex is running a newer (3.x) version of the Master CPU Firmware, it will appear as a "Vex Robotics Comm Port" in the list.

Vex2-getting-started-auto-select.png
Make sure that "Automatic Selection" or one of the two legitimate options is selected. If you ever plan on programming your robot wirelessly over VEXnet, choosing "Automatic Selection" is recommended. Press OK to save your choice.


Important: If the "USB Wired Cable" or "Vex Robotics Comm Port" options do not appear in the drop down menu when a VEX Cortex is connected, this may indicate that Windows has not recognized the device or access to it is blocked. Ensure that the VEX Cortex Device Driver was successfully installed with Administrative Privileges, disconnect and reconnect your Cortex from the computer, and press "Refresh List" to force ROBOTC to repopulate the list.


Step 3: Updating VEX Cortex Firmware

Go to Robot → Download Firmware and select "Automatically Update VEX Cortex".

Vex2-getting-started-auto-update.png

A message will appear, informing you that the software will update your Cortex to the latest Master CPU and ROBOTC Firmware files. Press OK to begin the process.

Vex2-getting-started-robotc-message.png

A Download Progress window will appear, showing the progress of the Master CPU Firmware download.

Vex2-getting-started-download-progress.png

When the Master CPU Firmware download is complete, a ROBOTC Message will appear and inform you that it will now update the ROBOTC firmware, if needed. Press OK to continue the process.

Vex2-getting-started-ROBOTC Message-2012-01-06 12 59 37.png

Note: If this is the first time a VEX Cortex running the 3.x Master CPU Firmware has been connected to your computer, Windows will recognize it as a new device, and may prompt you to verify the new hardware installation. Press Continue or Continue Anyway to complete the installation.

New hw.png

If your ROBOTC Firmware is out-of-date, another Download Progress window will appear and begin the ROBOTC Firmware download.

Vex2-getting-started-Download Progress-2012-01-06 13 00 34.png

When the download completes, another ROBOTC Message will appear. Press OK to complete the process.

Vex2-getting-started-ROBOTC Message-2012-01-06 13 00 00.png

Notes:

Once this step is complete, you should no longer need Administrative privileges on your computer; you should be able to download Master CPU Firmware, ROBOTC firmware, and ROBOTC programs in a permissions-restricted account. Only future updates to ROBOTC and the VEX Cortex Device Driver will require Administrative privileges. Exception: On some computers, Windows may prompt you to "install new hardware" each time the Cortex is plugged in on a different USB port. To alleviate the issue, connect the updated VEX Cortex on each USB port as an administrator (no need to redownload firmware), or dedicate one USB port for communication with the VEX Cortex.

You only need to download the 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 firmware every time you want to download code. If the download fails, disconnect the VEX Cortex from your computer and turn it off. Then reconnect it to the computer, allow a few seconds to ensure that Windows recognizes it, turn it on, and try downloading the firmware again.


Step 4: Downloading and Running Code

ROBOTC contains a large library of sample programs to help you get started. These sample programs can be downloaded to your VEX Cortex using the USB A-to-A cable, or using a wireless VEXnet connection.


The VEX Cortex Communication Mode controls how ROBOTC downloads programs to your Cortex, as well as what types of connections your Cortex checks for when it is powered on. Confirm that your VEX Cortex Communication Mode is set to "VEXnet or USB" or "USB Only". "USB Only" is the recommended method for wired-only programming.
Vex2-getting-started-usb-only.png

Option 1: VEXnet or USB
With this option selected, ROBOTC will download 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 for up to 15 seconds 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: USB Only
With this option selected, ROBOTC will download 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 will NOT work if you are using the VEXnet Joysticks to download to the Cortex, or remotely control it.

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

To open a sample program, go to File → Open Sample Program.

Vex2-getting-started-program 2.png

Navigate to the Basic Movement folder and open "Moving Forward.c".

Vex2-getting-started-program 1.png

Make sure that your robot is connected to the computer and turned ON. Then go to Robot → Compile and Download Program.

Vex2-getting-started-compile.png

Important Note: The VEX Cortex Communication Mode is stored in ROBOTC and on the Cortex. If you change the setting, it gets transferred to the Cortex the next time you download a program. The Cortex must be power cycled (disconnected from the computer, turned fully off, and then back on) before the change will take effect.

Vex2-getting-started-download method chage.png

Download Progress window will appear while the program is downloading to the Cortex.

Robotc download-vex2-tut.png

When the Download Progress window closes, the Program Debug window will appear. You can run your program by pressing the "Start" button, or by disconnecting the robot and turning it OFF and back ON.

Vex2-getting-started-program debug.png

With the sample program above, you should observe motors plugged into Ports 2 and 3 spinning for 3 seconds.

Vex2-getting-started-battery motors.JPG


Step 5: Getting More Help

ROBOTC includes a useful Help system. You can launch the help system by going to the Help menu and selecting Open Help, or by pressing the F1 key on your keyboard.

Vex2-getting-started-help.png

The VEX Cortex Video Trainer provides many useful video tutorials for learning the VEX Cortex system and ROBOTC Programming.


Additional help and support can be found at http://www.robotc.net or by e-mailing support@robotc.net


Configuring the VEX Cortex for a WIRELESS connection using the VEXnet Joysticks

This is a guide for configuring the VEX Cortex system to be programmed wirelessly using a VEXnet connection. 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.


Note: 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:
The drivers for the CORTEX Microcontroller and VEXnet Joysticks are included in the ROBOTC 3.0 installers. If, for any reason, you need to download them separately, here are the downloads:
Download Network Driver (in addition to required driver) if ROBOTC will run from a network:


Step 1: Connect the Cortex to your PC

Connect the VEX Cortex directly to a USB port on your computer using the USB A-to-A cable. Allow a few seconds for Windows to recognize the device.

Vex2-getting-started-connect.JPG

Connect a 7.2V Robot battery to the Cortex and move the POWER switch to the ON position. Optionally, you can connect two motors to MOTOR Ports 2 and 3 for testing a sample program later in the sequence. You can connect 3-wire motors directly, or the newer 2-wire motors using Motor Controller 29 cables.

Vex2-getting-started-battery motors.JPG
Note: Technically, the battery is not necessary for downloading Master CPU Firmware and ROBOTC Firmware, but it has helped in cases where the USB ports on the computer provide too little power to facilitate a reliable connection to the Cortex.


Step 2: Platform Type and Communication Port

Specify that you are using the Cortex and how it is connected to your computer in ROBOTC. Go to Robot → Platform Type → Innovation First (IFI) and select "VEX 2.0 Cortex" or "Natural Language (VEX Cortex)".

Vex2-getting-started-platform-selection.png
Note: You should choose "VEX 2.0 Cortex" if you plan on programming using the standard ROBOTC language. Choose "Natural Language (VEX Cortex)" if you want to take advantage of the Natural Language commands in ROBOTC.

Then go to View and choose Select Communication Port.

Comm port.png

The Select Communications Port for Platforms window will appear. From the Communications Port drop down list, you should see "Automatic Selection" and one of two additional options:

If your VEX Cortex is in "bootload mode" or running an older (2.x) version of the Master CPU Firmware, it will appear as a "USB Wired Cable" option in the list.
Comm port select.png

If your VEX Cortex is running a newer (3.x) version of the Master CPU Firmware, it will appear as a "Vex Robotics Comm Port" in the list.

Vex2-getting-started-auto-select.png
Make sure that "Automatic Selection" or one of the two legitimate options is selected. If you ever plan on programming your robot wirelessly over VEXnet, choosing "Automatic Selection" is recommended. Press OK to save your choice.


Important: If the "USB Wired Cable" or "Vex Robotics Comm Port" options do not appear in the drop down menu when a VEX Cortex is connected, this may indicate that Windows has not recognized the device or access to it is blocked. Ensure that the VEX Cortex Device Driver was successfully installed with Administrative Privileges, disconnect and reconnect your Cortex from the computer, and press "Refresh List" to force ROBOTC to repopulate the list.


Step 3: Updating VEX Cortex Firmware

Go to Robot → Download Firmware and select "Automatically Update VEX Cortex".

Vex2-getting-started-auto-update.png

A message will appear, informing you that the software will update your Cortex to the latest Master CPU and ROBOTC Firmware files. Press OK to begin the process.

Vex2-getting-started-robotc-message.png

A Download Progress window will appear, showing the progress of the Master CPU Firmware download.

Vex2-getting-started-download-progress.png

When the Master CPU Firmware download is complete, a ROBOTC Message will appear and inform you that it will now update the ROBOTC firmware, if needed. Press OK to continue the process.

Vex2-getting-started-ROBOTC Message-2012-01-06 12 59 37.png

Note: If this is the first time a VEX Cortex running the 3.x Master CPU Firmware has been connected to your computer, Windows will recognize it as a new device, and may prompt you to verify the new hardware installation. Press Continue or Continue Anyway to complete the installation.

New hw.png

If your ROBOTC Firmware is out-of-date, another Download Progress window will appear and begin the ROBOTC Firmware download.

Vex2-getting-started-Download Progress-2012-01-06 13 00 34.png

When the download completes, another ROBOTC Message will appear. Press OK to complete the process.

Vex2-getting-started-ROBOTC Message-2012-01-06 13 00 00.png

Step 4: Updating VEXNet Joystick Controller Firmware

Disconnect the USB cable from the Cortex and plug it into the USB port on the back of the VEXNet Joystick Controller.
Go to Robot → Download Firmware and select "Automatically Update VEXNet Joystick".


The Master CPU Firmware file will then be downloaded to the Joystick Controller (there is no ROBOTC firmware residing on the Joystick Controllers). Once the process is complete, you may disconnect the Joystick Controller from the computer.

Step 5: Pairing the VEXNet Joystick Controller and Cortex

The Cortex and VEXNet Controller must be paired together before the VEXNet system will work properly. In order to pair the Cortex and VEXNet Joystick Controller, you must:

  • Unplug the Cortex from the computer and turn the Cortex off
  • Connect the Cortex to the Joystick Controller via the USB A-to-A cable (NOT the Programming Hardware kit)
  • Once the two devices are physically connected, turn on the Cortex and wait for the VEXNet light on the Cortex and Joystick Controller to turn green
This will connect the two devices and pair them properly so they will only communicate with one another. To pair the Cortex or Joystick Controller with another device, simply repeat the pairing process with the other device instead.

Step 6: Updating VEXNet Key's firmware (2.0 and later only)

VEXNet 2.0 Keys have a separate firmware that resides inside of the individual keys, and may need to be upgraded before use. VEXnet 1.0 Key users can skip to Step 7.

First, download and run the 'VEXNet Key 2.0 Firmware Upgrade Utility' from VEX's download page.
Open the VEXNet 2.0 Firmware Upgrade Utility and plug the VEXNet 2.0 key you wish to upgrade into your computer's USB port. Click the 'Start Update' button within the Utility to start the firmware upgrade process.
Repeat the process with any remaining VEXNet 2.0 keys that require upgrading.

Step 7: Setting Cortex Communication Mode

Open up a program you would like to load onto the Cortex. For the purposes of this tutorial, we selected the 'Dual Joystick Control' program from the 'Remote Control' Sample Programs folder.

Cortex VEXNet Sample Prog.png

With the Cortex turned on and plugged in, navigate to 'VEX Cortex Communication Mode' under the 'Robot' menu. Select 'VEXNet or USB' as the communication type.

Cortex Communication Type.png

Compile and download the program to the Cortex. ROBOTC will pop up a message telling you that the communication mode has been changed and that a power cycle is required in order for the changes to take affect.

Cortex Communication Powercycle.png

Once the program has downloaded to the Cortex, turn the Cortex off and back on. This 'power cycle' commits the communication type to the Cortex. Remember, you must repeat this process to revert back to USB only (making sure that USB only is selected as the mode). The Cortex should now be set up for wireless communication over VEXNet.

Note:

Once these steps are complete, you should no longer need Administrative privileges on your computer; you should be able to download Master CPU Firmware, ROBOTC firmware, and ROBOTC programs in a permissions-restricted account. Only future updates to ROBOTC and the VEX Cortex Device Driver will require Administrative privileges. Exception: On some computers, Windows may prompt you to "install new hardware" each time the Cortex is plugged in on a different USB port. To alleviate the issue, connect the updated VEX Cortex on each USB port as an administrator (no need to redownload firmware), or dedicate one USB port for communication with the VEX Cortex.

You only need to download the Firmware 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 firmware every time you want to download code. If the download fails, disconnect the VEX Cortex from your computer and turn it off. Then reconnect it to the computer, allow a few seconds to ensure that Windows recognizes it, turn it on, and try downloading the firmware again.