Go to Post Remember, however, that such software limitations in no way approximate the functionality of a multiple-speed, mechanical transmission. They're simply a convenient way of limiting your students' lead feet. - Madison [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 25-02-2007, 20:00
popnbrown's Avatar
popnbrown popnbrown is offline
FIRST 5125 HOTH Lead Mentor
AKA: Sravan S
FRC #5125 (Hawks on the Horizon)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Illinois
Posts: 367
popnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond reputepopnbrown has a reputation beyond repute
Trouble with Autonomous

Well the title of the thread actually isnt exactly my problem. Autonomous works however one of my functions doesn't work. We are trying to get our robot to rotate (a 0 degree turn). I'm using WPILib so we have to write totally new code.

Well anways here is the function Rotate():
Code:
 
void Rotate(char direction, int degrees, char speed)
{
	int time = (1000 * (degrees/ 300));
	char RightMotor = NEUTRAL + (speed * direction * (SPEED_TO_PWM));
	char LeftMotor = NEUTRAL + (speed * direction * (SPEED_TO_PWM));
        //the SPEED_TO_PWM = 127/10 which converts the speed to PWM value

	printf("Rotate()\r");

	SetPWM(LEFT_WHEEL, LeftMotor);
	SetPWM(LEFT_FRONT_WHEEL, LeftMotor);
	SetPWM(RIGHT_WHEEL, RightMotor);
	SetPWM(RIGHT_FRONT_WHEEL, RightMotor);
	
	printf("time: %d\r", time);
	
	Wait(time);
	
	SetPWM(LEFT_WHEEL, NEUTRAL);
	SetPWM(LEFT_FRONT_WHEEL, NEUTRAL);
	SetPWM(RIGHT_WHEEL, NEUTRAL);
	SetPWM(RIGHT_FRONT_WHEEL, NEUTRAL);
       //NEUTRAL = 127

}
now the main problem is the time. When I pass for example:
Code:
Rotate(-1, 30, 10)
the time displays as 0. I find it really odd. However I ran time as a constant:
Code:
time = 300;
and the function worked perfectly. So the real problem here is one of the variables involved in the time equation and I dont know which one or what is wrong.

Any help would be appreciated
 


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
Trouble with the GTS Bomberofdoom Programming 1 04-02-2007 10:13
Has anyone else had trouble staying within the 10 second limit in autonomous? lkdjm Programming 18 12-02-2006 18:10
Autonomous Code trouble The yellowdart Programming 16 21-01-2006 10:36
My trouble with fund raising. BaldwinNYRookie Fundraising 5 03-04-2005 13:34
Trouble with pwm outputs misterikkit Programming 16 17-01-2004 10:56


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

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