Advice needed on a micr maestro

I have been using the micro Maestro to control my dc motor speed control (servo). Im using a pot to control the speed and its been working flawlessly. So my question now is, now I would like to control the same servo with 2 remote (mom) switches and the pot all inline. Overall im looking to have one switch run the motor in full speed only when pressed and the other switch to run the motor at half speed only when pressed. So far i have been testing ways to add these switches. I added a diode inline on the pot, and switches output wire to stop feed back. I made #1,#2 and #3 position inputs on the maestro and that seems to work. im limiting the speed with resistors on the second button. I would like to know if there is a better way of getting this done or is this the best way.

This is the script im using.

  # Sets servo 0 to a position based on an analog input.
begin
  1 get_position    # get the value of the pot, 0-1023
  4 times 4000 plus # scale it to 4000-8092, approximately 1-2 ms
  0 servo           # set servo 0 based to the value
repeat

Any input would be great

Thanks

Tom

Hi Tom,

We just talked on the phone about this, and I think I understand what you want. I recommend that you disconnect the diodes and extra resistors in your circuit and connect the switches only to Maestro inputs 2 and 3, following our recommended wiring diagram for a switch. With each part connected independently to the Maestro, you can control all the details with your Maestro script. Here is a guess at what the code should be:

# Sets servo 0 to a position based on an analog input.
# A button on channel 2 sets the output to 2 ms independent of the pot.
# A button on channel 3 sets the range to approximately 1-1.5 ms. 
begin
  button_a if
    8092 # full speed if button a is pressed
  else
    1 get_position # get the value of the pot, 0-1023
    button_b if
      2 times # 50% range (scaled to 0-2046)
    else
      4 times # full range (scaled to 0-4092)
    endif
    4000 plus # offset to bring the value into the 4000-8092 range, approximately 1-2 ms
  endif
  0 servo # set servo 0 based to the value
repeat

sub button_a
  2 get_position 500 less_than
  return
 
sub button_b
  3 get_position 500 less_than
  return

I have not tested this, so there are probably some bugs in it. I recommend looking it over and stepping through it in within the Control Center until you understand exactly how it works. If you modify it and have further questions, please post your entire code here, using the “Code” button to format it nicely.

Good luck!

-Paul

thanks Paul,

i will update you with the results.

Tom

after we figured out what i exactly needed, the micro maestro works like a charm. thanks to Paul and his great help my project is looking at a brighter future. this scrip enabled the use of two buttons and a pot to control one servos movement.

thanks again

Paul

begin

button_a if
8092 
else
button_b if
6000
else
1
get_position
4 times 
4000 plus 
endif
endif
0 servo 
repeat

sub

button_a
2 get_position 500 less_than
return

sub

button_b
3 get_position 500 less_than
return