Servo Motor Duplo Train Track Switcher 3775 (B4R,Node-RED)

Experiments & prototyping with the Arduino.
rwblinn
Site Admin
Posts: 224
Joined: 07 Oct 2017, 12:16

Servo Motor Duplo Train Track Switcher 3775 (B4R,Node-RED)

Postby rwblinn » 14 Oct 2017, 12:43

Purpose
Duplo Train Track Switcher 3775 using a Servo Motor controlled by an Arduino UNO connected to a
  • PC via Arduino IDE Serial Monitor and
  • Raspberry Pi via Node-RED.
The solution will be part of a planned Make Project Duplo Train Control.

Parts Needed
  • 1x Arduino UNO
  • 1x Mini-Servo Motor Tower Pro SG90
  • 1x Duplo Train Track Switcher 3775
Wiring

Code: Select all

Arduino = Servo Motor (wire color)
GND = GND (black)
5v = VCC (red)
8 = Signal (yellow)


Circuit
Image

Prototype
Image
The servo moves between 0 and 30 degrees. The servo is connected to the track using a screw 15mm height and 3mm width.
A rubber band enables to handle the direction. The additional holes can be used for LED indication track position left or right.

Download B4R Source Code

Solution PC
The Arduino connects to a COM port. For the initial test, connected to a PC Port COM5.
An asynchronous stream is used to read and handled incoming data via the serial line. The data can be a value between 0 and 30, which is the angle of the track switch. The incoming bytes are converted to an unsigned integer and written to the servo motor.
The Arduino IDE Serial Monitor, connected to port COM5, is used to send values between 0 and 30 to the track switch.

Solution Node-RED
Tested the solution as described, also with Node-RED running on a Raspberry Pi.
The Arduino connects to the Raspberry Pi USB port /dev/ttyUSB0. Hint: check the ports with command ls /dev/tty*.
A simple flow is defined using two inject nodes and a serial out node.
The serial out node has a properties /dev/ttyUSB0:115200-8N1. For other properties, kept the default.
Image
Additional test with Node-RED Dashboard nodes to control the track switch via UI.

Software Versions
Raspberry Pi Raspian v9.1, Node-RED v.0.17.5, nodejs v6.11.4, Node-RED Dashboard v2.5.1

Node-RED Flow

Code: Select all

[
{"id":"fb9b868c.a83b68","type":"serial out","z":"6eb3e321.ba79dc","name":"","serial":"b3caf8ef.980558","x":490,"y":100,"wires":[]},
{"id":"f0811bc4.976c68","type":"inject","z":"6eb3e321.ba79dc","name":"Switch 0","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":120,"y":100,"wires":[["fb9b868c.a83b68"]]},
{"id":"d41b39f0.ec8858","type":"inject","z":"6eb3e321.ba79dc","name":"Switch 30","topic":"","payload":"30","payloadType":"num","repeat":"","crontab":"","once":false,"x":120,"y":140,"wires":[["fb9b868c.a83b68"]]},
{"id":"e75d4c89.e4a87","type":"ui_slider","z":"6eb3e321.ba79dc","name":"","label":"Set Track Position","group":"a8c6acf1.e8654","order":0,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":"35","step":1,"x":140,"y":280,"wires":[["fb9b868c.a83b68","fe560bcd.ab3d68"]]},
{"id":"fe560bcd.ab3d68","type":"ui_text","z":"6eb3e321.ba79dc","group":"a8c6acf1.e8654","order":0,"width":0,"height":0,"name":"","label":"Track Position","format":"{{msg.payload}}","layout":"row-spread","x":500,"y":280,"wires":[]},
{"id":"c0917bf4.4754d8","type":"ui_switch","z":"6eb3e321.ba79dc","name":"","label":"Switch Track","group":"a8c6acf1.e8654","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"30","offvalueType":"num","officon":"","offcolor":"","x":120,"y":340,"wires":[["fb9b868c.a83b68","fe560bcd.ab3d68"]]},
{"id":"9c09336e.9f9d","type":"comment","z":"6eb3e321.ba79dc","name":"Dashboard Train Track Switch","info":"","x":180,"y":220,"wires":[]},
{"id":"a372a4fa.345a88","type":"comment","z":"6eb3e321.ba79dc","name":"Inject Train Track Switch","info":"","x":150,"y":60,"wires":[]},
{"id":"b3caf8ef.980558","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},
{"id":"a8c6acf1.e8654","type":"ui_group","z":"","name":"Shunt A","tab":"b8cec0d3.34b7d8","disp":true,"width":"6"},
{"id":"b8cec0d3.34b7d8","type":"ui_tab","z":"","name":"Duplo RailRoad","icon":"dashboard"}
]


ToDo
  • Experiment is completed.
Version
20171014
Last edited by rwblinn on 22 Oct 2017, 13:11, edited 1 time in total.

Return to “Arduino”



Who is online