Go to Post I don't get what all you people have done wrong to make the drills have so many problems. - Cory [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-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 03-08-2003, 05:23 PM
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
Running a motor for a set time in auton

Suppose that I need to run relay1 for 500 milliseconds. I have tried code like this in roboemu1.11.


if (auton_mode = 1) then
relay1_fwd = 1
pause 500
relay1_fwd = 0
endif



Shouldn't that turn on relay 1, wait 500 milliseconds, then turn it off?

Since this doesn't work how would you do it?

Thanks
__________________
"Lock the Doors"

NASA chief flight director Leroy Cain on the loss of Columbia's signal.
  #2   Spotlight this post!  
Unread 03-08-2003, 06:22 PM
Jeff_Rice's Avatar
Jeff_Rice Jeff_Rice is offline
ElementisRegamusProelium
#1359
Team Role: Programmer
 
Join Date: Dec 2002
Location: Linn County
Posts: 283
Jeff_Rice will become famous soon enoughJeff_Rice will become famous soon enough
That won't work. You'll have to program a timer in. The stamp cycles about once every 26 milliseconds.

Time var byte
Timeover var bit

If timeover = 1 then timeroff

Time = time + 1 + delta_t 'make sure to turn delta_t on,
' otherwise this won't work
relay1_fwd = 1

If time < 20 then dont_turn_off
relay1_fwd = 0
Timeover=1

dont_turn_off:
timeroff:

'PBasic takes inputs, and sends outputs accordingly once every
'cycle. That is why your code doesn't work.
'I think the pause just pauses the cycle. I haven't ever used it.
'Good luck on your programming! Feel free to ask other any other
'questions.
__________________
"He said my name is Private Andrew Malone
If you're reading this then I didn't make it home
But for every dream that's shattered another one comes true
This car was once a dream of mine now it belongs to you
And though you may take her and make her your own
You'll always be riding with Private Malone" David Ball, "Private Malone"
  #3   Spotlight this post!  
Unread 03-08-2003, 06:59 PM
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
Jeff_Rice's code should work for you. If you want some more info on why the original code wouldn't work, read on. Otherwise, just ignore the rest of this.

Here goes:
1. None of the variable names actually mean anything. For example, you could rename relay1_fwd to relay7_rev and as long as you updated the aliases correctly, the Stamp wouldn't know the difference.
2. Just setting a variable won't change the motor itself. In fact, setting the variables are just a matter of convience and allow for more complex processing.
3. The motors are actually set by the values passed to the SEROUT command.

Since the original code never reaches a SEROUT between the relay1_fwd = 1 and the relay1_fwd = 0, the relay will never know the difference. Furthermore, if you don't do a SEROUT at least once every 5 loops (that's ~125ms), you'll get a Basic Run Error. RoboEmu is a little more forgiving and will only complain after 1s which is probably why you didn't get any actual errors.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #4   Spotlight this post!  
Unread 03-09-2003, 03:50 PM
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
thanks
__________________
"Lock the Doors"

NASA chief flight director Leroy Cain on the loss of Columbia's signal.
  #5   Spotlight this post!  
Unread 03-09-2003, 11:41 PM
Eric G Eric G is offline
Registered User
#0343 (Metal In Motion)
 
Join Date: Mar 2003
Location: Seneca, SC
Posts: 15
Eric G is an unknown quantity at this point
I would also warn you to avoid doing anything that will tie up the robot in a loop -- even one that includes a serout command. OR, let me say that all loops MUST include a test for autonomous mode bit. If you get in a pause or a loop and do not test for the end of autonomous mode, you will have a robot and a human, but no loving nurturing relationship...

Eric
  #6   Spotlight this post!  
Unread 03-11-2003, 12:59 PM
yruhere yruhere is offline
Registered User
None #0769
 
Join Date: Mar 2003
Rookie Year: 2002
Location: _
Posts: 7
yruhere is an unknown quantity at this point
Also something very important is having a SERIN command just before your autononomous code. This is very important because you need to get the mode every time it goes through the loop (you won't get control from the robot if you don't.)
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
Actual execution time measurement Dan Technical Discussion 5 03-24-2003 10:36 AM
auton mode running motors incorrectly BK36 Programming 2 03-12-2003 01:43 AM
Solution to Timing Loops Steven Carmain Programming 39 02-10-2003 12:33 PM
Tranny help Thunder360 Motors 4 02-04-2003 02:12 PM
How long should production time be??? archiver 1999 4 06-23-2002 10:16 PM


All times are GMT -5. The time now is 02:02 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi