Downloading+Code+to+the+Vex+Controller

=Downloading Code to the Vex Controller= <-- Prev - Contents - Next -->

Writing code for the Vex Controller can be done in several ways. As described on the [|Vex website], the EasyC software provides a Drag-and-Drop interface for writing programs for the microcontroller. MPLab also has a program editor for writing software in the C programming language. Regardless of how a program is written, however, you must compile the code and transfer it from the PC it was written on //to// the Vex controller. "Compiling the code" simply converts the program from human-readable text to machine-readable instructions, stored in a .hex file. The hex file is transferred to the Vex microcontroller using the [|IFI Loader software] released by Vex. While the IFI Loader software is free, a special cable is needed to connect the microcontroller to the PC. We provide an all-purpose, pre-compiled robot program (robot_program.hex) for use in the NRS, so it should not be necessary to write any code in EasyC, MPLab, or similar Vex programming software. Also, prior to downloading the robot program, it is necessary to update the microcontroller's firmware- which is also done using the IFI Loader software. Below outlines the steps for updating the firmware and downloading the robot_program.hex file to the microcontroller.

Note: Once you have downloaded the **firmware** update to your microcontroller, **you will never have to do so again.**

The following steps outline the process of updating the Vex microcontroller's firmware: > > > > > > > > > > >
 * 1) Plug the orange Vex programming cable into your PC's USB port
 * 1) Connect your microcontroller to the programming cable, and power it on.
 * 1) Open the IFI Loader software, shown below.
 * 1) Determine which COM port your USB cable is connected to. To do so, go to your Windows Control Panel (from the Windows Start Menu). Select the System icon (in "Classic View"), and then choose the Hardware tab. Press the Device Manager button. Expand the "Ports (COM & LPT)" section. One of the choices listed should be "Prolific USB-to-Serial Comm Port (COM#)". Make a note of the COM#, as this is the port it's connected to! The following shows some illustrations.
 * 1) Then, in IFI Loader, Select Port Setting from the menu bar, and select the COM port that your USB cable is connected to.
 * 1) Now, we have to tell IFI Loader to download the firmware update (called the "Master Code") to the Vex controller. Select Option from the menu bar, and choose "Download Master Code...". When it prompts you if you "really want to download master file", click Yes.
 * 1) This should bring up a file browser. The current folder will be called "Default", and should have only one folder in it- a folder labeled "Vex". Double-click the Vex folder to browse into it.
 * 1) Next, select the firmware update, which is named "VEX_MASTER_V7_4EASYC.BIN", and click Open.
 * 1) This should start the download process, shown below.
 * 1) When completed, it should switch to the Terminal tab, where you should get a message saying "Download Complete... Now Reload User Code. The firmware update is complete! We can now download the Robot_Program.hex program in similar way.

The following steps outline the process of downloading our program to the robot: > >
 * 1) Download our [[file:robot_program.hex]] file (right click, and save target as...)
 * 2) Plug the orange Vex programming cable into your PC's USB port. See Step 1 above for illustration.
 * 3) Connect your microcontroller to the programming cable, and power it on.
 * 4) Open the IFI Loader software,
 * 5) Select the COM port as before.
 * 6) In the Download tab, select the "..." button.
 * 1) This should bring up a file browser. Browse to the robot_program.hex file that you saved in step 1, and select Open. This should populate the Hex File field with the .hex file. Hit the Download button to install the program.
 * 1) If you receive no error messages the program is downloaded! Go ahead and turn off your robot for now.

The program that was just installed on your robot was written to continuously listen for commands from a wireless connection, and to execute those commands (ie, turn on motor 2). Our future robot projects will build off of this capability.

<-- Prev - Contents - Next -->