Rotating arcade monitor

I’m not getting far in my programming efforts, have the micro maestro 6 channel usb servo controller. Have a dc 6volt power supply wired to the board. 1 servo is connected to channel 1 (plug for power was too wide and couldn’t use channel zero) have two switches wired with the pull down resistors as limit switches configured as inputs on channel 2 and 3 for a rotational limit horizontal and vertical position. My cry for help is in programming I’m a good mechanical designer and the wiring and setup is in my wheelhouse but not the programming. I am lost and beg for any help I can get! Thanks in advance!

Hello.

I moved your thread to the “Servo controllers and servos” section of the forum.

Typically, you do not need external limit switches when using a standard servo since they use position control, but it could help in certain situations. Are you using a standard servo or a continuous rotation one?

If you are using a continuous rotation servo (or just want to use limit switches), we should confirm that your switches are working correctly before doing any programming. In particular, you mentioned adding pull-downs to the switch inputs; please note that if you are using normal switches, you will need a pull-up resistor instead (since the 6-channel Micro Maestro does not have built-in pull-ups). You can find more information about this in the “Attaching Servos and Peripherals” section of the Maestro user’s guide.

Once you switches are set up, can you confirm that they are working as expected by monitoring the “Status” tab of the Maestro Control Center? You should see the indicator ball move from the right side to the left side of the slider when the switch is pressed.

Brandon

Switches are working, I can get the model of the servo but it is limited to 90 degrees rotation (little more each way) the position control was not precise enough and would go a little short or a little past the mark when rotating to a specific spot and the servo would “talk” as it’s trying to get to it’s correct location. I wanted the limit switch so it would stop at that spot

Just to clarify, how are you wanting to trigger the Maestro to move the monitor to the other position (e.g. button, switch, through USB from your computer, etc)?

Brandon

Yes, a routine to rotate the monitor clockwise or counterclockwise until the limit switch is engaged. The switch is wired normally open and goes to zero when pressed

As I mentioned before, I generally expect this to be achievable without limit switches, and from your description it sounds like your servo might be underpowered for the task. However, if you want to try it here’s what a subroutine to increment the servo position until the limit switch is triggered might look like

sub rotate_vertical
  begin 2 get_position 512 greater_than while    #while the limit switch on channel 2 is open
    1 get_position    #read the position of channel 1 
    1 plus                    #increase it by 1
    1 servo                 #update the position
  repeat
return

However, before blindly running this script, please note that I picked an arbitrary direction/limit switch combination. If your servo does not move toward the channel 2 limit switch when the position increases (i.e. 1000 → 2000), you will need to adjust it. For example, you can change plus to minus.

Also, please note that the Maestro will respect the min and max limits configured in the “Channel Settings” tab of the Maestro Control Center. So, you might need to adjust those so you can get the full range of travel you need if it stops before reaching the limit switch. You can find more information about finding the limits of your servo safely in the “FAQs” tab of the Micro Maestro product page.

It still is not clear to me how you want to trigger the routine, but once that is set up, you can call it from the main loop of your script. Alternatively, you can call the subroutine from your computer by sending a “Restart Script at Subroutine” command. You can find more information about this command in the “Serial Script Commands” section of the Maestro user’s guide. If you trigger the subroutine this way, you should also add a quit command before the return at the end of the subroutine (otherwise it will trigger an error).

Brandon

A good start, rotates monitor in clockwise direction (counterclockwise for solenoid because its inverted under the monitor) but roars right by the switch, i can see it click on the screen and go to zero but dosent stop the sequence. It goes to max rotation i also tried slowing the rotation by adding a line for speed but it didn’t change the speed i had to manually enter speed on the status tab. But thank you for this much its a great start.

Are you sure it is triggering the correct limit switch (i.e. the one on channel 2)? If it is triggering the one on channel 3 instead, you can change begin 2 get_position to begin 3 get_position at the beginning of the subroutine.

As far as slowing it down, since this code increments the position by 1 each loop, the speed and acceleration limits won’t work, but you can effectively slow it down by adding a small delay between 1 servo and repeat (e.g. something like 50 delay, which will delay 50ms).

Brandon

Yes im using the correct limit switch. And i tried changing the plus to minus to reverse direction and it still rotated in the same direction. (Confused me to be honest)