Maths Problem
This may end up being embarrassing for me [noparse]:([/noparse] I've been experimenting with
this for a while and I was hoping someone may have been here before and will
be able to help me.
I have a Motor with a ten turn Pot attached to it to give positional
information and an H bridge to drive it.
The position of this motor is controlled by a pot.
Both of these are determined by use of RCTIME. The application is a Focus
motor for lenses on motion picture cameras. Lenses come with different
diameter rings and lengths of travel. The Pot that controls the focus is
constant so the value for RCtime is between ..
1 - 300
and the motor (full travel from one end of the pot to the other)
1- 422
On power up the user is instructed to disengage the motor and set the lens
scale to the centre of the travel. The stamp then finds the far limits of
motor travel. Then returns the motor to the centre of it's travel. The
user is then instructed to engage the motor with the lens.
The stamp now looks for the end of the travel on the lens (i.e. infinity and
close focus) by pulsing the motor until there is no change in the result.
This will always be less than the full travel .. thus ..
Mclock = 422 (Motor fully clockwise)
Maclock = 1 (Motor full Anticlocwise)
Minf = 100 (Point where infinity is encountered)
Mclose = 300 (Point where close focus is encountered)
Whereas the control pot will always be .. (Not strictly a constant but for
sake of argument a constant)
Cinf = 1 (point on the control where infinity is encountered)
Cclose = 300 (point on the control where close is encountered)
so in computer with normal maths I would do something like this ...
Percent = Kpos /((Close - Cinf)/100) 'Kpos is the position of the knob
Percent is percentage of travel
Mpos = (((mclose - minf)/100) * percent)+ minf 'Mpos is the target position
for the motor
Of course this would only work because you could use very long numbers to a
multitude of decimal places. Does anyone know I could do this on a stamp ?
Justin Pentecost
this for a while and I was hoping someone may have been here before and will
be able to help me.
I have a Motor with a ten turn Pot attached to it to give positional
information and an H bridge to drive it.
The position of this motor is controlled by a pot.
Both of these are determined by use of RCTIME. The application is a Focus
motor for lenses on motion picture cameras. Lenses come with different
diameter rings and lengths of travel. The Pot that controls the focus is
constant so the value for RCtime is between ..
1 - 300
and the motor (full travel from one end of the pot to the other)
1- 422
On power up the user is instructed to disengage the motor and set the lens
scale to the centre of the travel. The stamp then finds the far limits of
motor travel. Then returns the motor to the centre of it's travel. The
user is then instructed to engage the motor with the lens.
The stamp now looks for the end of the travel on the lens (i.e. infinity and
close focus) by pulsing the motor until there is no change in the result.
This will always be less than the full travel .. thus ..
Mclock = 422 (Motor fully clockwise)
Maclock = 1 (Motor full Anticlocwise)
Minf = 100 (Point where infinity is encountered)
Mclose = 300 (Point where close focus is encountered)
Whereas the control pot will always be .. (Not strictly a constant but for
sake of argument a constant)
Cinf = 1 (point on the control where infinity is encountered)
Cclose = 300 (point on the control where close is encountered)
so in computer with normal maths I would do something like this ...
Percent = Kpos /((Close - Cinf)/100) 'Kpos is the position of the knob
Percent is percentage of travel
Mpos = (((mclose - minf)/100) * percent)+ minf 'Mpos is the target position
for the motor
Of course this would only work because you could use very long numbers to a
multitude of decimal places. Does anyone know I could do this on a stamp ?
Justin Pentecost
Comments
>so in computer with normal maths I would do something like this ...
>
>Percent = Kpos /((Close - Cinf)/100) 'Kpos is the position of the knob
>Percent is percentage of travel
Hi Justin,
If (Close-Cinf) is (practically speaking,as you said) a constant
(=299), this reduces to:
Percent=Kpos * 100/299 ' okay stamp math
where Kpos is the value that comes from the RCtime command.
In stamp math, a slicker way to compute this is:
Percent=Kpos ** 21918 ' good stamp math
(using the approximation 21918/65536 ~= 100/299)
That would give percent rounded down to an integer in the range
0-100. Here is a formula that would give tenths of a percent (as an
integer from 0 to 999, implying a fraction from 0/1000 to 1000/1000.)
Percent10=Kpos */ 856 ' good stamp math
(using the approx. 856/256 ~= 1000/299)
or
Percent10 = Kpos * 10 ** 21918
Here is another way to do it that will make things simpler later.
Instead of a percentage, find a word value "blub" such that
blub/65536 = Kpos/299
That is really the same idea as percentage, except that the
denominator is 65536 instead of the 100 you usually use for
percentage. Rearrange...
blub = Kpos/299 * 65536 <-- not good stamp math!
On the stamp, do it this way
blub = Kpos */ 56111 ' good stamp math
(using the approximation 56111/256 ~= 65536/299)
Why "blub"? It makes the next part easier...
>
>Mpos = (((mclose - minf)/100) * percent)+ minf 'Mpos is the target position
>for the motor
In stamp math, rewrite this as:
Mpos = (mclose - minf) ** blub + minf ' good stamp math
The operation ** blub computes the fractional part you are seeking,
with better than 4 digit precision.
>
>Of course this would only work because you could use very long numbers to a
>multitude of decimal places. Does anyone know I could do this on a stamp ?
The RCtime command is giving you a little more than 1/2 percent of
resolution with the R and C values you are using. That does not
justify a "multitude" of decimal places. However, the approximations
above are accurate enough.
Or not? Does that answer the question?
-- regards,
Tracy Allen
electronically monitored ecosystems
mailto:tracy@e...
http://www.emesystems.com