I have a series of 40 points that represent a curve. It's not a linear
curve. In fact, it doesn't necessarily even have a positive slope
throughout. What I want to do is to create a scaling that is variable
depending on the position on the curve. It's probably best to give an
example:
point 40 = 100 (dec.)
point 30 = 80
point 20 = 75
point 10 = 70
point 1 = 35
Let's say at point 30, we want to add an additional 10% to the value. So, I
want to add an additional 10% also at all the other points (3 or 4 at point
1 and 10 at point 40). This will, of course, change the characteristics of
the curve as a whole, but it is necessary in this application.
Any quick ways? My initial idea was to take the percentage and try to
multiply it out, but I'm not sure how this would work over the entire
percentage range (i.e., I could be adding as little as 1% or as much as
200%) and I would probably need some sort of floating point math for any
sort of precision at the lower values.
My other idea was just to take the endpoints, find the ratio between them,
and linearly scale the intermediate points, even though that's not entirely
accurate, but it's better than nothing.
Thanks,
--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
-- http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
At 09:54 AM 7/1/01 -0400, Drew wrote:
>I have a series of 40 points that represent a curve. It's not a linear
>curve. In fact, it doesn't necessarily even have a positive slope
>throughout. What I want to do is to create a scaling that is variable
>depending on the position on the curve. It's probably best to give an
>example:
>
>point 40 = 100 (dec.)
>point 30 = 80
>point 20 = 75
>point 10 = 70
>point 1 = 35
>
>Let's say at point 30, we want to add an additional 10% to the value. So, I
>want to add an additional 10% also at all the other points (3 or 4 at point
>1 and 10 at point 40). This will, of course, change the characteristics of
>the curve as a whole, but it is necessary in this application.
Questions:
1. What resolution do you need for the multiplicative scaling from 1% to
200%? E.g., 1:256, 1:4096, etc.
2. What accuracy, if any, do you need for cumulative displacement from the
original scale?
3. What accuracy is required for the invariance of the ratio of points in
the original scale? E.g., 1:256, 1:4096, 1:65536, etc.
4. What is the maximum number of times rescaling will occur?
>Any quick ways? My initial idea was to take the percentage and try to
>multiply it out, but I'm not sure how this would work over the entire
>percentage range (i.e., I could be adding as little as 1% or as much as
>200%) and I would probably need some sort of floating point math for any
>sort of precision at the lower values.
The simplest solution would be to add the original values to a fixed point
multiple by an 8-bit coefficient. This, however, would result in cumulative
scaling errors growing as multiple scalings occur.
The long-term relative drift can be controlled by either adding bits of
accuracy (e.g., 16, 24 or 32 bit values with corresponding fixed point
arithmetic), or by a simpler method of scaling only the maximum number and
then rescaling the other numbers to the maximum, based on stored values of
the original scale:
New Value = Scaled Max Value x Orig Value / Orig Max Number
The error in this case is just the single scaling error plus the single
rounding error.
>My other idea was just to take the endpoints, find the ratio between them,
>and linearly scale the intermediate points, even though that's not entirely
>accurate, but it's better than nothing.
This is basically the idea, but say "original scale" instead of "original
scale".
================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: spam_OUTralTakeThisOuTlcfltd.com
Least Cost Formulations, Ltd. URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239 Fax: 757-467-2947
"Vere scire est per causas scire"
================================================================
-- http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
The usual way to deal with a nonlinear curve from a sensor or whatever is to
linearize it. One method for doing that is by "curve fitting", where you
find an analytic equation that reproduces the curve you are interested in.
A nice tool for this can be found at: http://www.ebicom.net/~dhyams/cvxpt.htm
The other common method is to have a table in your program. Your software
finds the nearest matching value in the table. If that's close enough for
your application, then you're done. If it's not, then you interpolate
between the nearby table entries using methods that are well described in
any numerical methods textbook.
Once you have a nice linear number (0% - 100% for instance), then messing
around with it becomes pretty simple and non-confusing.
On Mon, 2 Jul 2001 08:06:07 -0500 Don Hyde <.....DonHKILLspam@spam@AXONN.COM> writes:
> The usual way to deal with a nonlinear curve from a sensor or
> whatever is to
> linearize it. One method for doing that is by "curve fitting",
> where you
> find an analytic equation that reproduces the curve you are
> interested in.
> A nice tool for this can be found at:
> http://www.ebicom.net/~dhyams/cvxpt.htm
>
> The other common method is to have a table in your program. Your
> software
> finds the nearest matching value in the table. If that's close
> enough for
> your application, then you're done.
Curve Expert is neat software! I've used it to generate a curve through
emperical values, then generate a table to go on the PIC.
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today! For your FREE software, visit:
dl.http://www.juno.com/get/tagj.
Your numbers fit a third order polynomial quite well and if your problem was
to add a value to each point, you would be in business (just modify the "a"
term). Frankly, the only way I know that will work in all cases is to:
a) represent your curve by an equation (in this case a polymonial)
b) get back to your original numbers by reversing the equation.
c) modify the y intercepts in the desired manner.
d) re calculate the polynomial coefficients.
We are doing this in a Pic 17C756A. You can use 24 bit float for the
polynomial, but will need 32 bits for the solver.
I guess I got to ask the most important questions of how big a Pic? and how
much time do you have? (Both real time and coding time)
On the other hand, you could use whatever technique you choose for you
original curve and then scale the y values after they are computed.
What resolution are you looking for? Would an 8 bit result do? If so
with a little cleverness you may be able to use 16 bit integer math. My
company measures ships. We do it in 24 bit integer millimeters,
anything from a rowboat to a supertanker! We don't use a PIC, we use a
network of ten PICs.