View Single Post
  #5   Spotlight this post!  
Unread 12-01-2008, 23:44
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Also, the "default code" that comes from IFI contains a few lines of code that copy values from the joystick ports (connected to the Operator Interface) to the PWM outputs. PWM outputs are wired to Victor speed controllers, and these to the motors.

In user_routines.c is the "Default_Routine()" function where most people do their programming. The following lines copy joystick values to the PWM outputs. 127 is the 'neutral' or 'stop' value for the Victor speed controllers ... sending the PWM a 0 value would operate the attached motor at full speed, sending 254 would operated at full speed in the opposite direction.

Code:
  p1_x = 255 - p1_y;
  p1_y = 255 - pwm05;

  pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
In ifi_aliases.h you find the definitions for the p1_x, p1_y, etc, etc defined-constants:

Code:
#define p1_y        rxdata.oi_analog01
#define p2_y        rxdata.oi_analog02
#define p3_y        rxdata.oi_analog03
#define p4_y        rxdata.oi_analog04
#define p1_x        rxdata.oi_analog05
#define p2_x        rxdata.oi_analog06
#define p3_x        rxdata.oi_analog07
#define p4_x        rxdata.oi_analog08
#define p1_wheel    rxdata.oi_analog09
#define p2_wheel    rxdata.oi_analog10
#define p3_wheel    rxdata.oi_analog11
#define p4_wheel    rxdata.oi_analog12
#define p1_aux      rxdata.oi_analog13
#define p2_aux      rxdata.oi_analog14
#define p3_aux      rxdata.oi_analog15
#define p4_aux      rxdata.oi_analog16