Home | Links | Contact |

Printed from www.nzmeccano.com

Top Home Bottom

The Little Tram

(Author: David Couch)

An introductory Arduino project

The Little Tram

An introductory project for Meccano and Arduino
by David Couch

 

Fig. 1 The Little Tram approaching a stop

 

Introduction

I have previously written, and published on the NZ Meccano web site, three documents giving an introduction to the Arduino microcontroller, a detailed description of how to buy and build a recommended system, and a programming reference. In this document I describe a model which is an example of control of a Meccano model by an Arduino. I have kept the model and program as simple as possible, but I add some suggestions for ways in which you might add extra detail once you have got the basic model working.

The model represents a tram running on rails, which can be as long as you wish, and a shelter which houses the Arduino system. The tram runs back and forth along the track, pausing at each end.

Requirements

You do not need any prior knowledge of either electronics or Arduino programming to build this model. You do need to have installed the Arduino and motor shield software on your computer and got to the point of loading and running the "blink" example sketch, as described in my document.

Components you will need, in addition to standard Meccano parts, are:
• The Arduino system described in my document, consisting of an Arduino Uno R3 or Mega 2560, a motor shield and a terminal shield
• A suitably cut and drilled piece of Perspex, thin ply or thick card to mount the Arduino
• A small electric motor (see below)
• Two small magnetic switches of the kind used on windows and doors as part of a security system, such as this
• A 4mm plastic knitting needle (UK no. 8, US no. 6)
• M3 and M4 screws, nuts and washers, including nylon ones
• Hookup wire, cable ties, a rubber band and a spring from a ball-point pen.

Building the tram chassis

The tram uses a two-rail power supply, which means that the rails and wheels

Fig.2 The chassis seen from the grounded side

on opposite sides must be insulated from each other. One side will be described as "live" and the other as "grounded".

The chassis of the tram is shown in figs. 2, 3 and 4. It consists of two 5½" zinc-plated Strips connected by a Double Bracket at either end. The Double Brackets are placed with the centre section upward. On the grounded side standard Bolts are used, and two Washers are inserted between the Strip and the Bracket on

Fig. 3 The chassis seen from the live side

each bolt. On the live side 4mm nylon screws, nuts and washers are used. The axles are 2" lengths cut from a 4mm plastic knitting needle. The wheels are 1⅛" Flanged Wheels. Each Wheel is fitted with two Grub Screws, and they are tightened just enough to grip the axle, so as not to distort it. A small piece (about one turn) cut from a ball-point pen spring or similar is placed between each Wheel and the chassis to give better electrical contact. A 1" Pulley is fixed to the centre of one axle.

The tram is driven by a small electric motor mounted above the chassis. I used an NZMecc no. 1 400 rpm geared motor from Stan Baker. It is held between a Double Bent Strip and a 1½" Flat Girder. A Bolt held by a Nut in the centre hole of the Flat Girder clamps the motor in

Fig. 4 The chassis seen from below

position. The Flat Girder is bolted to a 3" Strip which is attached by Angle Brackets to two vertical 1½" Strips bolted to the chassis. The motor is further constrained by Angle Brackets held by the Bolts attaching the Flat Girder to the 3" Strip. A ½" Pulley on the motor shaft drives the 1" Pulley on the axle via a rubber band. One motor lead is connected to each chassis Strip by a Bolt, Nut and Washer.

The magnet part of one of the magnetic switches is attached by an M3 screw and nut to an Angle Bracket, which is bolted to the grounded side chassis Strip and spaced with Washers so that the magnet is positioned under the centre of the chassis.

The rails

Fig. 5 A rail joint

The rails are zinc-plated Angle Girders placed 2" apart. They are supported by suitable bases, such as 3½" x 2½" Flanged Plates. The grounded rail is bolted to the base with a Washer for spacing on each Bolt. The live rail is attached by M4 nylon screws and nuts with a nylon washer between the rail and base. To make longer rails, Girders are butted together and joined by zinc-plated Strips placed on the outside. See fig. 5.

The switch part of a magnetic switch is attached to the base, centred between the rails, a short distance from each end of the rails. The magnet on the chassis should just clear the switches.

