Micro Maestro -scripting - newbie question

When using the controller with analog potentiometer inputs, what is the best way of scripting a servo mixer function, such as aileron/elevator > elevon mixing on a V-tail/flying wing, or speed/steering on a differentially steered vehicle (tank tracks, six wheel drive robot etc)?

I understand that it will somehow involve adding the steering pot input (or more correctly, its deviation from neutral) to the speed pot input for one output channel, and subtracting it from the other, but how to write the script in order to get the correct 4000-8000 output values for right & left track/wheel/control surface from the two 0-1023 input values (where 512 is stick centered/neutral) puzzles me a bit…

http://fatlion.com/sailplanes/vtail.html

It sounds like you have a good grasp on what your script needs to do: take two input values from 0 to 1023 and produce two output values from 4000 to 8000. So now you should be able to come up with mathematical formulas for each servo output channel value in terms of the two input pot values. Once you have those formulas, it should be easy to implement it on the Maestro. Maestro scripts can perform all the basic arithmetic operations (add, subtract, multiply, divide) so you should be able to implement any kind of scaling you want.

Are you going to include a deadband region (a region in the center of the input range where both servo channels go to their neutral positions)? If so, you might need a couple different formulas, and some IF statements in your Maestro script, but it won’t be hard.

If you get stuck, feel free to post here again for more help.

–David

Have been thinking it through and came up with something like this:
(bear in mind, I havent actually got a maestro to test it on, not yet anyway…)

For output 0:
1 get position
#gets value of pot 1 (speed 0-1023, neutral is 512)

2 get position plus
adds value of pot 2 (steering 0-1023, neutral is 512)
#(both inputs neutral gives 512 plus 512=1024, possible range
#is between 0 (0 plus 0) and 2046 (1023+1023)

512 minus
#subtracts 512 (effectually changes reading of pot 2 to be +/-512 rather than +0 / +1023;
possible range is now from -512 to +1534, with both inputs neutral =512)

Max 0
#sets value to 0 or higher (if value is less than 0)

Min 1023
#sets value to 1023 or lower (if value is more than 1023)

4 Times 4000 Plus
#scales value to 4000-8092, approximately 1-2 ms

0 servo
#set servo #0 based to the value

And for output 1:
1 get position
#gets value of pot 1 (speed 0-1023, neutral is 512)

2 get position minus
#subtracts value of pot 2 (steering 0-1023, neutral is 512)
#both inputs neutral gives 512 minus 512=0, possible range is
#between -1023 (0 minus 1023) and +1023 (1023-0)

512 plus
#adds 512 (effectually changes reading of pot 2 to be +/-512 rather than +0 / +1023,
#possible range is now from -512 to +1535, with both inputs neutral =512)

Max 0
#sets value to 0 or higher (if value is between -512 and 0)

Min 1023
#sets value to 1023 or lower (if value is between 1023 and 1535)

4 Times 4000 Plus
#scales value to 4000-8092, approximately 1-2 ms

1 servo
#set servo #1 based to the value

Does it look like this would work? Is there a better/easier/more elegant way?
(I’m rather sure there is…)

Come to think of it, the number of lines might be reduced a bit, like this:
2 get position minus 512 plus (written on one line rather than two)
Could the arguments 0 max and 1023 min be combined on one line in the same way?

Hello,

One thing you could do is remove all of the min/max commands, since the servo controller takes care of that for you. As long as you don’t try to set the servo position to zero or a negative value, it should do exactly what you want automatically.

-Paul

Also, (x - 512)*4 + 4000 = 4*x + 1952, so you could get exactly the same results with something like

1 get position
2 get position plus
4 times 1952 plus
0 servo

-Paul