View Single Post
  #13   Spotlight this post!  
Unread 11-01-2007, 11:21
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Re: What are we supposed to do!?!?!?!??!?!

Quote:
Originally Posted by Bomberofdoom View Post
But we don't know what to do in EasyC. We're used to raw C code. These blocks are confusing(safe, but confusing).
I am not surprised that you are confused.

The Default code is a real mess in my opinion. It is a mix-mash of a bunch of legacy stuff from the early years of FIRST and a bunch of patches and band -aids applied to add new features and functions.

Here is the basic idea:
Inputs from the Operator Interface (OI) come from 4 ports -- they themselves are legacy 15 pin game ports from the early days of the IBM PC. Each port has switches and analog inputs.

The switches are defined this way: pN_sw_SWITCHNAME where N refers to the port number and SWITCHNAME refers to "top", "trig", "aux1" and "aux2" Depending on what brand joystick you use these switches will be available out of the box or not -- if not, and you need those switches, you will have to build a custom harness to get access to the switches. The default code has structures and aliases defined for you that allow you to treat these switches as either 1 or 0's

The analog inputs are defined this way:
pN_ANALOGNAME where N refers to the port number and ANALOGNAME
Refer to "X" "Y" "WHEEL" and "AUX" Again depending on what brand joystick you use these analog inputs will be available out of the box or not -- if not, and you need those inputs, you will have to build a custom harness to get access to the analog inputs (wiring in your own potentiometer for example). The default code has structures and aliases defined for you that allow you to treat these analog inputs as either a number between 0 and 255 -- with 127 being the nominal center position of the joystick.

You have similar naming conventions for inputs on the Robot Controller's analog and digital inputs.

The outputs on the RC are basically the PWM values 0-254 and relays (which are of the form rc_dig_outNN).

In order to control a motor, you just assign the PWM output to a value 0 = full rev, 127 = off, 254= full fwd. The default code simply maps joystick values from the OI to PWM outputs on the RC. It also has some example methods of mapping limit switches to particular PWM output so that the motor will turn off when an end of travel switch is made. If you know C and you know how to access the various inputs and outputs, you should be able to write code to let your robot do what ever you need it to do.

Good luck.

Joe J.
__________________
Joseph M. Johnson, Ph.D., P.E.
Mentor
Team #88, TJ2