Go to Post ...six-year-old Libby had dragged her by the hand over to my (M.D./Ph.D) father and said, "Daddy, this is Miss Sally. She's a doctor AND and astronaut. YOU'RE just a doctor." - Libby K [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
  #31   Spotlight this post!  
Unread 10-03-2004, 09:45
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
Re: problem with autonomous that has stumped all programmers so far

In the following code (with lots of test lines) the Move () function is called many time to determine if the move has completed. The printf which the first line of the function appears and so does the second showing "TT=%d". But the subsequent printf statments never appear and it acts like the function just simply returns to the caller.

I'm suspecting a problem with how C18 handles long math. Read the relese note... it can make a person worry about what works.

I've already logged one bug with Microchip. The SetChanADC function needs to shift the channel number one bit to the right. I'm working on another white paper about "Faster Analog" input. Anyone want to review it?

I have talked to other teams and many have seen this problem - but no one has indetified the "root cause". I'm officially told to re-enter my program. There has to be an answer to help all of us.

int Move (void) {
static long l, r;
int ll, rr;
static int t, t1, t2;

printf("In Move STATE 1.\n");
switch (next_state) {

// Ramp Up. Stay in this state for the ramp up time
// or until the braking distance.
case 1 :
// Have you traveled far enough at this speed to brake in a safe distance?
// Compute the average distance remaining to go.
// l = get_LeftWheelDistance () - StartDistanceLeft;
// r = get_RightWheelDistance () - StartDistanceRight;

// why is 1200 / 2 = 22
ll = 1200;
rr = 0;
t = ll + rr;
printf ("TT = %d\n", t);
t = t / 2; // t = 1200 then t = t /2 results in 22!
printf ("TT = %d\n", t);

printf ("1200/2 %d\n", 1200/2);
l = 1200;
r = 0;
t = (int) l + (int) r;
printf ("T = %d\n", t);
t = t / 2; // t = 1200 then t = t /2 results in 22!
printf ("T = %d\n", t);
t = lAbs((long) t);
printf (" Move 1 l %4d r %4d Avg %4d\n", (int) l, (int) r, t);
...
  #32   Spotlight this post!  
Unread 10-03-2004, 12:25
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: problem with autonomous that has stumped all programmers so far

Quote:
Originally Posted by Daniel
In the following code (with lots of test lines) the Move () function is called many time to determine if the move has completed. The printf which the first line of the function appears and so does the second showing "TT=%d". But the subsequent printf statments never appear and it acts like the function just simply returns to the caller.

I'm suspecting a problem with how C18 handles long math. Read the relese note... it can make a person worry about what works.

I've already logged one bug with Microchip. The SetChanADC function needs to shift the channel number one bit to the right. I'm working on another white paper about "Faster Analog" input. Anyone want to review it?

I have talked to other teams and many have seen this problem - but no one has indetified the "root cause". I'm officially told to re-enter my program. There has to be an answer to help all of us.

...
%d is designed to print out an int, not a long. chances are that is the source of your problem. also, you might try the following to correct the "1200/2 = 22" bug:

Code:
t = t / (long)2;
instead of the current t = t / 2; line.

this is because 2 is automatically type cast to an unsigned char, and thus the math is performed in the unsigned char space, not the long space.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #33   Spotlight this post!  
Unread 10-03-2004, 22:22
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
Re: problem with autonomous that has stumped all programmers so far

I'll try it tommorrow between doing inspections.

But as a computer scientis type of person I want to know why something that simple and obscure can make a function prematurely return or act weird. Then I'll know that I have the problem solved, and it will not come back and byte me again.
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
PWM problem in autonomous outofcontrol Programming 5 27-02-2004 11:58
Urgent!!! Problem concerning Backup battery and autonomous. Code\\Pilot Programming 3 26-02-2004 16:44
autonomous..... Arefin Bari Rumor Mill 30 19-12-2003 10:53
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Autonomous Kill Switch UCGL_Guy Programming 8 15-01-2003 17:39


All times are GMT -5. The time now is 15:47.

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