Go to Post Ineveitably what we do just might end up in the hands of millions of people. - JoeXIII'007 [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 09-02-2006, 19:10
scottmso scottmso is offline
Registered User
FRC #1561 (RoboDucks)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Oklahoma City, OK
Posts: 26
scottmso is an unknown quantity at this point
Send a message via AIM to scottmso
Modified default code gives "code violation"

I've been modifying the default code to try to get a basic "joystick sensitivity reducer" working. I'm not planning on using this in our final robot as it significantly reduces the amount of power we can use. What it's supposed to do is subtract 127 from the joystick value and divide the result by two. Here's the code:
Code:
/* Variable declarations (at top of program) below */
unsigned char joystick_input = 127;
char joystick_input_2 = 0;
char drive_output = 0;
unsigned char drive_output_2 = 127;

/*******************************************************************************
* FUNCTION NAME: Slow_Drive
* PURPOSE:       "Halves" the input from the controllers.
* CALLED FROM:   Default_Routine
* ARGUMENTS:     unsigned char joystick_input - input joystick value 
* RETURNS:       unsigned char drive_output_2
*******************************************************************************/

unsigned char Slow_Drive(unsigned char joystick_input)
{
	joystick_input_2 = joystick_input - 127;
	drive_output = joystick_input_2 / 2;
	drive_output_2 = drive_output + 127;
	
	return drive_output_2;
}

void Default_Routine(void)
{
  
pwm01 = Slow_Drive(p1_y);
printf("Slow_Drive for pwm01 = %d",joystick_input); /* printfs are for debugging purposes */
pwm02 = Slow_Drive(p2_y);
printf("Slow_Drive for pwm02 = %d",joystick_input);

/* pwm01 and pwm02 below removed, rest of code left intact */
}
Whenever I put the code on the robot I get a "code violation" (flashing red program LED) or the robot controller will go back into program mode. Right now I'm thinking the problem might be with variable types, but where? Or does anyone see any particular problems? I know I may not have commented enough so feel free to ask any questions. Any advice appreciated - thanks!
 


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
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
default camera code edit Windward Programming 8 25-01-2006 18:33
Best Way To Insert Autonomous Code Into Default then load help.? :-)? gemccnp Programming 2 05-02-2005 18:58
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 02:38.

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