Maestro 18 pwm script

Hello.
I have a maestro 18 servo controller, i need to control the pwm (pin 12) using a potentiometer in a input pin, my programing knowledge is very very low and i don´t know how is the script.
someone can put some example???
thanks.

Hello.

We do not have example code specifically for controlling the PWM output of the Mini Maestros with a potentiometer. However, you could modify the “Using an analog input to control servos” example script, which can be found under the “Example Scripts” section of the Maestro user’s guide, to enable and change the parameters of the PWM output channel on your Maestro based on the input from your potentiometer. You can learn more about the PWM command under the “Command Reference” section of the Maestro’s user’s guide.

If you try making a script and have questions or problems, you can post the code here, and I would be happy to help.

- Amanda

Amandas thanks for your help.
I took the script example for servo, but does not work.
Sorry but my knowledge of programming are really very low, maybe if you could elaborate a simple example then I can try changing values.
Thank You.

begin
  1 get_position    
  4 times 4000 plus 
  12 PWM
repeat

I added [ code ] tags to your script to make it easier to read; please use this method to post code in the future.

I am not entirely sure why you used a value of 12 for the PWM period, but it seems like you are intending to use 12 to indicate the channel of the PWM pin, which is unnecessary, since there is only a single PWM pin on each of the Maestros, so you should not need to specify which channel it is on.

I modified your code to use a larger period and tested it with a Mini Maestro using an LED on the PWM channel, and a potentiometer on pin 1, and it worked for me. I used a larger number because the period needs to be larger than the onTime value (or pulse width). Here is the code:

begin
1 get_position 
4 times 4000 plus   #calculate onTime based on potentiometer value
16320 PWM    #set period
repeat

By the way, if you were confused about how to use the PWM command, the “Command Reference” section explains how each command uses values on the stack.

- Amanda

Thank you so much Amandas.
I could understand all well and works perfectly.