Go to Post Well I have to admit, most of the people on our team are geeks. I think that it's a title of honor considering it might as well be "boss" or "head supervisor" or something along those lines. - Cyberguy34000 [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-01-2003, 09:26
Brian_Lim's Avatar
Brian_Lim Brian_Lim is offline
Registered User
#0907 (EY Cybernetics)
 
Join Date: Jan 2002
Location: Toronto
Posts: 16
Brian_Lim is an unknown quantity at this point
Send a message via ICQ to Brian_Lim Send a message via Yahoo to Brian_Lim
GOING FORWARD THEN BACKWARD

Well lets see, how can you go forward and then backward

Well try to find these three lines of code

MainLoop :
'(there is code between here)

Serout USERCPU, OUTBAUD, [255,255,p1_y,relayA,p2_y,relayB,p3_y,p4_y,p1_x,p2_ x,p3_x,p4_x,p1_wheel,p2_wheel,p3_wheel,p4_wheel]

'(there is code between here)
Goto MainLoop :

Well the way it works is that every 26 miliseconds or so, the program goes through the loop and sends output through the serout command. You can't use a for loop -- it would stay inside the for loop and never get to the serout command. What you want is a counter variable to keep track of how long the robot goes forward and backwards.

For example :

'=== DECLARE VARIABLES (out of main loop)
state var byte
state = 0
counter var byte
counter = 0

'======
' PUT THIS AFTER MainLoop, before SEROUT command
if NOT (auton_mode = 1 and state = 0) then skip1
state = 1
counter = 0
p1_y = 254
skip1:

counter = counter + 1

if NOT (state = 1 and counter = 50) then skip2
state = 2
p1_y = 0
counter = 0
skip2:

if NOT (state = 2 and counter = 50) then skip3
state = 3
p1_y = 127
skip3:
' =========


You could easily alter this for tank-steering/other purposes

You notced I use the NOT and brackets, that's how I get into making the if statement a true if statement... it normally goes to the label, but if I put a NOT, it reverses, going to the label if the opposite is true... neat eh?

I'm going to be posting our team's autonomous code soon. The problem I heard from another post is that since the battery voltage changes, motor speed changes, so using an internal counter is not that reliable... but I'm not that convinced that can happen, how much voltage drop is going to happen in 2 minutes?

Hope this helps

907
Brian Lim
__________________
907 is back and we won't go quietly...
brianeyci@hotmail.com
brianeyci@yahoo.ca
ICQ #:147900708
Closed Thread


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
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Autonomous Code From Experience EbonySeraphim Programming 7 14-03-2003 21:56
Autonomous code tutorial miketwalker Programming 2 23-02-2003 12:28
Overcomplicated Autonomous Code EbonySeraphim Programming 33 20-02-2003 21:53
Autonomous Code Adrian Wong Robotics Education and Curriculum 1 18-11-2002 22:34


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

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