Go to Post CIMs are NEAR indestructible and I <3 them for it. - Andrew Schreiber [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 17-09-2003, 21:33
Salik Syed Salik Syed is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Stanford CA.
Posts: 514
Salik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud of
Send a message via AIM to Salik Syed
Autonomous Program

Hi, we are currently working on a new autonomous program which uses infared sensors for more accurate readings I know several teams have done this. Anyways this is what we have come up w/ so far... can anyone spot a mistake? It tokenizes but there is a Basic run error when putting it on the robot.

if auton_mode=1 then auto1:
goto end_auto_loop:

auto1:
first:
if dist>7 then end_first:
drive_R=0 'ur going backwards remember
drive_L=0
if rc_sw3=0 then end_auto_loop:
dist=dist + whlc
goto end_auto_loop:

end_first:

turn:
if dist>9 then end_turn:
drive_R=difrdir
drive_L=difldir
if rc_sw3=0 then end_auto_loop:
dist=dist + whlc
goto end_auto_loop:

end_turn:

open_pnuematics:
if dist>10 then end_open_pnuematics:
p1_sw_trig=1 'open lower pneumatic
p2_sw_top=1 'close shoulder pneumatic

end_open_pnuematics:

straight:
if dist>16 then end_straight:
drive_R=255 'straight now
drive_L=255
if rc_sw3=0 then end_auto_loop:
dist=dist + whlc
goto end_auto_loop:

end_straight:

straight2:
if dist>21 then end_straight2:
drive_R=255 'straight now
drive_L=255

end_straight2:

finish:
drive_R=127
drive_L=127
p1_sw_top=1 'close lower pneumatic
p2_sw_top=1 'open shoulder pneumatic

end_auto_loop:
__________________
Team 701
  #2   Spotlight this post!  
Unread 17-09-2003, 21:40
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Well, one guess is that you're feeding 255 as a value. That particular value is used to store something partaining to the code (I forget what) but basically, avoid it. Try using 254 instead.
Man I need to open up pBasic again!
It been so...long....
Anyaway, the new language sould be revealed 10/01/03
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #3   Spotlight this post!  
Unread 18-09-2003, 01:05
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
Sachiel7 has it pretty well correct, but I don't think (s)he (trying not to be presumptuous, here) explained the concept well enough.

To my knowledge, when you send the value 255 to a speed controller, by defining either drive_L, drive_R, or PWMn as 255, the speed controller interprets this as 0V (or 0% duty cycle), rather than +12V (100% duty cycle), which is full forward.

254 is the maximum value which you're supposed to send to a speed controller.

I just looked at the RC Reference Guide, on IFI's website, and there isn't a very descriptive explanation as to what specifically is wrong. Id est...
Quote:
Programming Problem: Basic Run Error Indicator
If after programming and resetting the Robot Controller, the BASIC RUN ERR LED is ON, then the
basic code has no output. This means that the code is not running properly. Check for errors in the
code. The BASIC RUN ERR light is controlled by the Output microprocessor.
So, actually, now that I think of it, if you're sending 255 as a PWM output, it (the Output microprocessor) might interpret that as the end of the SEROUT command from the BS2, and think that it's supposed to then recycle (start its sequence all over). Perhaps changing the values from 255 to 254 will do the trick.

Hope this helps, some. Good luck!
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #4   Spotlight this post!  
Unread 18-09-2003, 15:33
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
A value of 255 in the wrong place will not cause a Basic Run error, unless you're very lucky. Instead, it'll make your robot do a "not-so-happy" dance, with random LEDs blinking and whatnot, due to the problem Jim mentioned, that the SEROUT command gets screwed up. We had this problem in 2002, and it took a bit of time to figure it out .

Instead, one thing that I've noticed, unless you have any debug statements, leaving the serial cable in the Programming Port will trigger an error, I believe a Basic Run error, but I can't remember what exactly.

Another possible problem is that someone touched the uP init section, and I'm pretty sure that can't be touched or it'll break. Also, make sure you use the Constants section correctly, because I believe any value used in SERIN and/or SEROUT must be "signed" by a Constant. It's been a while, so I can't remember exactly, but definitely check the default code on www.innovationfirst.com/firstrobotics to make sure nothing crucial changed.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #5   Spotlight this post!  
Unread 20-09-2003, 21:42
Jeremy J's Avatar
Jeremy J Jeremy J is offline
Registered User
#0871 (West Islip Robotechs)
 
Join Date: Jan 2003
Location: West Islip, NY
Posts: 10
Jeremy J is an unknown quantity at this point
Send a message via ICQ to Jeremy J Send a message via AIM to Jeremy J Send a message via Yahoo to Jeremy J
Well, after a short collaboration with my team's lead programmer, we agree that for the robot, 255 exceeds the max value of what the robot controller can understand. 254 is the max value, I believe. Try changing it to that and then running the program. That should help

EDIT: Another idea is to check your var declarations, and make sure you have everything declared, as well as checking constants and SERIN and SEROUT. Also, try unplugging the serial cable from the program port and resetting the bot. When we had basic run errors and did that, they usually went away. Otherwise, we turned to the lead programmer and made him go fix the code
__________________
"...at about this time, somebody will be telling you to get on the plane, on the plane, on the plane. I say **** you, I'm getting IN the plane!" - George Carlin
-2002 Rookie All-Star
-2003 LI Regional 2nd place

Last edited by Jeremy J : 20-09-2003 at 21:47.
  #6   Spotlight this post!  
Unread 20-09-2003, 23:32
Damian Manda's Avatar
Damian Manda Damian Manda is offline
The Damian
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Fort Collins, CO
Posts: 154
Damian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud of
Send a message via AIM to Damian Manda
As far as I can remember, sending two values of 255 in a row in the serout will cause a reset, and everything will be messed up. This is why there are two 255's at the beginning of the serout. It tells the processor that the outputs begin there. If it resets later, the variables wil not match up with what is being outputed, hense undesired motor output. If this makes no sense, I can try to explain it better, but for right now I am too tired.

I think the consensus is that 255 should be avoided, due to many reasons.

--Damian Manda
  #7   Spotlight this post!  
Unread 21-09-2003, 11:36
WakeZero WakeZero is offline
FIRST-a-holic Strategist
#1011 (CRUSH)
 
Join Date: Feb 2002
Location: Tucson, AZ
Posts: 316
WakeZero will become famous soon enough
Send a message via AIM to WakeZero Send a message via Yahoo to WakeZero
Quote:
Originally posted by Jeremy J
Well, after a short collaboration with my team's lead programmer, we agree that for the robot, 255 exceeds the max value of what the robot controller can understand. 254 is the max value, I believe. Try changing it to that and then running the program. That should help
Yes, this is the case of a common fencepost error. In most programming languages, including this one, counting starts at zero instead of one. So if you want 10 numbers, it is really 0 through 9, not 1 through 10. So there are 255 values that you can assign a PWM, but it is 0-254
__________________
2004 Arizona Regional -- Semifinalist
2003 NAT Galileo Division -- Highest Seeded Rookie (20th)
2003 NAT Galileo Division -- 100% Autonomous Completion (7 for 7)
2003 Arizona Regional -- Rookie All-Star Award
2003 Arizona Regional -- Quarterfinalist

Alumni on Team 64, The Gila Monsters
College Mentor/Founder of Team 1011, CRUSH
  #8   Spotlight this post!  
Unread 21-09-2003, 13:24
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
A few things:

a) NEVER EVER EVER EVER EVER set a PWM to 255. EVER! As
Damian Manda said, sending two 255's in a row will cause the RC to think that all bytes following it are the start of a new Serout command. Thus, what should have been output to PWM5, for example, may end up being interpreted as relayA, causing stuff to go massively haywire.

