Suppose:
You are controlling a stepper motor with 1024 possible steps. The servo controls something that outputs a value you can measure, let's call it SWR. At some value of stepper motor setting where 0 <= stepperval <= 1023, the value of SWR will be at a minimum.
Obviously you could try every value of stepper motor setting within the permissable range and measure SWR, then find the setting for the minimum.
Assumptions:
- You can jump between stepper settings, then measure which will take time...
- To find such a minimum requires doing a series of a) move to position x, b) measure SWR, c) store SWR against position ... etc..
- The stepper rotation is modulo, i.e. 0 = 1024 back to where you started)
- There might be more than 1 absolute minimums within the stepper's turning range or indeed, the measurement might be minimum for a whole range of stepper settings, don't care just find me 1 of them, or the first of them.
Question:
Is there a quick way to find the value of that minimum? Quicker than looking at the value at every stepper position?
My ideas:
-
Take 10 sample values of SWR, where the sample values of stepval are equally spaced between 0 and 1023. Find the minimum valued sample, then take 10 more samples equally spaced with the sampled minimum in the middle, and repeat until an absolute minimum is reached. (i.e. another iteration doesn't give you a lower value of minimum than the previous iteration)
-
Take 10 samples, then use cubic spline interpolation to best fit a curve between them, then seek a minimum based on the spline.
Can anyone help with this?
**Now this is where the fun starts: **
Suppose a solution to the above gives me min SWR, given x the servo position. Now suppose SWR also varies with z. My end state for the whole thing is to have a function that for any value of z, returns the value of x, that gives the minimum value of SWR. I'm guessing I could tabulate min SWR against x, for a given set of values of z, then spline x for those values of z, and use the spline curve to tell me for a given z, the servo position x for the minumum SWR.
Is there an optimum solution to the above, that requires the minimum amount of servo activity to return the stepper position for min SWR given any value of z where z is between a known and fixed lower limit and an upper limit?
I'm NOT a mathmetician, but I feel sure this is one of those problems where there's an optimum way of doing it... I don't know... a spline in three dimensions ???
Tim