Go to Post The code is hopefully pretty self-documenting, but I haven't had time to comment it (kinda trying to build a robot at the moment). - RyanCahoon [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 03-03-2005, 05:07
yruhere yruhere is offline
Registered User
None #0769
 
Join Date: Mar 2003
Rookie Year: 2002
Location: _
Posts: 7
yruhere is an unknown quantity at this point
A strange occurence..

I'm a student at VCU and near the shipping deadline I went out to a school in the Richmond area that my friend mentors to help them with their programming issues. Apparently the compiler is as wonderful as last year.. and here's a solution for a problem they had...

The original code went something to the tune of:
Code:
if(calib) {
  offset01 = p1_y - 128;
  calib=0;
}
if(p1_y - offset01 > 254)
  pwm01 = 254;
else if(p1_y - offset01 < 0)
  pwm01 = 0;
else
  pwm01 = p1_y - offset01;
It would seem the compiler has issues with signed and unsigned variables and doing the math 'right' without you being very explicit. A bit of casting is all you need...

This should be the fix:
Code:
if(calib) {
  offset01 = p1_y - 128;
  calib=0;
}
if( ((signed int) p1_y) - offset01 > 254)
  pwm01 = 254;
else if( ((signed int) p1_y) - offset01 < 0)
  pwm01 = 0;
else
  pwm01 = ((signed int) p1_y) - offset01;
 


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
Strange Auto Problem NotQuiteFree Programming 6 20-02-2005 17:12
Strange 16 bit MS-DOS subsystem error Crazy_Ed Programming 6 18-03-2004 14:31
strange error Anthony Kesich Programming 2 25-02-2004 18:55
Linux and the New R/C and Strange ideas... Venkatesh Programming 7 28-10-2003 23:54
Strange Serial Input Adam Shapiro Programming 4 31-01-2003 02:01


All times are GMT -5. The time now is 04:40.

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