b) The "wrapping" of numbers isn't really an issue here. PWMs are stored as bytes (8 bits), so they can have 256 values (0-255). It's just that 255 means something else...

c) For you power freaks out there that are concerned about not getting that extra 1/256 of an output to your speed controllers, don't be! The Victors interpret anything above about 240 to be full ahead and anything below about 17 (IIRC) to be full reverse. The only even semi-real disadvantage to not being able to use 255 is that you'll loose 1/256th of a rotation on your servo.

-Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #9   Spotlight this post!  
Unread 23-09-2003, 20:19
Adam Collet Adam Collet is offline
Registered User
#0159 (Alpine Robotics)
 
Join Date: Nov 2002
Location: Ft. Collins, Colorado
Posts: 25
Adam Collet is an unknown quantity at this point
thank you

Thank you, thank you, thank you, Rob for saying everything I'd wanted to scream since starting of reading the post. Probably better you said it though, since I tend to get a little excited. Oh well, it's all been said. But anyway, that code looks like a perfectly good SELECTION of code - there may be an error somewhere else that you didn't include; though your 255 error is an almost certain culprit of your problem. Tell us if it's still not working out for you.
__________________
"Without the wind, the grass does not move. Without software, hardware is useless.''

Thus spake the Master Programmer

The Tao of Programming
Translated by: Geoffrey James
  #10   Spotlight this post!  
