|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
printf is your best debug friend
computers have a nasty habit of doing exactly what you tell them to do instead of what you want them to do whenever a program is not doing what you expected, printf the variables to see whats going on inside the SW in fact, you should get in the habit of checking SW modules this way, to make sure it is doing exactly what you thought it would do (module level testing). Then if its working correctly take the debug (printf...) statements out, or have a debug variable that you set to 0 to disable them. |
|
#2
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Assuming he didn't change the comment at the beginning of the code (which I am guessing he didn't because other wise the line numbers don't do much good) then he initialized time in the right place.
The only problem I could see there is if you just declared time and didn't initialize it. Assuming you initialized it as 0 I don't see that as being your problem. I am not sure if it is enough to cause the problem you have but at the very least it is sloppy to return a value through the function if you aren't assigning it to anything. If you still can't figure out the problem, post all of your user_routine_fast.c and we can probably help more. James |
|
#3
|
|||
|
|||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
After running it in my head (which may not be accurate), I think time is the problem. You're incrementing time, so that after 49, it reaches 50, but at it, you do not define what it does with it (ie Left() or Stop(), etc), so it will keep repeating left.
Daisy Last edited by Daisy : 02-11-2006 at 10:29. Reason: grammar |
|
#4
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Quote:
I agree with what was said above. Most likely the time variable isn't global or statically defined. Debug prints should make this apparent rather quickly if this is the case. |
|
#5
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Time is not the problem, that part works great. All i need to know is did i code the subroutines wrong or am i calling them wrong? If im doing those right then why is the code stuck in Left() when i run the robot in autonomous mode?
|
|
#6
|
|||||
|
|||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Post a zip of your user_routines_fast.c here and we'll tell you.
Right now it looks like you're taking something for granted when you post the problem and not bothering to tell us about some seemingly unimportant detail. In programming all details are important. If you weren't overlooking something your code would be working. As with most bugs you don't know what the important detail is yet.Last edited by Mark McLeod : 02-11-2006 at 15:46. |
|
#7
|
|||||
|
|||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Quote:
Speaking of "the loop", what is causing it to run 26 times per second? We definitely need to see more of the code in order to help you. |
|
#8
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
ok its now 5pm and Im awake
ok 50% chance your resetting time to be = to 0 every time you loop. 30% chance that that loop isnt happening every 26 secs(I know it says "im fast I run every 26.1 secs" but its a liar liar pants on fire) 20% chance its something else |
|
#9
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
I know it works because it works in all the other modes, just not the one with the subroutines, we have a dip switch to choose autonomous modes. but here are the user_routines_fast.c and user_routines.h files (attached)
|
|
#10
|
|||||
|
|||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Code:
if (rc_dig_in11 = 1) /* 1st Autonomy code */ The code you posted will always run the BASH routine. You need to change all those single = to double == in your if and else if statements. |
|
#11
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
Quote:
As a note to any one else who ever needs help the more code you post the better we can help, don't worry about people stealing it, it wont work on our robots anyway. James |
|
#12
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
I agree with Alan and James that a problem exists in the use of the assignment operator, but the initial problem stated that the code was stuck in Left. I don't see how this could be reached. How was it determined that it was getting stuck in Left?
|
|
#13
|
||||
|
||||
|
Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
i had a student telling me what directions the wheels were turning and i took his word for it instead of double checking, but thank you all for the help
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RC Controller Stuck | bhk88 | Programming | 1 | 31-01-2006 17:46 |
| Stuck on Camera Mount | busterblade16 | Programming | 2 | 14-02-2005 22:07 |
| stuck in programming mode | Shu Song | Control System | 2 | 29-04-2004 16:44 |
| help! Am really stuck!!!! | pagemauck | Programming | 8 | 29-01-2004 12:38 |
| guy stuck in toilet! | robot180 | Chit-Chat | 8 | 14-11-2003 22:27 |