|
|
Line 8: |
Line 8: |
| I think this is a real great blog article.Thanks Again. Really Great. | | I think this is a real great blog article.Thanks Again. Really Great. |
| | | |
- | == Setting-Up the Robot and Connecting ==
| + | YWoUbT I am so grateful for your blog article.Much thanks again. Really Cool. |
- | === The Robot ===
| + | |
- | Before we can interact with the camera or begin to test code on the robot, we need to get the robot's electronics wired to a very basic minimum. The Robot Controller needs a charged backup battery and should have a charged main battery hooked up to it (see the appropriate FIRST documentation for help with that stuff). The Operator Interface needs to be getting power from the power adapter that came with it, and needs to be connected to the Robot Controller, either with a tether or with the radio set-up.
| + | |
- | | + | |
- | === The Camera ===
| + | |
- | The camera needs to be built into its pan-and-tilt mechanism. All the parts needed are included in the Robot Kit, and instructions can be found in the first part of ''CMUcam2_Workbook.pdf''. Also in the workbook are instructions for how to wire the camera to the Robot Controller. In fact, much of what I'm about to describe is also in that workbook, so you can always go back to it as a reference. However, to prevent confusion between the instructions for various different tasks found in the workbook, I'll specify here what exactly needs to be connected. Just open the workbook to the diagram (p. 17) so you can identify the pins and ports I specify.
| + | |
- | | + | |
- | '''Make sure you match up the black wire of the pwm cables with a ''B'' where they plug in.'''
| + | |
- | | + | |
- | *Make sure that there is a jumper on ''External Power To Servos'', and not on ''Internal Power To Servos'' (look in the diagram to the left of the power switch at the top)
| + | |
- | *Connect ''Power Input'' (also to the left of the power switch) to a free pwm out on the robot, for example pwm03, with a pwm cable
| + | |
- | *Connect ''RS232 PORT (3-PIN)'' (next to the massive serial connection) to the 3 pin connection of the little extra chip which came with the camera (the TTL-232 Adapter, a picture of it is below the picture of the camera on page 13) with a pwm cable.
| + | |
- | *Plug the 4-pin plug attached to the TTL-232 Adapter directly into the 4 pin plug on the Robot Controller which is labeled ''TTL Serial Port'' and is right next to the reset button. Match up the '''B'''s.
| + | |
- | *Attach the pwm cable coming out of the pan servo on the camera assembly to pwm01 on the robot controller (you will probably have to use a pwm cable as an exention cord)
| + | |
- | *Attach the pwm cable coming out of the tilt servo on the camera assembly to pwm02 on the robot controller (again, use an extra pwm cable if you need to)
| + | |
- | *Go ahead and switch on the camera and carefully take the lens cap off
| + | |
- | | + | |
- | === Connecting to a Computer ===
| + | |
- | | + | |
- | Have the main battery and the backup battery connected. Then, hold the '''PROG''' button (at the bottom of the Robot Controller, next to the '''RESET''' button) until the ''Program State'' LED turns orange. Have your computer connected to the robot via a serial cable, from a serial port on your computer to the '''Program''' serial port on the right side of the Robot Controller. Start ''IFI Loader'' on your computer, click ''Port Settings'' in the upper left of the ''IFI Loader'' window, and make sure the correct serial port on you computer has a check mark next to it, COM1 (selected by default) is correct if you only have one serial port. Next click the ''Browse'' button in the middle-right of the ''IFI Loader'' program, and browse to the folder which contains your robot code, if you followed the directions above to the letter, browse to the folder ''C:\\frc_camera''. You should see only one file available for selection there, '''camera.hex''', which is the file that was generated when we compiled the code earlier. Click on it and open it. Then click the ''Download'' button on the ''IFI Loader'' program, and (hopefully) watch the progress bar that appears at the bottom fill up as the code is loaded into the Robot Controller. When IFI Loader is done loading the code, a white window which I will refer to as a ''serial terminal'' will open.
| + | |
- | | + | |
- | ==== Troubleshooting ====
| + | |
- | If loading the code doesn't work and you get an error message from IFI Loader, make sure that a path to a ''.hex'' file is in the text box labeled "Current Hex File", that the correct serial port is selected (as described above), that a good quality serial cable (prefferable just one to start) is well connected to both the Program port of the Robot Controller and your computer, and that the Program LED on the Robot Controller is orange, indicating that it is in program mode. You might also want to make sure the settings of your serial port are all right; to do this, right click on ''My Computer'' on the Desktop or the Start menu and click ''Properties'', click the ''Hardware'' tab, click the ''Device Manager'' button, expand the ''Ports (COM and LPT)'' section (which may be different on Windows versions which are not XP), and double click the COM port you use. Click the ''Port Settings'' tab, and make sure that ''Bits per second'' is set to ''115200'', ''Data bits'' is set to ''8'', ''Parity'' is set to ''none'', ''Stop bits'' is set to ''1'', and ''Flow control'' is set to ''none''.
| + | |
- | | + | |
- | === Running the Robot Code ===
| + | |
- | As soon as the ''Robot Controller'' becomes connected to the ''Operator Interface'', it will begin to run the code which is loaded onto it (unless it doesn't have power or is in Program Mode etc). The Operator Interface can be connected to it either with a serial cable which connects the ''Tether'' ports on the Robot Controller and the Operator Interface, or with the radio link, in which case the Operator Interface needs its power brick connected to it.
| + | |
- | | + | |
- | When the Robot Code is running, the camera should start panning to the side in steps, and then panning up a step after a full sweep. When a green light which it is properly calibrated for comes into its view, it should stop panning around and follow that green light. This is all already set up in the robot code.
| + | |
- | | + | |
- | === Communication Using the Serial Terminal ===
| + | |
- | The white box which appeared on the computer screen when IFI Loader finished loading the code is a ''Serial Terminal'', it can transfer text to and from the robot. Wherever ''printf()'' statements appear in the robot code, they will send a text string (like a sentence) to this serial terminal. You also use this serial terminal to send commands to the robot controller, which adjust the camera's settings.
| + | |
- | | + | |
- | When the camera is panning around looking for the green light, "Searching..." should repeatedly be printed to the serial terminal, while it is properly connected. When the light source is found, the robot should no longer send "Searching..." to the serial terminal. While the camera is searching or locked on, you can enter the ''Tracking Menu'' by typing ''t'' in the small box at the bottom of the serial window and hitting the ''Enter'' button on your keyboard or clicking the ''Send'' button. A list of possible further commands should come up in the serial terminal, and next to each one is the letter in parenthensis you need to send to give that command or modify that setting. The setting presented here are self-explanatory. The camera will not track while you are in a menu. Another menu you can access is the color calibration menu. Send the robot a ''c'' while it is not in another menu (you may have to exit out of the ''tracking'' menu first). How to find the correct settings to input to the calibration menu is detailed in the ''CMUcam2_workbook.pdf'', and involves use of other software included with the robot kit.
| + | |
- | | + | |
- | === Getting a Serial Terminal Without IFI Loader ===
| + | |
- | | + | |
- | You can only get IFI Loader's Serial Terminal to appear after you have loaded code onto the robot using it. However, there is another way to get a serial terminal to the robot running, which is usefull if you don't want to spend the time to load the code, or you don't have the latest version of the code on your computer. First, get the robot fully running and connected to the computer's serial port via its program port. Then, double-click the ''shortcut to example.bat'' (which you can rename) on your desktop. A black window with some text should come up, leave it up. Next, double-click the ''shortcut to putty.exe'' icon on your desktop. In the ''Session'' subsection of the configuration which appears (should be already shown, and is the first on the list on the left), select ''Telnet'', input ''localhost'' for ''Hostname:'', and ''23'' for ''Port''. Then click the ''Open'' button at the bottom. If the (black in this case) terminal doesn't fully work like the other one does, you may have to adjust the settings in the ''Connection > Telnet'' subsection in the left column of the configuration dialog.
| + | |
| | | |
| == Introduction to Programming == | | == Introduction to Programming == |
There are easier ways to program your robot controller, including Easy C (new for 2006), however, I am far more familiar with the classic, more complicated method using MPLAB IDE. This perhaps more complicated system is the one which I describe below, but do consider that there are other options and other tutorials available on the web. As this will be outdated soon, it may be useful in the future as an overview of all the tools involved and what they generally do. This tutorial can also be used as a reference on a short topic you may not be fully familiar with, in particular I suggest checking out the section Getting a Serial Terminal Without IFI Loader even if you are an experienced programmer.
-Pierce Lopez
1izajK Appreciate you sharing, great blog article.Really thank you! Much obliged.
I think this is a real great blog article.Thanks Again. Really Great.
YWoUbT I am so grateful for your blog article.Much thanks again. Really Cool.
I've actually become lazy at this point, and won't go into the detail I once intended on the matter. However, a couple of quick pointers to help you out: You only need to edit user_routines.c, user_routines_fast.c, and user_routines.h, to do about anything with the programming. Try to learn from example from the code. Another note: Default_Routine() is never called in the camera-capable code I ask you download, because it's commented out in the process_data_from_master_uP() (or whatever it's called) routine.