Programming Tips

From Team1370

(Difference between revisions)
(Initial, incomplete, version set up)
(revert to 03:18, 14 February 2006 by 72.45.26.29)
 
(21 intermediate revisions not shown)
Line 1: Line 1:
-
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 desribe below, but do consider that there are other options and other tutorials available on the web. Of course, I suggest the following. -[[User:Admin|Pierce Lopez]]
+
== Aliases to keep in mind ==
 +
*pwm## where the number ranges from 01 to 12 (and up to 16 if the "Generate_Pwms(pwm13,pwm14,pwm15,pwm16);" is included in the "void Process_Data_From_Master_uP(void)" function of the user_routines.c file)
-
== Collecting Your Tools ==
+
The pwm## alias is used to assign an output value to the speed controllers according to the pwm slots that they are each plugged into. ''Values range from 0 to 255''
-
The system I use requires the use of a few different tools which work together (more or less). Here's what you'll need:
+
-
*'''A Laptop running Windows''' A laptop will make connecting to the robot immeasurably easier and more convenient, and most tools I use are only available for windows, and have no counterparts for other OSs (unfortunately).
 
-
*'''MPLAB IDE v7.20''' Newer versions don't work, according to the source code documentation. Download this version [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023073 here].
 
-
*'''MPLAB C18 Compiler Student Edition v2.40''' Newer versions of this will apparently not work either, and this older version is pretty difficult to find online. I found a download link for it [http://www.acfr.usyd.edu.au/teaching/3rd-year/mtrx3700-Mx3/reference/tools/C18/c18_240_SE.zip here]. If that link doesn't still work, search for it.
 
-
*'''IFI_Loader v1.0.12''' Can be found at the bottom of [http://www.ifirobotics.com/rc.shtml this] page. But don't get the robot default code from there, if you intend to use the camera with your robot, as we will in this guide.
 
-
*'''The Default Robot+Camera Code'''
 
-
*'''puTTY'''
 
-
*'''COM/Telnet Bridge'''
 
-
== Getting it all set up ==
+
*p#_? where the number ranges from 1 to 4 and the ? sign is either "x", "y", or "wheel"
-
''In Progress...''
+
 
 +
This alias represents the value of one of a specific joystick's axis positions. It may be from one of the four possible joysticks, of which it may be either the x-axis, y-axis, or throttle wheel (if one exists).  ''Values range from 0 to 255''
 +
 
 +
 
 +
*p#_sw_? where the number ranges from 1 to 4 and the ? sign is either "trig", "top", "aux1", or "aux2"
 +
 
 +
This alias represents the value of one of a specific joystick's buttons. It may be from one of the four possible joysticks, of which it may be either the trigger, top, or side buttons.  ''Values are either 0 (normal) or 1 (pressed)''
 +
 
 +
 
 +
*pwm01 and pwm02 are used by the camera code to control the servos. One thing to remember is that, unlike with a normal motor, the value of these correspond to positions (127 is center) such that assigning 200 would make the servos jump to that position -- instead of spinning forward at the given speed. Thus, the value can also be used in reverse, to determine the position of the camera.
 +
 
 +
 
 +
 
 +
== Compiling errors got you down? ==
 +
*Check for missing or extra semicolons and parentheses. They can be a real hassle.
 +
 
 +
*Make sure you declare variables at the top of a function (remember, this is C, not C++)
 +
 
 +
*Functions should be prototyped in a header file that is included in the .c file
 +
 
 +
 
 +
== Other things to remember ==
 +
*The Limit_Mix function can be used to limit the value of something to between 0 and 254. Just make sure that the input sent to the function is somewhere around 2000 to 2254 in most cases (in other words, add 2000 to your equations before encasing them in a Limit_Mix).
 +
 
 +
 
 +
== Team 1370 Robot Code ==
 +
Here is a link to the current version of our [[Robot Code 2006]], which is a good example of various programming techniques we use.

Current revision as of 03:55, 2 October 2007

Contents

[edit] Aliases to keep in mind

  • pwm## where the number ranges from 01 to 12 (and up to 16 if the "Generate_Pwms(pwm13,pwm14,pwm15,pwm16);" is included in the "void Process_Data_From_Master_uP(void)" function of the user_routines.c file)

The pwm## alias is used to assign an output value to the speed controllers according to the pwm slots that they are each plugged into. Values range from 0 to 255


  • p#_? where the number ranges from 1 to 4 and the ? sign is either "x", "y", or "wheel"

This alias represents the value of one of a specific joystick's axis positions. It may be from one of the four possible joysticks, of which it may be either the x-axis, y-axis, or throttle wheel (if one exists). Values range from 0 to 255


  • p#_sw_? where the number ranges from 1 to 4 and the ? sign is either "trig", "top", "aux1", or "aux2"

This alias represents the value of one of a specific joystick's buttons. It may be from one of the four possible joysticks, of which it may be either the trigger, top, or side buttons. Values are either 0 (normal) or 1 (pressed)


  • pwm01 and pwm02 are used by the camera code to control the servos. One thing to remember is that, unlike with a normal motor, the value of these correspond to positions (127 is center) such that assigning 200 would make the servos jump to that position -- instead of spinning forward at the given speed. Thus, the value can also be used in reverse, to determine the position of the camera.


[edit] Compiling errors got you down?

  • Check for missing or extra semicolons and parentheses. They can be a real hassle.
  • Make sure you declare variables at the top of a function (remember, this is C, not C++)
  • Functions should be prototyped in a header file that is included in the .c file


[edit] Other things to remember

  • The Limit_Mix function can be used to limit the value of something to between 0 and 254. Just make sure that the input sent to the function is somewhere around 2000 to 2254 in most cases (in other words, add 2000 to your equations before encasing them in a Limit_Mix).


[edit] Team 1370 Robot Code

Here is a link to the current version of our Robot Code 2006, which is a good example of various programming techniques we use.

Personal tools