Need help adding switches to control R2D2 periscope raise / lower mech mini Maestro 12

Hello All
I have a mini maestro 12 channel board, which has 2 speed controllers with motors connected to it.
by using delays i am able to raise , rotate & lower the Periscope . Motor 1 raises & lowers & motor 2 rotates left & right.
as i am using delays to achieve this, it is not very reliable & i am getting unpredictable results.
My only issue is the raising & lowering parts of the sequence. The rotating works 100% fine.
After speaking with Derrill in support ,who’s been very helpful, he suggested using a couple of limit switches to control the raising & lowering.
I have read the sections on adding switches etc, however as i don’t want to destroy anything i wondered if someone had already achieved this or had any advice on how best for me to proceed.
Is there a diagram for the 12 showing where to attach the resistors , I see the 6 is shown, again not wanting to break anything.
I think to achieve what I need will mean multiple sequences but that is ok , plus I would like to put a 30 minute delay between the script. I think if the periscope was to run at 30 minute intervals would be good.

I am looking for some advice and guidance how to add the switches & resistors & how to build the script correctly.
I haven’t programmed a servo board before so keen not to break anything.

My plan is for the motor to raise the periscope to a sufficient height, then have the first switch activate & stop the Periscope from raising further, by switching off the motor, then after its rotated back & forth, the Periscope lowers , once it reaches the bottom of the mechanism the second switch will active and switch the motor off again, hopefully ready to go again.
I have added a video of the periscope in action from my YouTube Channel.
This was taken before i replaced the servo used for rotating with the second motor & speed controller. I wanted a smoother rotating action, which i now have…

Many Thanks

Hello, Paul.

We do not have a wiring diagram showing how to wire a switch to the Mini Maestro 12-Channel servo controller. The wiring diagram example for the Micro Maestro (shown under the “Attaching Servos and Peripherals” section of the Pololu Maestro Servo Controller User’s Guide) should work for the Mini Maestro. If you do not know where the 5V output is on the Mini Maestro 12-Channel, see the “Mini Maestro 12 power pins” picture under the “Pictures” tab on its product page.

As for your script, I recommend that you look at the “Using a button or switch to control servos” example under the “Example Scripts” section of the user’s guide and try to merge that script with yours. If you try that and have problems, you can post your modified code here, and I would be happy to take a look.

- Amanda

Hi Amanda
I located where to add the resistors thanks for you recommend any specific ones for the board ?

regarding adding to the script , i haven’t coded anything like this before so wasn’t sure & didn’t want to break anything.

my main concern was that when the periscope is at its resting/starting point one of the micro switches will be closed.

I am probably over complicating it, as all i am trying to do is add a stop at the top & bottom of the mechanism.
plus using speed controllers with motors instead of servos.

I am assuming i should use the multiple button example script & modify it for 2 buttons & copy it into my script.
The only confusing part is that according to the multiple button script, it is made up of multiple sequences instead of my current script which is one sequence.
my sequence is a raise with channel 0 , then a pause , then rotating with channel 1 , then pause, then lower with channel 0 again then a large pause (30-45mins is what i am looking to set) .
I just have to ensure the switch /stop additional code is in the correct place . happy to run some tests , but as a safeguard will remove the periscope & just test with the bare mechanism.

My final question is what is the best way to manipulate the script , as the only way i have been able to look at & make minor changes is when the board is plugged in to my USB & i am running the maestro control software.
Apologies if i my reply sounds over complicated .
many thanks for responding

I located where to add the resistors thanks for you recommend any specific ones for the board ?

The wiring diagram example gives a range of pull-up resistor values (1-100 kilo-ohms) that are suitable to use when connecting a switch to the Maestro (both the Micro Maestro and Mini Maestro versions).

The only confusing part is that according to the multiple button script, it is made up of multiple sequences instead of my current script which is one sequence.

The “Using multiple buttons or switches to control servos” example script simply checks for the status of a switch on a channel specified in its subroutine (e.g. button_a) and executes the associated sequence based on that status. You will probably want to separate your sequence into the two main events (moving the Periscope up and moving the Periscope down). It would not make sense to have both events do the same thing. Then, the Periscope’s turn sequence can be added after or before the Periscope has finished its moving up or moving down sequence, respectively.

The easiest way to create and modify a Maestro script is using the “Script” tab in the Maestro Control Center. I recommend that you use the multiple button example script as a template and modify it slightly by adding one event at a time.

- Amanda

Hello Amanda
After much consideration , I decided to go a different way with controlling stopping the motor.
instead of using the script & adding 10K resistors to the board, I added 2 micro switches to the mechanism, one at the bottom & one at the desired height, both have a diode on to act as a non return valve. They are wired directly to the motor & speed controller.
this takes all the control away from the Pololu board.
I decided to do it this way as its easier to swap out a Pololu board in the event of a failure.
all I had to do with the script to fix my initial problem was to increase the time on the Raise frame.
It works great & have had it on a loop for 3 hours!.
Here’s a video of it in operation, if you compare to the older video above you will see I have replaced the servo with a motor & speed controller for the rotating. I did this as I wasn’t 100% happy with it initially.

I have one final request, as R2 wouldn’t be putting the periscope up every couple of minutes, I wondered if someone could show mw how to add a 30plus minute delay to the end of the script , before it repeats.
I am looking at testing 30-45minutes as the delay. I think this will make R2 look quite realistic.
The 12 Channel board does a brilliant job.
Many thanks, I will be buying more of them :smile:

1 Like

There is an example script titled “Long Delays” under the “Example Scripts” section of the Maestro’s user’s guide that shows how you can create delays of many seconds, minutes, and hours in a Maestro script. You might consider using the “Step Script” button, which can be found under the “Script” tab in the Maestro Control Center, to step through the “Long Delays” example script and get a better understanding of how it works.

- Amanda

Hi Amanda
I added the 10 minute routine and modified it for 30 , 40 & 45 minutes.
I must say what a good example it is too.
looks great , tested & watched it count down in the stack from within the control centre,
again many thanks .
R2 Periscope is now fully automated & completed .

1 Like