Preliminary testing

At this point the chassis can be tested by connecting a suitable power supply to the two rails and placing the chassis on the rails. If it runs erratically, clean the top edges of the rails and the rims of the Wheels with a piece of fine emery paper or sandpaper. Also check that the small springs are lightly compressed between the Wheels and the chassis to make good contact.

The tram body

Fig. 6 Another view of the tram

The design of the tram is taken from model no. 3.5 in the 1958 no. 3 Outfit manual. It is built exactly as described, except that the Flanged Plate, axle supports, axles and wheels are omitted. The construction should be evident from figs. 1 and 6. Two 2½" x ½" Double Angle strips are bolted between the ends of the lower 5½" Strips, and then bolted to the Double Brackets of the chassis.

The shelter and Arduino

Fig. 7 The shelter and the Arduino

The base of the shelter consists of a 7" x 5½" rectangle of strips connected by Angle Brackets. The floor is two 5½" x 3½" Flat Plates, also attached by Angle Brackets. The rails are attached to the floor as described above and shown in figs. 1 and 7.

The Arduino, without the shields, is attached to a suitably cut and drilled piece of Pespex, thin ply or thick card with M3 screws and nuts and 38B Spacers. This mounting is in turn attached to the Flat Plate with Bolts spaced by two Washers, and positioned so that cables can be plugged into the USB and power sockets. The shields can then be inserted into the Arduino.

Fig. 8 The rear of the shelter

Connections are made as follows. A suitable power supply for the motor is connected to the power input terminals on the motor shield. The VIN jumper on the motor shield is removed. If the Arduino is to be powered by a battery, wires are connected to the VIN and GND terminals on the terminal shield. (If the Arduino is to be powered by a plugpack power supply or from the USB cable these can be connected later.) Wires are connected between the M1 motor terminals on the motor shield and the two rails. One wire from the near magnetic switch is connected to pin 4 on the terminal shield, and one from the far switch to pin 5. The other wire from each switch is connected to the GND terminal. The wires for the far switch are neatly attached to the rails with cable ties.

The construction of the rest of the shelter should be evident from figs. 1, 7 and 8. Note the slot to allow the cables to be plugged into the Arduino.

Loading the Arduino program

To obtain the "sketch" or program, please send me an email message at
david.couch46@gmail.com. I will send you a file named tram.txt. Save this file to your hard drive, and then open it with Notepad or another editor. (It does not matter that the text is not correctly formatted in Notepad.) Press Ctrl and A to select the entire text, then press Ctrl and C to copy it to the clipboard. Run the Arduino program, which will open with just the minimum code to allow you to create a new sketch. Press Ctrl and A, and then Delete, to delete all the code in the code space. Press Ctrl and V to paste the new sketch in. In the tool bar click the first icon (a tick mark in a circle) to check that the code compiles correctly. You will be prompted to enter a name for the new sketch. Type the name Tram in the File name space and click Save. In future, when you run the Arduino program you can load the Tram sketch by selecting Sketchbook in the File menu and then Tram in the sub-menu.

With the Arduino connected via the USB cable, click the Upload icon (the second in the tool bar, a right arrow in a circle). If the sketch uploads successfully it will then be running in the Arduino. It will also be saved in the Arduino's flash memory, so you do not need to upload it again unless you modify it.

Testing

Connect the power to the motor shield and put the tram on the rails. The tram should soon start to move, and stop when it reaches the switch. If it goes right past the switch it may mean that the sketch is checking the wrong switch. Try swapping the two connections to the rails.

If nothing happens at all you can see what the sketch is doing by running the serial monitor. In the Tools menu select Serial Monitor. At the bottom right of the monitor screen check whether the speed is set to 115200 baud. If it is not, select 115200 from the drop-down list. You should then see the messages from the sketch appearing at intervals. If necessary reset the Arduino, or close and restart the serial monitor. To test the switches, hold the spare magnet next to each switch.

Modifying the model and sketch

