MENU

Fun & Interesting

Controlling turnouts with servo motors from JMRI with MQTT

T-TRAK U-TUBE 3,000 lượt xem 4 years ago
Video Not Working? Fix It Now

This video shows how I am controlling turnouts with servo motors connected to a NodeMCU ESP8266 which is similar to Arduino devices.

Turnouts are controlled using JMRI which means you can just tap a layout diagram on your phone to throw the points.

Communication between JMRI and the NodeMCU is MQTT (messaging) over TCP/IP using the NodeMCU's inbuilt WiFi so the only wires to it are DC power.

This does not use DCC. It is totally independent of track power. Although it uses JMRI, it can be used on any DC or DCC layout. It does not use DCC stationary decoders for the turnouts. Of course, you can add a DCC connection to run your trains.

Timestamps to fast forward
00:00 Into
00:37 The test track - 2 half=depth, triple length T-TRAK modules
00:55 Fitting a servo
01:37 The NodeMCU - the brains driving the motors
04:01 About MQTT
05:59 Getting it working with JMRI
08:56 MQTT Explorer - watching the messages
11:51 Wrap up - what you get for less than $20

Equipment:
- 9g servo motors - NodeMCU ESP8266 controller, now superseded by ESP32
- PCA9685 16 channel PWM servo controller
- SPDT microswitches (for frog polarity)
- servo mounting bracket - I've designed and 3D printed my own
- 5V and 6V power supplies. You can probably use one power supply though the servos create "noise" on the power which may impact the NodeMCU. You can smooth the power with a capacitor but "best practice" is to use separate power supplies.

Software:
- JMRI. Note: At the time of creating this video, JMRI (version 4.19) on Windows computers requires JMRI to be run as administrator for the MQTT connection to be established. I normally use Linux systems so haven't had that issue.
- MQTT broker. I use and recommend Mosquitto, This can run on the same computer as JMRI or any other of your choice. It is a light weight messaging system so will happily coexist with JMRI
- Sketch for the NodeMCU.

The test track being used has 5 Peco electrofrog turnouts with Peco flex track. The base is two triple length, half depth T-TRAK modules, hence the short lengths of Kato Unitrack at the ends. I have run big locos with 60ft container wagons and little shunters (switchers) with underweight 4 wheelers through all these turnouts with all going very smoothly through. So that's a gold star for the test, now to progress to my main yard.

The set up as demonstrated costs about $17 Australian or about $3.50 per turnout which includes the servo motor, microswitch and the controller boards. I have not included the cost of power supplies because there are many way of doing this and each person's situation is different.

I use a 12VDC power bus with a cheap buck converter to drop this down to 6VDC for powering the servo controller and servo motors. I use a separate 5VDC power supply for the NodeMCU. If you have a big demand for DC power, using a computer power supply is worth considering to give you several different voltages and lots of amps.

I give a big thank you to Speed Muller for his guidance through this. It is not my invention.

Comment