I need some help/advice on how to get a switch to work with the 6 channel Maestro. None of the examples seem to work for me!
I have a simple script that runs three frames, I want to add a switch to change the order of the frames.
Seems simple enough but I can’t get it to work. . I have added a switch to channel 2 with a resister as described in the manual. It reads 255.75 or 0.75 via the status tab and works correctly.
What scripting do I need to get the switch to do what I want?
basically just need how to get the switch to operate.
CAN ANYONE HELP, I AM DESPERATE AS I HAVE A DEMO PROJECT DUE THAT IS SUPPOSED TO PROVE THAT THE 6 CHANNEL MAESTRO WORK FOR A BIGGER PROJECT.
Here is copy of the stand alone code without the switch that works for the proper servo actions (does not switch order of servo).
It looks like you have done everything except reading channel 2 (where you have your switch connected). To do this, you can use the GET_POSITION command. For example, you can check the state of the switch on channel 2 by using “2 get_position” in your script. Then, you can compare this to a value between the two states of your switch to see if it is above or below. This can be done with the “LESS_THAN” or “GREATER_THAN” commands. Since those commands will return a 1 or 0 (depending on the state of the switch), you can put your if statement directly after it. You can find more information about the scripting language commands in the “Command Reference” section of the Maestro user’s guide.
If you try adding this to your script and need additional help, could you post the script you have so far?
Thanks for your help. I spent more time than wanted but I have the following script running without errors. If you see something I omitted or that can removed, please let me know.
Here is the working script commands:
I am glad you were able to get it working. Thank you for sharing your script. It looks like you only use channel 0 and channel 1, so you can probably get rid of the first four lines in your “fram_0…5” subroutine, along with the four zeros in the first line of your script. Setting the servo channels to 0 is just disabling them; if you are not using servos on those channels, you can omit those lines.
By the way, I noticed you are using 100 when you are checking the state of your switch. This will probably work for your application, but it might be good to point out that the values you see for an input channel in the “Status” tab (0-255) correspond to numbers from 0 to 1023 in your script. If you wanted to use a more centered number, you could try something around 500.