Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Model Train Switches

Hello,

Please be patient…
Very much a novice don’t know much about electronics
however I do know what I want to do and it all points to the Maestro 18
I want to control individual servos for switcher tracks on my train layout.
that being said I am having trouble understanding the wiring diagram because I am so new
Here is what I have:
Single pole Double Throw Toggle Switches 3 Prong
Maestro 18 Assembled
1-100 ohm resisters
Mini servos 3 pin
6 volt in wall power cord
Looking for step by step instruction

I think I have what I need just don’t know how to assemble it

Hope someone can help many thanks in advance!
John “remember I am really a novice”

Hello, John.

I suggest starting slowly, such as just getting one switch connected and seeing the associated channel in the Maestro Control Center respond when you put it in the different positions. The first thing you will want to do is choose a channel for your switch and set the mode of that channel to “Input”, which you can do in the “Channel Settings” tab of the Maestro Control Center. Then, you can connect the switch to that channel.

It sounds like you have a 3-position switch; do you need the Maestro to uniquely register all three positions or just switch between two?

If you only need the Maestro to register 2 positions, you can connect the 3-position switch, you can connect it as we show under the “Button or switch” heading of the “Attaching Servos and Peripherals” section of the Maestro user’s guide. Note that we recommend using a resistor between 1kΩ and 100kΩ (10kΩ is common).

Brandon

Thanks BrandonM
The toggle switches i have and would like to use are only 2 position with three leads under to connect to.
I just don’t know how it all connects together
since i know the 3 pins for the servo go to Channel O on the Maestro
where does the switch and resistor connect to?

Did you read through the “Button or switch” heading of the “Attaching Servos and Peripherals” section of the user’s guide that I linked to in my previous post? The diagram in that section shows how to connect a switch.

You can use a multimeter to check continuity of your switch to figure out how it behaves when it is toggled. With 3-position switches, the middle prong is typically connected and disconnected from the prongs on the either side of it as the switch is toggled. So, if that is the case, you could connect the middle prong of your switch to the signal pin of your Maestro channel, and one of the outer pins to the ground (GND) pin. Then, you would connect your pull-up resistor between the same signal pin and one of the available 5V pins on your 18-channel Maestro.

If you are still not confident about how you are connecting the switch, you can post a picture of your setup with it connected how you think they should be (before you apply power) and I would be glad to take a look.

Brandon

Continuing
Good Morning BrandonM

the Switch is a single pole double throw switch

it has two (2) “ON” positions (right and left)
nothing in the middle / there is no middle position

I will experiment more this weekend with everything you suggested
any other thoughts u have i will listen

Thanks so much John

Good Day BrandonM
So this weekend I will have all the parts assembled to hopefully attached to switch and the resistor to Channel 0

And according to your direction I will then watch what it does when I flip the switch back and forth

So my next question will be to control the servo that let’s say is on Channel 9 I’m assuming that’s in the programming if this is the case that songs a lot of my questions on how to wire the servo in which I assume is a three plug plug-in?

Yes, you should be able to see the associated slider in the “Status” tab of the Maestro Control Center reacting to the switch if it is connected correctly. Note that you will also have to configure that channel as an “Input” in the “Channel Settings” tab.

The “Attaching Servos and Peripherals” section of the Maestro user’s guide that I linked to in my previous posts has instructions for connecting a servo. You can attach the 3-wire servo connection to the desired channel, making sure it is in the correct orientation.

Please note that you will need to connect your servo power supply as well. You can find multiple methods for powering the Maestro and your servos in the “Powering the Maestro” section of the Maestro user’s guide.

Brandon

So I’m following so far and getting better acquainted with everything just one last question before I try it

You saw my switch it has 3 leads and 2 positions (on and on) do I use the two ends or one end and one middle?

And the resistor goes on the power side NOT the ground?

I wait you response

And have a great weekend

Thanks!

John DiGiacomo

As I mentioned in my previous post, most switches with 3 leads will toggle connecting the middle lead to either outer lead, but you should do a continuity check with a multimeter if you are unsure. Essentially, you just want to find two leads that are connected in one position, and not in the other.

The resistor should go from the input channel’s signal pin to a 5V pin on the Maestro; then the switch goes from that same signal pin to ground. When the switch is off, the voltage at the signal pin will be high (5V) and when the switch is on, it will be low (0V).

Brandon

Thanks Brandon so here’s my next question

Once I have everything hooked up and hooked up correctly hopefully question what tells the switch on Channel 1 to operate the servo on Channel 9?

As always thanks John

Once you can verify that the switch works correctly, you can start writing your script. This is what reads the switch and decides what the servo position should be. To get a better understanding of the Maestro scripting language, I recommend reading through the “Maestro Script Language Basics” section of the Maestro user’s guide, then looking over the “Command Reference” and “Example Scripts” sections.

If you get to the point where you are trying to write a script and have questions, please post the script you have so far or what particular part you have questions about.

Brandon

Ok

Something is terribly wrong with the switch wiring

Resistor became really hot

Smelled it first then touched it

Very hot

Sent you pixs

Any suggestions

John DiGiacomo

ok Brandon,

First I hope the reply finds you all well??

Great news!

The switch is wired and the parameters go from Less than 3 to 255 as suggested
now I have the switch on channel 0 as an input and the servo on channel 6
I just can no get it to move at all.

I want it to go extreme left toggled one way and extreme right toggled the other way.
took a break for now awaiting your suggestion and I read threw the code and had to stop wasn’t getting it yet.
but I will eventually

Thanks again John!

Hello, John.

It sounds like you got the switch working now (hopefully nothing was broken when it was not working properly).

You will essentially want your script to check the switch, then use an “if” statement to send the servo to one of the positions based on the switch reading. The main commands you will use to do this are as follows:

BEGIN
GET_POSITION (to read the switch)
IF, ELSE ENDIF
SERVO (to command the servo)
REPEAT

You can read more about these commands in the “Command Reference” section of the Maestro user’s guide. I suggest trying it out yourself by using the “Script” tab of the Maestro Control Center. The “Step Script” button at the bottom is very useful for stepping through the code one line at a time and getting a sense for what each command is doing.

Brandon