Unread 23-09-2003, 21:10
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,586
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
I think it is unlikley that setting the pwm values to 255 is causing the problem. But, it depends on what PWM values the variables correspond to. If this was the problem, you'd have a problem sometime into running the program, not on download.

how big is dist and whlc and do you overrun anything when adding them together? Same thing, this shouldn't cause the error, but is something to look into.

I think the most likely cause was already mentioned by Ian. If you tried to read in a new sensor, but didn't define the constant saying that you want to read it, your serin will be mismatched with the initialization. Look at the section of the code labled "DEFINE CONSTANTS FOR INITIALIZATION"

It would also be helpful to see more of your code if one of the suggestions doesn't help.
  #11   Spotlight this post!  
Unread 23-09-2003, 22:17
Unsung FIRST Hero
miketwalker miketwalker is offline
Robot Lifeguard
FRC #1902 (Exploding Bacon)
 
Join Date: Dec 2001
Rookie Year: 2002
Location: Orlando, FL
Posts: 878
miketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond repute
Send a message via AIM to miketwalker
Fotoplasma has it right, and I like how Rob described the problem. I remember researching this, and if you look into the code, every time it sends out to the RC the new packet it sends "255,255" at the beginning to tell it that this is new information if I'm not mistaken. The purpose of this, is code has errors, it skips (delta_t counts how many times it's skipped for those that don't know) and when it skips, without that "255,255" it'll interpret the inputs as part of the line before, and we all know we don't want that. So when you have 255 run in another part of the robot, as someone put it, it does a dance, because it keeps translating the inputs into different areas and each time it errors (I believe) the outputs will swap again, so things go nuts. I'm not 100% sure about all of this, but this is the conclusion I came to awhile ago and I think that's what happens. But yea, swapping your 255 will almost ALWAYS fix that. Another trick if that doesn't work, stick a debug statement somewhere before the lines to output "hello" or something, just so you can tell if the code gets to that without having an error, then move the debug around to find the problem area, then you work with that area and sometimes it connects to something else and then you have to look at that as well. I hope this helps. Good luck!
__________________
Chopsaw? Chopsaw.
  #12   Spotlight this post!  
Unread 24-09-2003, 12:39
WakeZero WakeZero is offline
FIRST-a-holic Strategist
#1011 (CRUSH)
 
Join Date: Feb 2002
Location: Tucson, AZ
Posts: 316
WakeZero will become famous soon enough
Send a message via AIM to WakeZero Send a message via Yahoo to WakeZero
Quote:
Originally posted by rbayer
b) The "wrapping" of numbers isn't really an issue here. PWMs are stored as bytes (8 bits), so they can have 256 values (0-255). It's just that 255 means something else...
Not true, if you read the Innovation FIRST comments (which I doubt anyone does anymore ) it specifically says that a PWM can have 255 values, not 256. So the wrapping error is very important for people to understand, since it is 0-254, not 1-255
__________________
2004 Arizona Regional -- Semifinalist
2003 NAT Galileo Division -- Highest Seeded Rookie (20th)
2003 NAT Galileo Division -- 100% Autonomous Completion (7 for 7)
2003 Arizona Regional -- Rookie All-Star Award
2003 Arizona Regional -- Quarterfinalist

Alumni on Team 64, The Gila Monsters
College Mentor/Founder of Team 1011, CRUSH
  #13   Spotlight this post!  
