Go to Post As Frank said, when an FRC team hurts, we all hurt. - Hallry [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 18-02-2006, 07:57
CaseyKasem_1251's Avatar
CaseyKasem_1251 CaseyKasem_1251 is offline
Registered User
AKA: John Casey
FRC #1251 (TechTigers)
Team Role: Student
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Florida
Posts: 21
CaseyKasem_1251 is on a distinguished road
Send a message via AIM to CaseyKasem_1251
Need help with code

ok so i have some autonomous code right now and This code gets the Tilt_servo variable from tracking.c, then goes into a
loop, and waits for a while, then gets the value again and tests it
against the previous value to guaranty that it has not changed. If the
value has not been updated, we assume that the target has been found
and we can then pass the value as the final value. right now this code looks like this
Quote:
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;

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

/* Add your own autonomous code here. */

angle = TILT_Servo;
try_again = false
while (try_again == false)
{
first_angle == TILT_Servo;
for (y = 1; y<=1000; y++)
//do nothing-wait
second_angle = TILT_Servo
if (first_angle == second_angle)
{
(TILT_Servo)
}
else
try_again = true;

}

Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}
i keep getting errors at while (try_again == false) and (first_angle == second_angle) any help or constructive criticsm would be most helpful

Thanks
__________________
2008 UCF Regional Champs thanks to 233 and 86
2008 UCF Regional GM Industrial Design Award
2007 Palmetto Regional finalists thanks to 1626 and 1758
2007 Palmetto Regional Motorola Quality Award
2007 UCF Regional Champs thanks to 1270 and 86
2007 UCF Regional GM Industrial Design Award
2006 Palmetto Regional Champs thanks to 11 and 247
2006 UCF Regional Semifinalist thanks to 86 and 710
2005 Palmetto Regional finalist thanks to 25 and 301
2005 Palmetto Regional Xerox Creativity Award
2005 UCF Regional finalists thanks to 845 and 1270
2005 UCF Regional Judges Award
2004 UCF Regional Rookie All-star Award


Last edited by CaseyKasem_1251 : 18-02-2006 at 08:08.
  #2   Spotlight this post!  
Unread 18-02-2006, 09:08
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Need help with code

Is this really the code? If so, the errors are because you are missing a bunch of semicolons (like after "try_again = false"). You should also clean up the curly braces with the else statements
  #3   Spotlight this post!  
Unread 18-02-2006, 09:38
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Need help with code

This scheme will also not work with the IFI Robot Controller design because you cannot pause execution with a "while" statement or a timing loop for any appreciable amount of time.
Doing so prevents you from servicing the regular radio packets with Getdata/Putdata, and when the Master control doesn't hear from you it automatically shuts your code down -- Red "Code Error" light.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #4   Spotlight this post!  
Unread 18-02-2006, 09:39
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Need help with code

Code:
   angle = TILT_Servo;
	try_again = false;
		while (try_again == false)
		{
	first_angle = TILT_Servo;
	for (y = 1; y<=1000; y++)
	{
		  //do nothing-wait
	}
	second_angle = TILT_Servo;
	if (first_angle == second_angle)
	{
		   (TILT_Servo)
	}
	else
	{
			try_again = true;
	}


Couple of Things:
1. There is no Boolean Variables right out of the box for MPLAB. You can get them by assigning your variables as int and then have:
#define TRUE 1
#define FALSE 0
at the top of your code
2. Try and use indentation. It will make debugging your code a lot easier
3. I have noticed a lot that MPLAB doesn't like when you don't use {} on single line For/If/While statements. That is why I put those in.
4. == is for conditional statements. IF / While statements
= is for assignment statements. There were couple of places where those were messed up

If you have any more question feel free to contact me on one of my Instant Messaging ways
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
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
Encoder Code Kevin Watson Programming 47 18-02-2008 12:56
Problem with idata_user_routines.o? Adrien Programming 3 12-02-2006 01:33
Trying to import Camera code into program without. Kingofl337 Programming 1 18-02-2005 00:43
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 01:33.

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