Raspberry pi dcc train control

For example, automatic block control avoids collisions and you control which train is driving manually or fully automatically according to a selected route. Modern software techniques make it possible to run the program on all major computer operating systems such as Windows, macOS and Linux. Client server architecture allows extra computers to be used as extra overviews or controllers. The switchboard is fully scalable with an optional layout overview for large layouts, and allows different tabs for different views of parts of the layout.

It is not necessary to study for weeks to be able to use iTrain. Simply draw the layout and assign the signals and feedbacks to the blocks for automatic control of your block signals, without providing difficult rules.

Defining a route can be as simple as selecting the order of blocks, but more advanced options are also possible. In case you use a modern system like the ECoS or Central Station 1 and 2, iTrain will import all loc definitions so you can start even faster. Introduction iTrain offers an easy to use solution to control your model railroad with your computer sespecially if you want to automate only parts of your layout and keep control of the rest yourself.

Features Easy manual control of locomotives. Travelled time and distance indicators per loc. Flexible switchboard with overview control.

Automatic control with one or more feedbacks per block. Block properties automatically retrieved from switchboard drawing. Easy configuration of main and warning signals. Possibility to add text, platforms and buildings to the switchboard. Stopping in the middle of a platform at a station without extra feedbacks. Fully automatic driving with or without routes. Modification of definitions possible at all times and directly visible. Controlling one layout via multiple computers in a network.

Multiple commands stations at the same time. This page was last updated March 23, All Rights Reserved.Certain hobbies come in clusters. Programmers who are musicians. Electronics people who build model trains.

raspberry pi dcc train control

This last seems like a great fit since you can do lots of interesting things with simple electronics and small-scale trains. There are actually quite a few basic Arduino videos on the channel, although most of them are aimed at beginners. Model trains pick up electrical power from the rails. DCC allows digital messages to also ride the rail.

The signal shifts from positive to negative to indicate marks and spaces. By diode switching the electrical signal, the train or other equipment can get a constant supply of current. However, equipment monitoring the line ahead of the diodes can read the data and interpret it as commands. To accommodate old equipment, you can stretch the high or low values to make the average voltage either positive forward or negative reverse.

This can heat up DC motors, though, so it may shorten the life of the legacy equipment. We had to wonder if there were other places where passing power and data on the same lines might be useful. There are other ways to do that, of course, but this would be a reasonable place to start if you needed that capability. Either way, it is just the thing for your next coffee table. Some clarification: in DCC, power and signal on the rails is the same thing.

The signal is simply rectified to get DC for a motor and whatever other functions. DCC has taken things quite far from what used to be the case with model trains. For starters, you can run two trains on the same rails in any direction, independently, at any time. You can also control lighting. DCC decoders mounted in engines are processor-based, meaning you can have lighting control and effects, sound effects, back EMF motor control, locomotive inertia settings, even sound effects onboard, including the ability to have a more labored sound on an incline, based on motor loading.

Speed tables can be used to calibrate models such that a given throttle setting equates to very similar speed in another model at the same throttle setting. Kick voltages can be set for starting a motor off at really low RPM. Features and bells and whistles, literally in some cases, are extensive.

Beyond mobile decoders and their motor, lights, and sound control, you can wire up turnouts, trackside lighting, you name it, any sort of animation automation you can imagine. Some guys have done DCC rail cranes, giving the ability to run your crane from a remote called a throttle in model railroading.

And yes, various USB interfaces exist for computer-based control.Add the following snippet to your HTML:. Project in progress by Masters. It takes a long time, of course, to build a complicated layout and in the meantime you want to test ride on the track you have so far. You can of course do so just with your transformer, but if you do not pay attention you drive off the track. And model trains are fragile, a drop on the floor will do damage.

So the plan is a back and forth automation. Something like this: Arduino-railroad. All due respect to the maker but if you pop each time against a fence and reverse the motor directly, it will damage the train or the gear at some time. Please log in or sign up to comment. A low-cost way of controlling a model train layout using a mobile phone through DTMF. Project tutorial by Kushagra Keshari. Now you can easily control your model railway layout using a keyboard! Simple instruction to let you know how to control an AC voltage device using an IR remote control and the Arduino.

Sign In. My dashboard Add project. Model Train Control Project in progress by Masters 9, views 4 comments 16 respects. Project in progress. The train blocks the light. Train Control. The pin numbers of motor control are fixed. Author Masters 1 project 7 followers Follow.

Respect project. Similar projects you might like. Project tutorial by Kushagra Keshari 2, views 0 comments 8 respects. Powered by. Keep me signed in on this device. Or connect with your social account: Login with Arduino.

Arduino Motor Shield R3. LED white. Photo resistor.Free versions of both apps are available from the respective app stores. Paid for version of the apps are also available with greater functionality. This is intended for those users who already own a suitable Raspberry Pi and are happy to configure their own system. Full instructions to create a suitable Linux image for your Pi model are provided. This is a complete and fully configured and tested system that will work "out of the box" actually, in the included 3D-printed custom box!

As supplied, there is nothing more to do than plug in the power, connect your phone or tablet to the WiFi and select your loco s to run. Connect to the WiFi, launch the throttle app for your type of device phone, tablet, etc. Close the default PanelPro session, and launch DecoderPpro from the desktop icon provided.

See our Using the Image Guide with full details about using this image, or download a printable version too. A current capacity of at least 2. Alternative supplies are also available - please Contact us to request bundling of other options, for example for a higher voltage unit. Use of a lower capacity supply e. A small amount of power is taken from the Raspberry Pi's 3.

raspberry pi dcc train control

Using separate power supplies in this way guarantees that a problem with the DCC track power supply will not affect the normal operation of the Raspberry Pi. In any case the standard Raspberry Pi power supply should be sufficient, depending on what other peripherals you have connected to your Raspberry Pi. To help users in setting up their system we also supply pre-configured Raspbian Buster images, including all of the software required, on micro SD Card.

Introduction

Thanks to Steve Todd for the base image that we are using, with some additional adjustments. We offer the image in two versions, set up as a standalone WiFi accesspoint, or to connect to an existing club or home WiFi network. This image can also be reconfigured to work on an existing home or club WiFi. This image can also be reconfigured to act as as standalone WiFi access point.

Default is Operation mode with PanelPro and the Pi hosts a separate WiFi broadcast network, or switch to programming by connecting your display and keyboard, or launching a VNC virtual desktop to connect to the Pi. Close the default PanelPro session, and launch DecoderPro from the desktop icon provided. What about a home or club existing network? We also supply a preconfigured image that is set up to connect to an existing network, rather than broadcast a new separate network, as the example above does our default image we ship.

Select this option when ordering. We now offer a preconfigured image for the most recent Buster version of the Raspbian OS.A python program sends XPressNet commands to the controller using the python serial package python-serial. The XPressNet protocol developed by Lenz allows DCC control devices such as hand-held controllers to be connected to the command station.

Such connections are high-speed RS links.

Lenz and probably others make devices that allow PCs to be connected to the XPressNet bus via a slow speed e. For further information about XPressNet including the full specification see the Lenz website. There appear to be discrepancies between the documented responses and what I get back from Elite after a command has been sent.

One problem I had, was getting Linux to correctly recognise the Elite when it was connected to the RPi. It appears that Hornby incorrectly uses product and device ids in their firmware. This results in the wrong drivers being associated with the Elite. This problem can be resolved by creating a file called :. The application program running on the RPi should now be able to communicate with the Elite using the file id ttyUSB1. Before python can communicate with the serial port you need to install the python serial package e.

The following will open the serial port ttyUSB1 with a speed of Baud, no parity and one stop bit:. The following is an example of sending a command and waiting for a response. It is formed using an X-Or linkage of the proceeding bytes of the command.

The following function will determine the error detection byte:. The following example shows how a function could be coded to implement the XPressNet throttle command:. For railway automation to be effective, some sort of positional feedback is required.

There are a number of techniques for achieving this, ranging from sophisticated RFID readers that can read information stored on tags fitted to the train to simple mechanical switches such as reed relays activated by magnets fitted under the train.

The approach adopted with this project, is the use of hall-effect switches fitted to the track and a magnet fitted to the underside of each train. It has the following advantages:. This approach does, however, lack the ability for a computer to distinguish between different trains.

