Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Autonomous Program (http://www.chiefdelphi.com/forums/showthread.php?t=21955)

miketwalker 24-09-2003 19:37

Quote:

Originally posted by golf_cart_john
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.

With the 2003, the code works the same as every other year, you could just use the new version if you wanted but the old IF loops work fine still.

Joe Ross 24-09-2003 22:56

Quote:

Originally posted by gwross
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]
Yes, you're right about the serin. I realized that after I looked at that same document for a different reason, today.

Quote:

Originally posted by gwross

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.)

This is why my initial inclination was that the 255's are not causing the problem. However, after going throught the code snippet, both won't be set to 255 until dist > 9. So, either dist would have to be initialized to > 9 or the sensor would be giving a larger value then was expected. It should definetly be fixed, but I don't think it is the cause of the problem.


salik: it appears that whlc is the number of feet that you have traveled. Is that correct? How is this value computed? Are you reading it directly from your infrared sensor, is it being calculated in your program based on sensor readings? is it calculated in your custom circuit?

One common cause of your program taking to long to execute a loop is too many debug statements. Are you using any anywhere else in your code?

josh_johnson 25-09-2003 20:14

Quote:

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.)
Actually, they are interspersed to prevent problems from occurring when both relay output bytes are 255. A change from 255 to 254 will make almost no difference with the analog PWM outputs, but changing this in a relay output would completely reverse one of the digital output pins, most likely causing very undesired operation. Also, if i remember correctly, the default code sets a maximum of 254 for all the PWM outputs it uses.

My guess is that somewhere else you are doing one of 5 things:

1. getting stuck in an infinite loop
2. taking too long on part of your code. This could be caused by a loop that is ran multiple times or from several debug statements
3. skipping over your serout statement
4. you are using the serout statement incorrectly.(i.e. outputting to the wrong pin, etc.)
5. not looping back to your serin command.

It is hard to say without seeing the rest of your code. If you could post all of the code, it would be very helpful in determining your problem.

[edit] added a 5th item [/edit]


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

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