View Single Post
  #3   Spotlight this post!  
Unread 06-02-2003, 20:31
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
There's a good example in the whitepapers section that you can get here. Other than that, there have been a few threads on this topic recently. Here's a few I've managed to dig up:

http://www.chiefdelphi.com/forums/sh...threadid=16452
http://www.chiefdelphi.com/forums/sh...threadid=15891
http://www.chiefdelphi.com/forums/sh...threadid=16994


If you just want to see some code quickly, here's a sample:

Code:
loopCnt VAR word
loopCnt=0
DO
SERIN...
IF auton_mode = 1 THEN 
	loopCnt=loopCnt+1
	SELECT loopCnt
		CASE <50
			PWM1=254
			PWM2=254
		CASE 50 TO 149
			PWM1=127
			PWM2=254
		CASE 150 TO 219
			PWM1=1
			PWM2=1
		CASE 220 TO 249
			PWM1=127
			PWM2=254
		CASE ELSE
			PWM1=127
			PWM2=127
			PWM3=127
			PWM4=127
	ENDSELECT

ELSE
	PWM1 = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)
	PWM2 = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000)
ENDIF

SEROUT ....
LOOP
This will cause the robot to go forward, turn, go backwards, turn the other way and then stop. After autonomous mode ends, you will have normal one-joystick drive control. Let me know if you have any questions via PM/email or here.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php