View Single Post
  #1   Spotlight this post!  
Unread 09-02-2006, 17:29
caderader's Avatar
caderader caderader is offline
caderader
#1284 (DART)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: gville
Posts: 19
caderader is an unknown quantity at this point
GTS code Problems

I've been working on and revising the geartooth sensor autonoumous code for a few days now but no matter how I change it the code won't work. If anyone just has a quick example of working gear tooth sensor code it would be very helpful.The code that i'm using right now with Kevin's FRC code is right here...

Code:
void User_Autonomous_Code(void)
{
  /* Initialize all PWMs and Relays when entering Autonomous mode, or else it
     will be stuck with the last values mapped from the joysticks.  Remember, 
     even when Disabled it is reading inputs from the Operator Interface. 
  */
  pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
  pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
  relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
  relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
  relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
  relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;
i=0;
Cnt_L=0;
Cnt_R=0;
Total_Count=0.0;
Total_Count_R=0.0;
Total_Count_L=0.0;
  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */

      pwm01=pwm02=170;
pwm02=255-pwm02 ;
pwm01=170;
pwm02=170;
	Cnt_L=Get_Encoder_1_Count();
		Cnt_R=Get_Encoder_2_Count();
	
	
if(i<5)
		{
			Total_Count=(Cnt_L+Cnt_R)/2;
			
			if (Total_Count>50)
    		{   
	   			i++;
	   			Total_Count_L+=Cnt_L;
       			Total_Count_R+=Cnt_R;
       			Reset_Encoder_1_Count();
       			Reset_Encoder_2_Count();
       			Cnt_L=0;
       			Cnt_R=0;
			}
		}
		if (i=5)
		{
			i++;
			Total_Count_L+=Get_Encoder_1_Count();
			Total_Count_R+=Get_Encoder_2_Count();
       		Reset_Encoder_1_Count();
       		Reset_Encoder_2_Count();
			pwm01=100;
			pwm02=160;
		}
		if (i>=6)
		{
			i++;
			Total_Count_L+=Get_Encoder_1_Count();
			Total_Count_R+=Get_Encoder_2_Count();
       		Reset_Encoder_1_Count();
       		Reset_Encoder_2_Count();
			pwm01=127;
			pwm02=127;

 /* Add your own autonomous code here. */

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}
}
I've definedTotal_Count, Total_Count_R, andTotal_Count_L as Float's.
Cnt_L, and Cnt_R as Long's.
and i as an int.

Thank You in advance