Go to Post You want to make sure you got a Mike Walker and Billfred at your event so the field runs very smoothly throughout the day. - Arefin Bari [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 18-02-2008, 23:03
Guarana Guarana is offline
Registered User
FRC #1706
 
Join Date: Jan 2008
Location: Wentzville, Missouri
Posts: 16
Guarana is an unknown quantity at this point
gyro problem

I have the gyro on the analog input 01. i am using kevin's code with the gyro and adc enabled. i am getting a reading in the printf for both the rate and the angle. coding it is the trouble.

i am using mecanum programming i found from alan. it works very well on its own.

Code:
/*******************
function:	deadband()
inputs:	inp, input value
		center, value of input that represents neutral
		band, size of deadband to consider neutral
output:	scaled and deadband-compensated output value
		inputs below center will yield negative output
		inputs above center will yield positive output
		inputs within deadband either side of center will yield 0
usage:	typically call with joystick value (0-254) as input,
		joystick neutral (127) as center, and a small number (5)
		as the size of the deadband.  The white POS joysticks
		should probably have a much larger band (10) instead.
*******************/
int deadband(int inp, int center, int band)
{
int oup;
	if (inp < center-band)
		oup = inp - center + band;
	if (center-band <= inp && inp <= center+band)
		oup = 0;
	if (center+band < inp)
		oup = inp - center - band;
	return oup;
}

/*********************
function:	pwm_limit()
inputs:	inp, input value
output:	scaled and range-limited output value
usage:	call with signed value (+/- 127) as input,
		will return a valid pwm value
*********************/
unsigned char pwm_limit (signed int inp)
{
	if(inp<-127)
		inp = -127;
	if (inp>127)
		inp = 127;
	inp = inp+127;

	return (char)inp;
}



void Teleop(void)
{

	l_y = deadband(p1_y,127,10);
	r_y = deadband(p2_y,127,10);
	l_x = deadband(p1_x,127,10);
	r_x = deadband(p2_x,127,10);

	l_y = l_y/2;
	r_y = r_y/2;
	l_x = l_x/2;
	r_x = r_x/2;

	speed = l_y+r_y;
	turn = l_y-r_y;
	slide = -l_x-r_x; 

/*

	if(temp_gyro_angle <= -75) //gyro
	{
		turn = turn+15;
	}
	if(temp_gyro_angle >= 75)
	{
		turn = turn-15;
	}

*/
  	front_r = speed-turn+slide;
	front_l = speed+turn-slide;
	back_r = speed-turn-slide;
	back_l = speed+turn+slide;


	pwm01 = pwm_limit(front_r);
	pwm02 = 255 - pwm_limit(front_l);
	pwm03 = pwm_limit(back_r);
	pwm04 = 255 - pwm_limit(back_l);

}
The commented out part is mine. It is simple and looks like it should work, but whenever the gyro is plugged in, the victors 'flicker'. the orange lights flash very quick, and the wheels get a quick power burst to it, over and over. when the gyro is unplugged, its fine.

suggestions?
 


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
Problem with gyro... capenga Programming 21 16-02-2006 19:25
Gyro not accurate - Problem naor52 Programming 15 27-01-2006 16:50
Gyro code problem AMIRAM Programming 10 23-01-2006 04:26
Gyro magical hands Programming 2 14-01-2005 20:57


All times are GMT -5. The time now is 17:35.

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