|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Need help with code
ok so i have some autonomous code right now and This code gets the Tilt_servo variable from tracking.c, then goes into a
loop, and waits for a while, then gets the value again and tests it against the previous value to guaranty that it has not changed. If the value has not been updated, we assume that the target has been found and we can then pass the value as the final value. right now this code looks like this Quote:
Thanks Last edited by CaseyKasem_1251 : 18-02-2006 at 08:08. |
|
#2
|
||||
|
||||
|
Re: Need help with code
Is this really the code? If so, the errors are because you are missing a bunch of semicolons (like after "try_again = false"). You should also clean up the curly braces with the else statements
|
|
#3
|
|||||
|
|||||
|
Re: Need help with code
This scheme will also not work with the IFI Robot Controller design because you cannot pause execution with a "while" statement or a timing loop for any appreciable amount of time.
Doing so prevents you from servicing the regular radio packets with Getdata/Putdata, and when the Master control doesn't hear from you it automatically shuts your code down -- Red "Code Error" light. |
|
#4
|
|||||
|
|||||
|
Re: Need help with code
Code:
angle = TILT_Servo;
try_again = false;
while (try_again == false)
{
first_angle = TILT_Servo;
for (y = 1; y<=1000; y++)
{
//do nothing-wait
}
second_angle = TILT_Servo;
if (first_angle == second_angle)
{
(TILT_Servo)
}
else
{
try_again = true;
}
Couple of Things: 1. There is no Boolean Variables right out of the box for MPLAB. You can get them by assigning your variables as int and then have: #define TRUE 1 #define FALSE 0 at the top of your code 2. Try and use indentation. It will make debugging your code a lot easier 3. I have noticed a lot that MPLAB doesn't like when you don't use {} on single line For/If/While statements. That is why I put those in. 4. == is for conditional statements. IF / While statements = is for assignment statements. There were couple of places where those were messed up If you have any more question feel free to contact me on one of my Instant Messaging ways |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Encoder Code | Kevin Watson | Programming | 47 | 18-02-2008 12:56 |
| Problem with idata_user_routines.o? | Adrien | Programming | 3 | 12-02-2006 01:33 |
| Trying to import Camera code into program without. | Kingofl337 | Programming | 1 | 18-02-2005 00:43 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |