OS-Railway is a complete system of track, trains and accessories, all designed to be fully 3D-printable. The size is the same as O-scale (32mm track) but printability is prioritized over scale.
This page covers the Z70 locomotive, for track pieces see a separate page
Klick here for track: http://www.thingiverse.com/thing:2146361
Klick here for cars: http://www.thingiverse.com/thing:2152351
This locomotive was inspired by the Swedish lokomotor Z70 https://sv.wikipedia.org/wiki/Z70 but the dimensions are not strict, the wheel base has been shortened to assure that the train can cope with the rather short radius of 300mm used in my track and switch design. The body has been sculpted to pictures so it is not perfect scale either.
The aim was to create a easy-to-print locomotive that looks OK, but not a super complicated set with tons of parts. The kit includes mounting and pinion gear for using a standard RC-servo as motor. To do this you only need to pull out the potentiometer from the servo, adjust it so that it is in the middle, and then it a RC-signal will act as a dual way speed control. This is a slow but very easy method if you want to use very simple electronics or a radio control.
However, if you want better performance I recommend to use the included Arduino code, a motor controller board and a 16mm DC-motor with gearbox. You can find plenty of such motors on E-bay, or go to www.maxonmotor.com and configure a 16mm motor and gearbox. Direct drive will be too weak so you will need a gearbox.
To power the locomotive, you can either use the chassis which is prepared for batteries, or you can use the one adapted for LiPo-packs. In the first case, 4pcs AAA is used. In the case of LiPo-pack you can use a 2 cell series package (~7,2V).
Look further below for more detailed instructions!
Most parts are designed to be printed without support. The chassi and the body are the only parts on this page that requires support. Please see the instruction pictures for further information.
- There are two versions of the chassi, one with the battery compartment prepared for 4pcs AAA-batteries and another one with an empty battery box if you want to use lipo cells for example.
- Bearing houses are designed for ball bearings 6mm OD, 3mm ID, 2.5mm W.
Screw them in place using M2x3.
- Use M2x4 for the bumpers, if you use longer screws you'll have trouble with the screws for the body. (or you can glue the bumpers in place).
- The body uses M2, length isn't critical, 6-10mm
- Designed for use with 3mm shaft, I use carbon fiber rod. Cut them to 49mm length.
- Placement of the wheels. The track width is 32mm, but you have to leave a gap in order for the train to be able to take the curves, I use 28mm between the inside of the wheels which works fine. The wheels are press-fit, so don't glue them and you'll be able to adjust this if needed.
- Traction is created by using O-rings (or rubber bands) on the driving wheels.
- The small "things" on the roof edges are holders for red 3mm LED's. The full scale locomotor has only white lights on the body, and uses red lights on the roof depending on which direction it travels. So, depending on how nerdy you want to be, you can use these mounts to get it "right". :)
- In order to pull many cars, especially in a slope, you will need to add weight to get good enough grip. Otherwise the locomotive will just stand stil with the wheels turning. A good way to add weight is to buy weights designed for balancing car rims with. These can be bought in big packs at car part stores and usually have double-grip tape already on them. Put as many as you can fit in the locomotive!
The included Arduino source code and schematic is for the Pro Micro-board. In the Arduino software, this board goes under the name Leonardo (which can be quite confusing). However, you can of course use any other Arduino compatible board with very little adaptation, you basically only need to change the pin allocation and make sure that the ports you choose can handle either PWM or analog in for respective ports. This board was chosen because of the compact size.
The motor board is a Dual TB6612FNG (1A) from Sparkfun.com
Source code descrpition
The included program uses a micro button switch to activate motion and a potentiometer (use between 5 - 10 kOhm ) to set speed. When the button is pressed, a counter starts counting either control loop (preset to 1/10S) and when the button is released, either forward or backward motion is initiated depending on how long the button is pressed. The motor PWM is increased with a pre-set acceleration value which you can adjust in the code if you want slower or faster acceleration.
At any given time during motion, the button can be pressed to initiate a deceleration. If the button is pressed longer than the pre-set emergency stop counter value, the PWM will be cut of as soon as the control loop has counted to that value with the button pressed.
During motion, the speed knob can be turned to directly adjust speed.
Resistors for LED's
In the schematic, the resistors for the LED's are not specified. This is because different supply voltage and different LED's will require different values. There is an easy way you can find out what value to use, without doing any calculations.
- Take a potentiometer and connect two wires, one to the middle (output) and one to either of the sides. Measure with a multimeter and turn the knob so you have maximum resistance dialed in (!important!).
- Wire up the LED's. In the case of front lights, there is almost always enough voltage to drive two of them in series unless you have a 3,3V CPU board like a NodeMCU, but most Arduinos can operate at 5V and then you will have enough voltage to put two LED's in series.
- Put the potentiometer in series with the two LED's and the multimeter set to current sensing mode.
- Connect a 4 cell battery (4,8V) or a power supply with 5V output).
- Slowly turn the potentiometer knob (lowering the resistance) until the LED's shine bright enough, or you reach around 20mA of current, which is standard nominal for most simpler LED's (not high-power ones). Also keep in mind that if you intend to drive them directly from a digital I/O on the Arduino, it's very important to make sure they don't draw too much current!. 20mA is OK for most boards so aim for that. IF you read this and think it's stupid not to just use a simple Ohms law, keep in mind that in many cases you want the LED to shine less bright than full power, then this is a good way to adapt and make it shine exactly the way you want it to.
Alternative, powering LED's from motor board
As briefly stated in the schematics, the motor board can handle two motor outputs and only one is used for the motor. The other one can be used for LED's, but keep in mind that the output at full PWM duty cycle will supply the whole battery voltage unregulated, this mean that the LED's will shine brighter at first and gradually shine less bright as the battery voltage decreases. That said, you can still use the boards H-bridge in a smart way to light up either sides headlights without any extra pins on the arduino, here is how.
Follow the above instructions for the LED's and the resistors, but in this case use your intended batterypack as voltage source when testing.
- Now to the important part, wire the head ligths like this:
Forward -------->---- Board---<------- Backwards
LED voltage ---->---- B01 ----<------- LED GND
LED GND ------->---- B02 ----<------- LED Voltage
Why this connection? The LED's are diodes, meaning they will block current in one direction and allow current in the other. They are not harmed by reverse voltage as long as it's not higher than they are designed for. In the above connection, depending on which of B01 or B02 is voltage or GND, only one sides head lights will shine at either one time.
Next step is to bridge the direction inputs to control this as well. Connect as followes:
AIN1 -> BIN1
AIN2 -> BIN2
- If you want to be able to dim the lights, connect an extra PWM output from the Arduino to the PWMB-input on the motor board. If you are OK with full power or nothing, just connect VCC to PWMB and you're set. (do NOT use VM, because that input has higher voltage than the controller can handle).
Finally, there are a lot of directions to keep track of here which can be a bit confusing, so before you mount the boards in the locomotive, fire it up and test. If the lights are wrong, either switch place for the B01 and B02 or connect AIN1 to BIN2 and AIN2 to BIN1. If on the other hand, the directions forward and backward are wrong compared to the chassis, switch place on the motor leads instead.
Right click on the picture and save it or open it in a new tab to see full size