View Single Post
  #1   Spotlight this post!  
Unread 14-02-2008, 19:53
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
integer print not making any sense.

Hi, We are implementing a simple digital moving average filter of the output of the p1_y and p1_x. We are pretty much summing 8 numbers that should be in the range of 0-30 therefore should get an output of around 0-240...however this isn't the case for us. We are getting an output of something in the 7000s.

Thanks for your help!
Windell

Below is the code:
Quote:
(at top of user_routines.c)
unsigned int yminus1,yminus2,yminus3,yminus4,yminus5,yminus6,ym inus7;
unsigned int tempy;

(outside of any of the functions in custom_routines.c)
extern unsigned int yminus1,yminus2,yminus3,yminus4,yminus5,yminus6,ym inus7;
extern unsigned int tempy;

/************************************************** **************************/
/*implement a moving average filter to eliminate some of the noise of the p1 ADC*/
/************************************************** **************************/
tempy=(int)p1_y+yminus1+yminus2+yminus3+yminus4+ym inus5+yminus6+yminus7;
yminus7=yminus6;
yminus6=yminus5;
yminus5=yminus4;
yminus4=yminus3;
yminus3=yminus2;
yminus2=yminus1;
yminus1=p1_y;

printf("tempy %d\r",tempy);