Script Help

I am a 110% noob when it comes to programing.

Now that is out of the way … I am about to have ACDF surgery in a couple weeks and I need to set up an automated pitching machine that shoots mini wiffle balls as goalie practice with my son while I am recovering.

I have the Micro Maestro 6 and when I use the below example script (tweaked for my endpoints) The servo I have goes nuts … I have created a script that goes from 3000 - 8000 but it is way to fast moving back and forth… I just need need the servo to go from 3000 - 8000 with the ability of adjusting the speed and acceleration. Ideally a randomizing speed and acceleration would be perfect. This will be used to adjust the angle up and down for 1 servo and left and right for another to simulate the balls being shot at different parts of the net.

Thank you all !

# This example uses speed and acceleration to make a smooth
# motion back and forth between 1 and 2 ms.
3 0 acceleration
30 0 speed
 
begin
  3000 5 servo # set servo 0 to 1.00 ms
  moving_wait
  8000 5 servo # 2.00 ms
  moving_wait
repeat
 
sub moving_wait
  begin
    get_moving_state
  while
    # wait until it is no longer moving
  repeat
  return

Hello.

In the future please put your code inside [code ] [/code ] tags (without spaces) to make it more readable. One problem with your code is that you never actually set an acceleration or speed limit for channel 5. Another potential problem is that you were commanding the servo to go to 3000 (750 microseconds). I don’t know what you configured the Min and Max pulse widths to be for your servo, but if you command a servo to go outside of its allowed range on the Micro Maestro 6 then your moving_wait function will loop infinitely. A good way to avoid this is to just make sure you are commanding the servo to go to a position that is greater than the Min you configured in the Channel Settings tab and less than the Max you configured in the Channel Settings tab.

Please try this script:

3 5 acceleration
30 5 speed

begin
  4000 5 servo 
  moving_wait
  8000 5 servo
  moving_wait
repeat

sub moving_wait
  begin get_moving_state while repeat
  return

–David

I tweaked it a bit and it works great. Thank you very much. I am now wondering how to make the 2 servo move as well? would it be a sub script too? Thank you again

For every line that does something to servo 5, try duplicating the line, putting the duplicate right below the original, and changing the “5” to a “4” in the duplicate. Then your script should do the same thing to servo 4 that it is doing to servo 5.

–David