Go to Post I clicked on "agree to terms" ........ crash. I think I killed the server. ;) - rees2001 [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 05-02-2008, 15:05
2526 2526 is offline
Crimson Robotics
FRC #2526 (Crimson Robotics)
Team Role: Teacher
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Maple Grove Senior High
Posts: 10
2526 is an unknown quantity at this point
Help with Kevin Watson's 2008 code

Can someone give an example of their teleop.c code. I have read the posts and unable to get a pwm to control a motor. When I add the code to the function it will not compile. Would someone adopt us and walk us through it? We are a rookie team and learning to use MPlab 8.0 and MCC18 3.10. Also how do we verify MCC18 version?
  #2   Spotlight this post!  
Unread 05-02-2008, 15:23
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Help with Kevin Watson's 2008 code

Your question is too generic. We'll need to see your code to help. Does the project build before you insert your changes? Where are your motors hooked up? And on and on and on... ;o)

If you call the Default_Routine function from Teleop function, your robot will run the FIRST default code.

HTH
  #3   Spotlight this post!  
Unread 05-02-2008, 15:53
eaglesfan10's Avatar
eaglesfan10 eaglesfan10 is offline
Registered User
FRC #1647 (Iron Devils)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2005
Location: New Jersey
Posts: 19
eaglesfan10 is an unknown quantity at this point
Re: Help with Kevin Watson's 2008 code

Not sure what your setup is, but just open up teleop.c and go to the teleop function. If your speed controller is connected to pwm01, just put this one line of code in:
pwm01 = p1_y;

This assumes that you have a joystick connected to port 1 on the operator inferface.
  #4   Spotlight this post!  
Unread 05-02-2008, 15:55
2526 2526 is offline
Crimson Robotics
FRC #2526 (Crimson Robotics)
Team Role: Teacher
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Maple Grove Senior High
Posts: 10
2526 is an unknown quantity at this point
Re: Help with Kevin Watson's 2008 code

The project did build but as soon as I added pwm01 = p1_y; It would not build as shown below.

void Teleop(void)
{
pwm01 = p1_y;
// example code to test your gyro and encoder(s)

long Encoder_Count;

static unsigned int i = 0;
static unsigned int j = 0;
int temp_gyro_rate;
long temp_gyro_angle;
int temp_gyro_bias;

i++;
j++; // this will rollover every ~1000 seconds

// enable this block of code to test your gyro
if(j == 10)
{
printf("\r\nCalculating Gyro Bias...\r\n");
}
if(j == 38) // let the gyro stablize for a second before starting a calibration
{
// start a gyro bias calculation
Start_Gyro_Bias_Calc();
}
if(j == 191) // allow calibration routine to run for four seconds
{
// terminate the gyro bias calculation
Stop_Gyro_Bias_Calc();

// reset the gyro heading angle
Reset_Gyro_Angle();

temp_gyro_bias = Get_Gyro_Bias();
printf("Gyro Bias=%d\r\n", temp_gyro_bias);
}
if(i == 35 && j >= 191)
{
temp_gyro_rate = Get_Gyro_Rate();
temp_gyro_angle = Get_Gyro_Angle();
printf(" Gyro Rate=%d\r\n", temp_gyro_rate);
printf("Gyro Angle=%d\r\n\r\n", (int)temp_gyro_angle);
}


/*
// enable this block of code to test your encoder(s)
if(i == 37 && j >= 191)
{
Encoder_Count = Get_Encoder_1_Count();
printf("E1=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_2_Count();
printf("E2=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_3_Count();
printf("E3=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_4_Count();
printf("E4=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_5_Count();
printf("E5=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_6_Count();
printf("E6=%d\r\n\r\n",(int)Encoder_Count);
}
*/

// reset the loop counter
if(i >= 38)
{
i = 0;
}

// enable this to use IFI's default robot code
// Default_Routine(); // located in ifi_code.c

// update the state of the LEDs on the operator interface
Update_OI_LEDs(); // located in ifi_code.c
}
  #5   Spotlight this post!  
Unread 05-02-2008, 16:09
eaglesfan10's Avatar
eaglesfan10 eaglesfan10 is offline
Registered User
FRC #1647 (Iron Devils)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2005
Location: New Jersey
Posts: 19
eaglesfan10 is an unknown quantity at this point
Re: Help with Kevin Watson's 2008 code

Quote:
Originally Posted by 2526 View Post
The project did build but as soon as I added pwm01 = p1_y; It would not build as shown below.

void Teleop(void)
{
pwm01 = p1_y;
// example code to test your gyro and encoder(s)

long Encoder_Count;

static unsigned int i = 0;
static unsigned int j = 0;
int temp_gyro_rate;
long temp_gyro_angle;
int temp_gyro_bias;

i++;
j++; // this will rollover every ~1000 seconds

// enable this block of code to test your gyro
if(j == 10)
{
printf("\r\nCalculating Gyro Bias...\r\n");
}
if(j == 38) // let the gyro stablize for a second before starting a calibration
{
// start a gyro bias calculation
Start_Gyro_Bias_Calc();
}
if(j == 191) // allow calibration routine to run for four seconds
{
// terminate the gyro bias calculation
Stop_Gyro_Bias_Calc();

// reset the gyro heading angle
Reset_Gyro_Angle();

temp_gyro_bias = Get_Gyro_Bias();
printf("Gyro Bias=%d\r\n", temp_gyro_bias);
}
if(i == 35 && j >= 191)
{
temp_gyro_rate = Get_Gyro_Rate();
temp_gyro_angle = Get_Gyro_Angle();
printf(" Gyro Rate=%d\r\n", temp_gyro_rate);
printf("Gyro Angle=%d\r\n\r\n", (int)temp_gyro_angle);
}


/*
// enable this block of code to test your encoder(s)
if(i == 37 && j >= 191)
{
Encoder_Count = Get_Encoder_1_Count();
printf("E1=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_2_Count();
printf("E2=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_3_Count();
printf("E3=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_4_Count();
printf("E4=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_5_Count();
printf("E5=%d\r\n",(int)Encoder_Count);

Encoder_Count = Get_Encoder_6_Count();
printf("E6=%d\r\n\r\n",(int)Encoder_Count);
}
*/

// reset the loop counter
if(i >= 38)
{
i = 0;
}

// enable this to use IFI's default robot code
// Default_Routine(); // located in ifi_code.c

// update the state of the LEDs on the operator interface
Update_OI_LEDs(); // located in ifi_code.c
}
You need to put it AFTER your declarations. Put it after this line:
int temp_gyro_bias;
  #6   Spotlight this post!  
Unread 05-02-2008, 16:09
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,586
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Help with Kevin Watson's 2008 code

Quote:
Originally Posted by 2526 View Post
The project did build but as soon as I added pwm01 = p1_y; It would not build as shown below.

Code:
	pwm01 = p1_y;
	// example code to test your gyro and encoder(s)

	long Encoder_Count;

	static unsigned int i = 0;
	static unsigned int j = 0;
	int temp_gyro_rate;
	long temp_gyro_angle;
	int temp_gyro_bias;
In C, you have to put your code after all variable declarations. If you move pwm01 = p1_y; to the end of this block, it will compile.
  #7   Spotlight this post!  
Unread 05-02-2008, 16:53
2526 2526 is offline
Crimson Robotics
FRC #2526 (Crimson Robotics)
Team Role: Teacher
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Maple Grove Senior High
Posts: 10
2526 is an unknown quantity at this point
Re: Help with Kevin Watson's 2008 code

Thanks for the help we'll try that please check back as I'm sure we'll have more questions
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
Kevin watson's sensor code DustinB_3 Programming 3 30-01-2008 21:07
Problem compiling Kevin Watson's code Spencer E. Programming 2 07-01-2008 00:34
Trouble using Kevin Watson's Serial Code with Vex user API StargateFan Programming 3 13-01-2007 15:42
Kevin Watson's encoder code with RPM output MaxM Programming 2 05-02-2005 00:06
Kevin Watson's Kick-off Demo Code! Mr. Lim Programming 27 22-01-2005 03:38


All times are GMT -5. The time now is 19:09.

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