Once you have got the basic model working you may like to add some more features to the model and modify the sketch to make them work. Here are some suggestions. My reference document tells you how to control the additional devices.
1. Make the tram wait for a random time at each stop. (See the random() function in the Arduino reference.)
2. Add another stop with another switch and make the tram stop there - sometimes.
3. Add a set of traffic lights using bright LEDs, and make them change regularly. Then make the tram obey them.
4. Add a barrier or lifting bridge, powered by a motor or servo, which is raised and lowered as the tram approaches and leaves.

Feedback

I would really like to hear from you if you build this model, and will do my best to help if you have problems. Please send email to david.couch46@gmail.com

 

If you have any interesting information or comments about this page, please add them here:


Your name:
Your message:
Security check: (Please type in the text to prove you're a person!)
 
Login status:  You have not yet entered your user name and password. You cannot create or edit documents until you do.
Enter your user name and password to log in

Remember me

If you click on the box marked 'remember me next time', you will not have to log in again on this computer for three months.

If you don't have a user name yet, please click here

On this page...

Latest documents:

 
A G gauge model 
(Colin Bull & Richard Smith)
Midlands Meccano Guild
99th Meeting Model Report 
 
98th Meeting Model Report 
 
97th Meeting Model Report 
(David Couch)
The Little Tram
An introductory Arduino project 
(G. Eiermann and M. Schild)
A Short History of MARKLIN Metall
 
96th Meeting Model Report 
83rd Meeting Model Report 
 
82nd Meeting Model Report 
Picks up three golf balls 
(Roger Marriott)
Midlands Meccano Guild
95th Meeting Model Report 
The Spanner Challenge 
 
 
 
94th Meeting Report 
(Andre Theberge)
Meccano Segway
Instructions 
(Andre Theberge)
A Meccano Segway
Arduino code 
(Andre Theberge)
A Meccano Segway
Assembly instructions 
(Michael J. Walker)
Meet the new MMG President
Geoff Wright 
The Spanner Challenge 
(Michael Walker)
Midlands Meccano Guild
93rd Model Report 
Report by Michael J. Walker. 
92nd Model Report 
(Stan Knight)
Minimal Meccano
Pocket Meccano Sets of the 1970s 
Little Lever, Bolton 
The Spanner Challenge 
91st Model Report 
(Bob Thompson)
Back to the beginning
Shop Display Model 
90th Meeting Report 
(Old Blue Gold)
Getting Old
A screwy story 
The Spanner Challenge 
Model report written by Michael J. Walker 
76th Meeting Report 
Exhibition in Nelson, New Zealand 
(Barry Gerdes)
Meccano Radio
 
 
How to flatten  
(Rod Socket)
Dear Mrs Spanner
Survival techniques for the Meccanoman's wife 
(Stan Knight)
The Top Ten Tools
Indispensable Tools for the Meccanoman 
A call for help 
The Spanner Challenge 
 
For small brass and nickel parts. Also for stripping paint and rotted zinc plating. 
(Stephen Heafield)
Waterslide Transfers
Refurbishing 0 & 00 Aero Models 
Construction details 
or Put Your Hammer Away 
Mobile Morris Crane from 1968 MM 
Bert Love's Blocksetter in colour 
The dangers of internet auctions 
(Rob Thompson pp Terry Bullingh)
BlockSetter Tower
Built by Terry Bullingham 
(Rob Thompson pp John Reid)
Captain Robert Falcon Scott
1912 Polar Sledging Party 
(Niels Gottlob)
Bucket Wheel Excavator
Transcribed from typed document with photos 
Selected Spanner messages 18th to 24th January 
Selected Spanner messages 11th to 17th January 
Selected Spanner messages 4th to 10th January 
 
(Norbert Klimmek)
Hulett Ore Unloader
A 1 to 32 Scale Model 
 
(Joe Attard of Malta)
A model ship
 
 
 
(Arup Dasgupta (ISM 652))
My E15R Motor
A repair story 
(Charles)
About Meccano
What is Meccano? 
Thoughts about modern Meccano 
Some hints and tips 
Not many in this condition I'll bet! 
 
 View all | Chat | Models | Hints and Tips | Opinion | Reviews | Mine