View Single Post
  #26   Spotlight this post!  
Unread 03-12-2011, 01:03
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 443
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Team 254 2011 FRC Code

Quote:
Originally Posted by AdamHeard View Post
It's easier to generate the polynomial with software (completely avoiding any transcription by hand or hand calcs). This is unless there is a piece-wise linear approximation tool I am unaware of.

Also, for simple math, it's not really a concern when running on the cRio.
No tool is needed, you simply identify the X and Y coordinates of points that define the lines.

My team dumps these points into a 2d array and uses the point slope formula to calculate the output for any given input.

Quote:
Don't forget that another option is pre-processing of lookup tables, if the memory will hold it. 256 data points, 1 per PWM step, would be easy to calculate during sensor initialization and also cut down on cycles. Preprocessing it instead of pre-programming it also allows you to make adjustments to parameters before each match (if needed).
Agreed, we could pre-compute a lookup table, but unless we compute for all possible inputs we'll have to quantize the output or interpolate between the points.

The main reason why we don't take this approach on my team is because of the flexibility provided by the piecewise function. We can code our method once and set it up to operate on a 2d array of x,y coordinates. Changing that array is SUPER simple if we need to do so later on, and won't require any changes to the supporting code.