Go to Post You don't see teams plastering the arena with signs saying "Show your spirit!" or "Be creative in your robot design!" or "Be sure to be innovative in your control!" - Mr. Van [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
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
  #17   Spotlight this post!  
Unread 11-04-2003, 09:34
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
previous post

The previous post has a small code snippet that shows how they're summing up the gyro inputs to make the 90 degree turn:

Code:
drive_L = 254	' start right turn
drive_R = 1	

select sensor1			'select yaw rate sensor
	case 0 to 127		' turning left
		new_ct = 127-sensor1
		yaw_ct = yaw_ct - new_ct
	case 128 to 255		' turning right
		new_ct = sensor1 -127
		yaw_ct = yaw_ct + new_ct
endselect

if yaw_ct > 5262  then	‘count has reached 5262 and passed 90
	drive_L = 127  	‘stop turn
	drive_R = 127
endif

debug ?yaw_ct		'display count value in debug screen
The code in the select statement can be simplified and the case statement eliminated. When the gyro is less than 127 the value of yaw_ct = yaw_ct - new_ct. Since new_ct = 127 - sensor1, the equivalent expression is yaw_ct = yaw_ct - (127 - sensor1), reduced to yaw_ct = yaw_ct + sensor1 - 127.

When the gyro is greater than 127 the expression is yaw_ct = yaw_ct + new_ct, where new_ct = sensor1 - 127. This also simplifies to yaw_ct = yaw_ct + sensor1 - 127.

So the following code will work the same way. I added a deadband around 127 for the gyro so that it doesn't start adding up noise if the robot is sitting still. If yaw_ct was initialized to zero and some noise creeps in then yaw_ct may underflow and trigger the IF statement. If you initialize yaw_ct to something like 10000 then you can use it for both clockwise and anti-clockwise turns. 15,262 would be to the cutoff turning left and 4738 would be the cutoff to the right.

Code:
'constants
gyro_deadband 	CON 	4	'gyro deadband
yaw_ct_base	CON	10000	'base value for yaw_ct
yaw_ct_stop 	CON	5262	'yaw counts for 90 degrees

'initialize
yaw_ct = yaw_ct_base

'start main loop
DO

SERIN...

drive_L = 254		'start right turn
drive_R = 1	

if abs(sensor1-127) > gyro_deadband then 
	yaw_ct = yaw_ct + sensor1 - 127
endif

'stop after turning 90 degrees
if abs(yaw_ct - yaw_ct_base) > yaw_ct_stop then	
	drive_L = 127  	'stop turn
	drive_R = 127
endif

debug ?yaw_ct		'display count value in debug screen

SEROUT..

LOOP

Last edited by seanwitte : 11-04-2003 at 09:50.
Reply With Quote
 


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
gyro code odin892 Programming 2 08-04-2003 14:50
Team 469 and the Gyro archiver 2001 0 24-06-2002 02:57
This Gyro is driving me crazy! archiver 2001 2 23-06-2002 23:35
Is any team using the gyro chip? Ragin_Kage Kit & Additional Hardware 4 10-04-2002 12:11
Have YOU used the gyro chip? FotoPlasma Technical Discussion 10 31-01-2002 13:26


All times are GMT -5. The time now is 06:08.

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