A complex layout with a number of trains concurrently running will struggle to achieve full automation, however, even with a reasonable size layout, it should be possible to manage a degree of automation by building algorithms into the automation program that will deduce which train has triggered the sensor by the sequence of sensors activated. The hall-effect switch is a small device that fits on the railway track.

The new Pi-SPROG DCC devices

The flat side of the device should be facing upwards towards the underside of the train. Care must be taken to ensure the three leads that protrude from the device do not touch each other or the metal rail. For detailed information of the device see the device data sheet and the applications guide. When the south-pole of the magnet passes overhead, the output pin is driven LOW. It is assumed that the automation program will enable the internal pull-up resistors on the inputs to the MCPGranted DC is simple to hookup to a loop of track.

The locomotive is already setup to run and it takes a knob and a switch. But if you want to run more than one train at a time on DC, you have a lot of work to do. The work is not just in setting up block control but you must work to run the trains by throwing switches to power blocks as you move around the layout. The setup is much easier than it appears and once it is setup, it is very mobile and always available.

To replicate what I have done you will need and probably already have:. Keep in mind that these items are NOT dedicated to serving your layout. I use the household computer everyone else uses. These were all things that are quite common in most households these days. Sometimes I borrow well maybe steal my kids iPod Touch to run my trains if I need an extra throttle. The following article assumes that you are using Windows 7. The software outlined will run on many versions of Windows and even Linux.

We will keep this simple and just focus on what is necessary. We are going to assume that the maximum number of trains running at any given time will be four. This includes all locomotives pulling power, even if they are just sitting and not moving. If it is receiving track power we have to consider it running. Many command stations include the booster.

For the small layout, full size commercial systems can be too much, and in my humble opinion, can be overly complex. Most of us have computers and some may even have old ones doing nothing. Why not put it to use running trains? This means it will work with any decoder that also meets that specification and most do.On paper or in my head anyway it all sounded so easy…….

The result is not something that you would use as a desktop, but for small jobs such as a media player, or how about controlling a model railway! The first attempt I made on the Pi I already had kicking around which was the very first model released back in At that time I bought it to play with and never really found a particular use for it, however the model railway was always in the back of my head.

The original version was not very powerful at processing, so after installing all the latest versions of the software it would get part way through loading and then freeze entirely and give up. So I decided it was time to splash out on a new Pi 3 model B and give that a go. I bought a starter pack which included the power supply, case and pre-loaded memory card well I could have loaded it but it was cheaper to buy one as part of the set since I needed all the pieces ultimately.

So after sending back that Pi and ordering again, I tried again for the 3rd time! This time I had more luck and with various amounts of fiddling about and a bit of googling I managed to get the Pi up and running, JMRI installed and talking to the Sprog and control of a train! More detail on the steps on how to do it below.

Simple Coding for DCC Model Trains with Arduino.

The next stage is going to be get this onto the layout and try using a DCC train up there in reality. My last attempts failed miserably, but this was before I discovered all the Windows 10 issues.

So hopefully this time it will go better.

raspberry pi dcc train control

The installation process This piece is probably only interesting to those who might want to set up the Pi and Sprog setup. So here goes……. The first stage is to power up the Pi and install the latest version of Raspbian which is called Jesse. Since my aim is to try and use the Pi as remotely as possible and not connect a keyboard, mouse or monitor, then the next stage was to configure SSH access onto the machine. There are some good instructions on how to do that here.

More on Raspberry Pi, Arduino and DCC

Next up was to install JMRI itself. You can do this manually however following instructions I found on the nscale forum then it appears that someone has written some handy scripts that do pretty much all the work for you and published them to Github. So you just need to do the following:. Finally it appears there is an issue with xrdp and some of the default VNC servers on the latest version of Raspbian. As a result I needed to install another VNC server onto the machine.

After adding the connection preferences and a little trial and error to get the right USB port for the Sprog then I was able to connect to the track, read the decoder in my test train and control it.

The final stage was to enable the WiThrottle web server, and then using the Engine Driver Throttle on my Android tablet I was able to control the train remotely without needing to touch the Pi other than to start the software. So in the end, with the right hardware, not having Windows 10 involved, and a little bit of patience I think I know have a system for running DCC that I can look at add to the layout. So here goes…… The first stage is to power up the Pi and install the latest version of Raspbian which is called Jesse.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *