View Single Post
  #6   Spotlight this post!  
Unread 12-01-2008, 23:46
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,753
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Basically, you're missing the inputs and outputs I had the same problem last year, in that none of the documentation seems to really help much with what someone of our talent would need to know. That being said, I can help.

I would recommend starting with Kevin's code (links here, but it sounds like you already found them: http://www.chiefdelphi.com/forums/sh...ad.php?t=60377) - it's easy to use and pretty simple. For a very basic start, make all your changes to the teleop.c file - that's the one that will "run" when you power up your robot for the first time in your garage. From there, you can branch out to the rest of the code.

Now, for the rest of it. Go grab your RC (the board that goes in the robot), the OI (the board that goes with the operator), a joystick, and open up ifi_frc.h from Kevin's code. In that header file is pretty much all of the inputs and outputs you'll need, and everything is mapped to easy to remember names.

So, scrolling down the list, you'll find a bunch of p1_, p2_, p3_ and p4_ variables. All of these map, conveniently enough, to the 4 joystick ports on the OI. the analog ones (x, y, wheel, and aux) all have input values of 0-255 - using x as an example, 0 would be when you have the joystick all the way to the left, 127 is in the middle, and 255 is all the way to the right. Next, you see the digital inputs (trig, top, aux1, aux2) - these are your buttons, and are 0 normally, 1 if the button is depressed.

So, now you should have all of your inputs!

On the RC, you'll see a bunch of pins around the outside - PWM, digital, analog, and the relays are the main ones to worry about. Moving further down the ifi_frc.h file, you'll first see the digital mappings. the digital_io_ variables are used to tell if it's an input or output pin - just set them to INPUT or OUTPUT. from there, you can use rc_dig_in and rc_dig_out to get or set values (0 or 1).

Next in the file are the pwm ports, conveniently with variables starting with pwm. These are analog ports, and are used to control things like your drive motors. Set them to any value 0-255. For a drive motor, a value of 0 would be full speed reverse, 255 full speed forward, and 127 stop (depending on the load on the motors, you won't get any change for a range of values around 127).

Next are the relay ports (relayX_fwd and relayX_rev). These ones are typically used to power something like pneumatics. In a typical setup, you would want one of them set to 1, the other to 0, but that is really setup and use case dependent.

Next are the analog inputs, rc_ana_in. Being analog, these naturally have values rangings from 0-255, just like all the other ones discussed previously.


That pretty much covers the basics. If you want to test it, a real simple setup could just be a joystick into port 1, the tether cable between the two boards, and hook up a drive motor to pwm01 (through a victor!), and use the following code in the teleop.c file, in the Teleop(void) function:
Code:
pwm01 = p1_x;
Compile your code and upload the hex file using the ifiLoader. then power up and move the joystick - you'll like the results!