View Single Post
  #6   Spotlight this post!  
Unread 15-02-2008, 20:27
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: This code will NOT compile

Code:
int cube1 (unsigned char p1_y)
{
return((int)p1_y * (int)p1_y * (int)p1_y);
}
and you'll need to use casts to up the unsigned char to ints. Also, you can't use p1_y as a passed argument - its defined in ifi_aliases.h:

Code:
ifi_aliases.h:30: #define p1_y        rxdata.oi_analog01

and unless you are absolutely certain of the precedence rules for applying operations - use parentheses to eliminate any questions:
Code:
 
pwm01 = cube()  - (3 * square() ) + (5 * p1_y);  /*x^3-3x^2+5x* A cubic function to regulate the sensitivity of the robot's drive*/
  pwm02 = cube2() - (3 * square2()) + (5 * p2_y); /*same thing, son*/
Attached Files
File Type: c user_routines.c (15.2 KB, 50 views)
File Type: c user_routines_diff.c (3.8 KB, 26 views)

Last edited by dcbrown : 15-02-2008 at 20:52.