Unread 24-09-2003, 13:48
djcapelis's Avatar
djcapelis djcapelis is offline
Fried Manic Custard
None #0675 (Geeks with Power Tools)
Team Role: Programmer
 
Join Date: May 2003
Rookie Year: 2001
Location: Rohnert Park, CA
Posts: 129
djcapelis will become famous soon enoughdjcapelis will become famous soon enough
Send a message via ICQ to djcapelis Send a message via AIM to djcapelis Send a message via Yahoo to djcapelis
A wrapping error that I think he was refferring to would be a variable overflow... that isn't the case here.
__________________
"I have more friends than enemies, I'm working to resolve the issue."
  #14   Spotlight this post!  
Unread 24-09-2003, 18:03
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Quote:
Originally posted by Joe Ross
I think it is unlikley that setting the pwm values to 255 is causing the problem. But, it depends on what PWM values the variables correspond to. If this was the problem, you'd have a problem sometime into running the program, not on download.

how big is dist and whlc and do you overrun anything when adding them together? Same thing, this shouldn't cause the error, but is something to look into.

I think the most likely cause was already mentioned by Ian. If you tried to read in a new sensor, but didn't define the constant saying that you want to read it, your serin will be mismatched with the initialization. Look at the section of the code labled "DEFINE CONSTANTS FOR INITIALIZATION"

It would also be helpful to see more of your code if one of the suggestions doesn't help.
Joe, what you're describing is what causes Basic Init Errors, and not Basic Run Errors.

From the Innovation First Full-Size Robot Controller Reference Guide:
Quote:
Programming Problem: Basic Run Error Indicator
If after programming and resetting the Robot Controller, the BASIC RUN ERR LED is ON, then the
basic code has no output. This means that the code is not running properly. Check for errors in the
code. The BASIC RUN ERR light is controlled by the Output microprocessor.
Programming Problem: Basic Init Error Indicator
If after programming and resetting the Robot Controller, the BASIC INIT ERR LED is ON, then the
basic code did not properly initialize the data packet structure with the master microprocessor. Check
the initialization part of the code for errors. A common mistake is having a different number of
variables in the SERIN command, as compared to the requested data setup in the “Set the Initialization
constants you want to read” section of the code. The BASIC INIT ERR light is controlled by the Master
microprocessor.
My guess is that either[list=1][*]the 255s are causing the problem, or[*]some part of the code other than that of which we have visibility is preventing the serout from being executed.[/list=1]
BTW, the two relay bytes are deliberately interspersed in the serout command between PWMs 1, 2 and 3 to prevent 255s output to PWMs from causing problems in the most common cases where someone is using the default code (or has made minimal modifications to it.) So, Salik, if you're using two consecutive PWMs (not including 1 and 2) for drive_r and drive_l, there's your problem. (Actually, it is still possible to provoke this problem when you're using PWMs 1 through 3 if you happen to turn on all the relays in one of the relay bytes.)
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me

Last edited by Greg Ross : 24-09-2003 at 18:17.
  #15   Spotlight this post!  
Unread 24-09-2003, 18:52
golf_cart_john golf_cart_john is offline
Registered User
AKA: John W
FRC #0095 (Grasshoppers)
Team Role: Coach
 
Join Date: Sep 2003
Rookie Year: 2004
Location: Lebanon, NH
Posts: 36
golf_cart_john will become famous soon enoughgolf_cart_john will become famous soon enough
Are you using the newer version of PBASIC or the older version? Innovation First came out with a newer version for the 2003 season, and it doesn't use that format for the IF statements. I don't know if that would tokenize properly, but might be your problem.

However, if those 255s aren't causing a problem now, they will later. Outputting 2 values of 255 in a row will mess up your program.
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
A better autonomous method.. randomperson Programming 4 24-02-2004 18:02
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Fried program slots? Jeff Waegelin Programming 18 19-03-2003 18:08
Autonomous Kill Switch UCGL_Guy Programming 8 15-01-2003 17:39
Ahh! Program trick confusing! archiver 2001 9 24-06-2002 02:26


All times are GMT -5. The time now is 19:55.

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