Go to Post The minute humans begin depending on robots for anything in their daily routine is .... well, let's just hope people "in it for the lulz" don't take notice. - JesseK [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 09-02-2006, 18:11
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: GTS code Problems

Quote:
Originally Posted by caderader
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...
It would be helpful if you could describe what you want the code to do, and what you observe when compiling/linking/running it.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #3   Spotlight this post!  
Unread 09-02-2006, 18:17
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
Re: GTS code Problems

pretty much right now I'm trying to use a sample code to let the robot run for a certain number of gear counts(the exact number doesn't matter right now) and then after that time change the direction for another number of gear counts and then stop the robot. This should work as far as I can tell with the way I have the code but I can't right now when running the code the robot does NOTHING at all. This is very confusing so any help at all would be appreciated. If i can not make the gts work I'll be forced to use dead reconing...ughhh.
  #4   Spotlight this post!  
Unread 09-02-2006, 18:33
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: GTS code Problems

I think the main reason it is doing NOTHING is that you have a misplaced closing brace. As your code stands now, your putdata() call is inside the "if (i>=6)" braces. You will need to add a "}" before /* Add your own autonomous code here. */, and get rid of one at the end of the routine.

I haven't digested the whole thing yet, but that might get you started.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #5   Spotlight this post!  
Unread 09-02-2006, 21:08
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
Re: GTS code Problems

Thank you very much. I'll try that tommorow when I get time to test on the robot.
  #6   Spotlight this post!  
Unread 13-02-2006, 16:37
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
Re: GTS code Problems

Still no movement or response. Thanks though.
  #7   Spotlight this post!  
Unread 13-02-2006, 17:01
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: GTS code Problems

Quote:
Originally Posted by caderader
pwm01=pwm02=170;
pwm02=255-pwm02 ;
pwm01=170;
pwm02=170;
there seems to be a contradiction in there...
first you set pwm02 to 170, then to 85, then to 170 again... maybe clean that up?
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."
  #8   Spotlight this post!  
Unread 13-02-2006, 19:14
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: GTS code Problems

Quote:
Originally Posted by caderader
Still no movement or response. Thanks though.
OK. I took another look at the code you posted before. Here it is again, prettified, and with the change I suggested before (It's a lot easier to read code with proper indentation ):
Code:
float Total_Count, Total_Count_R, Total_Count_L;
long Cnt_L, Cnt_R;
int i;

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! */
    }
  }
}
And here's my analysis:
You set "i" to 0 on every call to User_Autonomous_Code, so "i" is guaranteed to always be less than 5. (If it were not for the fact that your putdata() call was within the (i>=6) block, you still should have seen SOME movement, since you set your PWMs outside of the if statements.) I guess you probably want something like:
Code:
void User_Autonomous_Code(void)
{
  static int i=0;
  static float Total_Count_R=0.0;
  static float Total_Count_L=0.0;

  long Cnt_L=0;
  long Cnt_R=0;
  float Total_Count=0.0;

  /* 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;

  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
etc.
This will initialize the variables at compile time only, rather than on every call. If you make these changes, and still get nothing, I would ask: Are you actually in autonomous mode, and is this routine actually being called?
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #9   Spotlight this post!  
Unread 13-02-2006, 19:23
phrontist's Avatar
phrontist phrontist is offline
Proto-Engineer
AKA: Bjorn Westergard
FRC #1418 (Vae Victus)
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Falls Church, VA
Posts: 828
phrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond reputephrontist has a reputation beyond repute
Send a message via AIM to phrontist
Re: GTS code Problems

In order to get into autonomus mode you need to jumper two pins on the OI's competition port. Which pins are specified in the manual.
__________________

University of Kentucky - Radio Free Lexington

"I would rather have a really big success or a really spectacular crash and failure then live out the warm eventual death of mediocrity" - Dean Kamen
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gyroscope Code Kevin Watson Programming 65 01-03-2008 23:46
Gyro Code Problems railerobotics Programming 8 27-01-2006 10:45
Code problems doyler Programming 14 15-02-2005 16:23
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Wierd gyro code problems...pls help Salik Syed Programming 4 14-03-2004 01:29


All times are GMT -5. The time now is 14:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi