Go to Post Sometimes I think all the Game Hint does to us is make us terrible listeners. - Chris is me [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
  #5   Spotlight this post!  
Unread 10-09-2008, 16:37
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Servo 'smoothing'

Quote:
Originally Posted by Alan Anderson View Post
Code:
// DISCLAIMER: THIS CODE IS UNTESTED

// declare some variables at the beginning of the code
char incount = 0; // this will count the input values being accumulated
int accumulator = 0; // this will accumulate input values
char smooth = 128; // this will hold the smoothed input value

// ....

// do this each time a new OI value is available
  accumulator += (int)potval; // replace 'potval' as appropriate, e.g. p1_aux
  if( incount++ == 8 ) // is this the eighth sample?
  {
    smooth = accumulator << 3; // a quick and sneaky way to divide by 8
    incount = 0; // set to count another eight samples
    accumulator = 0; // reset accumulator
  }

Does the incount++ action actually happen? I mean, when you check if the "if" statment is true, does the Microprocessor increase the valuce of incount? If it doesn't work, this should be done in a for loop, but if this "if" statment counts as a loop, then OK (it's just a method of a loop i've never seen before ).
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.
 


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
Data Smoothing Lafleur Programming 3 14-01-2008 22:06
Servo behavior question / advanced servo/PIC programming question DanL Electrical 12 18-10-2005 18:33
Servo Values DanDon Motors 8 14-02-2005 15:49
Buying Servo Gamer930 Motors 4 13-02-2005 20:44
Servo MASherry General Forum 6 04-10-2004 22:46


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

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