proffalken
Posts: 13
Joined: Wed Aug 31, 2011 3:11 pm
Contact: Website

Model Railways

Wed May 16, 2012 4:34 pm

Hi all,

I've just received the email from RS stating that my R-Pi should be shipped within 7 days!

I've started work on an Arduino controller for my DC model railway (00 gauge) and you can find more information on this at http://www.rmweb.co.uk/community/index. ... -my-locos/

The plan is to use the R-Pi as the "interface" and "brains" and the Arudino as the "muscles" - Once I've got the R-Pi hooked up and the code written, I'll update this thread

Phil Spiegel
Posts: 210
Joined: Tue Jan 17, 2012 8:17 am
Contact: Website

Re: Model Railways

Tue May 22, 2012 8:46 am

You're ahead of me by an unknown amount in the queue 8-)
I'm planning ona Raspi in each of our portable (DCC-controlled) layouts -

Initial Development will be in our G-Scale Bruksbanen Mk2 Shunting Puzzle, which uses Picaxe's to run OLED information Displays, and has RFid Readers mounted in the tracks, going to a MERG Mk2 Conentrator .... the output from this will be fed to the Pi to translate into the correct picture of the stock, etc... THe Rpi will be located with the Picaxe, RFid Concentrator and USB hub in the 'basement' of the Station - maintaining the totally integrated solution.

Dropbox users can find a viewing gallery at..
http://www.dropbox.com/gallery/45006096 ... 2?h=c8bede
Dropbox Info: http://www.dropbox.com/photos


Our other Portable layout, 'Skandi-Demo' makes use of Optical Detection which feeds, at the moment, to a Rocomotion-controlled Glass Panel Position Display. We plan adding some Rfid readers to keep viewers informed of whatever stock we have chosen to run around the 'lower level' - and again the R-Pi can be totally integrated into the layout for this.

These are both the prelude to replacing the previously-allocated RiscPCs for may main loft-based 00 layout - where Rpi will take over 'running' the timetable and other information systems - again based on the RFid reader feedback ... but hopefully also incorporating DCC info (eg via NCE DCC reader we have monitoring track data) but preferably directly via Roco's Protocol if they publish the version for their USB-based MultiCentralPro.
The storage space (and energy) saved by changing to Rpis instead of 'full box computers' will be much valued!!

proffalken
Posts: 13
Joined: Wed Aug 31, 2011 3:11 pm
Contact: Website

Re: Model Railways

Tue May 22, 2012 10:28 am

Heh, sounds awesome.

How well does the RFID stuff work? I'm considering implementing it once I've built the base boards (or retro fitting it at a later date) but I've read mixed reviews on the reliability.

Nice to see others using their R-pi for model railways.

PF.

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Model Railways

Tue May 22, 2012 12:27 pm

Choo-choosing a raspberry pi will put you on the right track

proffalken
Posts: 13
Joined: Wed Aug 31, 2011 3:11 pm
Contact: Website

Re: Model Railways

Tue May 22, 2012 1:02 pm

:shock: :roll:

Phil Spiegel
Posts: 210
Joined: Tue Jan 17, 2012 8:17 am
Contact: Website

Re: Model Railways

Tue May 22, 2012 5:31 pm

How well does the RFID stuff work? I'm considering implementing it once I've built the base boards (or retro fitting it at a later date) but I've read mixed reviews on the reliability.
In this shunting puzzle, the trains are running 'relatively slowly' [Programmed to about 1/4-1/2 of possible maximum speed if (Roco Multimaus) throttle turned fully] Positioning the tags is critcal, as is positioning the 'aerial' - which in this case is simply the ID-12 IC with its internal antenna; and the Mk2 MERG Reader boards conveniently fit within the rails of the 45mm gauge brass track.
The 'Field Railway' wagons used for shunting have the 35mm glass tag glued lengthwise to their underside, between the axles, and appear to trigger reliably when the ID12 is at rail-level (but a problem when cleaning track!!) or just below .... if lying on the sleepers (Code332 rail) they are getting less reliable, and the 'full size' (Post) wagon in the pictures did not trigger when mounted on its underside 8-(

Similarly, problems were found when placing the Tags on the Locos ... and I SUSPECT but have not verified, that close proximity to the motor, and its magnetic field is killing the range ... also maybe the 'silent drive' pulses ???

We've had 'easier/more reliable results in 00; perhaps the range of distances involved is narrower. The LDT kit uses an external aerial, of Credit Card Size - maybe using the 2 connections to the external aerial on the IC would also have benficial effects.
[We've had 'similar' problems with 'Optical' IR Detection and visibly opaque plastics which seem to be transparent to Infra Red - white paper benath a model seems to improve that situation!]

A friend, in MERG, did some tests, mainly with the 12mm tags and N gauge a while back, and found speed to be a key factor: too fast and no detection. I can reproduce that on the shunting puzzle - but also you have to consider gaps between tags (too close and conflicts) and the inhibition of 're-reading and sending' the same data ... so if testing, always 'clear' the tag away fom the area, and preferably use a different tag next. On my 00 layout I have rather a lot of Tags waiting to be fitted - to 'all' stock - and hope to read the formations of trains as they depart from 'shunting/storage' locations ... that's 8 readers spread over 5m x 8m ... and the cable used for the serial signal back, and local power supply stability has also been found to be important (The MERG Concentrator Mk2 supplies the 5V to all 8 readers per concentrator)

AT PRESENT I do not see it as 'reliable enough' to actually CONTROL trains by position detection ... I am testing Optical on the Skandi Demo (3m long) layout for that .. and again the short distances between triggers can be a problem. [ By the time softrware debaiunce has occurred, you may be past the next sensor] . We have a 'backlog' of the Optical Detectors to fit to my main 00 layout (5m x 8m, 88 optical detectors planned -> 50+built) . I currently anticipate only using the positition detection, and RFid tag composition info to 'assist' me in running the trains by 'offering' information which I can use .... and I see the RPi as ideal for that - even for spoken station announcements to match (afterall, the BBC Micro could do that 30 years ago !!!!, and this is just the latest incarnation of that 'Beechingless Barnstaple' layout. So its definately a case of 'watch this space' (and or my website, or the MERG Journal etc)
rgds
Phil

proffalken
Posts: 13
Joined: Wed Aug 31, 2011 3:11 pm
Contact: Website

Re: Model Railways

Wed May 23, 2012 10:10 am

Hmmm, sounds like it's a problem that is yet to be solved.

My random brain this morning started to contemplate using Webcams and OCR (optical character recognition - the technology used in scanners) to identify which loco was in which block based on "reading" the number from the side of the train.

Not sure how well that would work at the moment, might try and test a few things in the next couple of days.

I guess I'm after more than block detection, I want to know where my train is on the layout so the R-Pi can set routes and direct the loco to the appropriate end point!

Phil Spiegel
Posts: 210
Joined: Tue Jan 17, 2012 8:17 am
Contact: Website

Re: Model Railways

Wed May 23, 2012 1:41 pm

Bar code reading - presumably from the underside of the train is available commmercially in several scales from german manufacturers - whether 'full' or a limited range code depending on the system, and perhaps affecting reliability and cost The 'limited range' version being limited to about 128 codes, making it loco only or for small railways?.

Someone some years ago, was working on a project using a video camera to read a bar code - but for some reason they seemed to me (as a video engineer) to be trying to reinvent the wheel, and read it 'vertically' line-by-line instead of using existing reading on each line ... which would have worked when stationary as well as at speed ['barcode'/ aka timecode printed across track - would be read many times at slow speed, but still readable at higher speed.

Quad Splits with movement detection are now quite cheap, and useful for monitoring a layout - with automatic switching of full-screen image - but as always, it is the variety of stock / scale /gauge / weather [indoor/outdoor-lighting etc] which makes a single solution difficult to reliably read information.

Returning to the camera-in-the track idea - and using EITHER image recognition (projects elsewhere in this forum) or 'barcode reading' - cameras are now cheap enough to position and read ANY label placed beneath an item of rolling stock - perhaps 'flood lit from below by Infra-red' and then processable to uniquely identify the item - and perhaps its orientation and direction of movement ... even speed!!

proffalken
Posts: 13
Joined: Wed Aug 31, 2011 3:11 pm
Contact: Website

Re: Model Railways

Wed May 23, 2012 3:21 pm

Well, at least I'm not completely mad with this idea then :)

Phil Spiegel
Posts: 210
Joined: Tue Jan 17, 2012 8:17 am
Contact: Website

Re: Model Railways

Wed Jun 20, 2012 10:50 am

Rumours of Pi coming to Fruition... now that apparently CPC are allowed access to Farnell's stock 8-) I may soon have a Pi to work on:
Coinciding also with finding my Roco (Serial) Rocomotion intereface - for which we have the published protocol .. so soon, the stalled project to produce our own Display and Control with both Roco and RFId feedback, will be back on track.

PaulCheffus
Posts: 381
Joined: Tue May 29, 2012 2:51 pm
Location: Lincolnshire UK

Re: Model Railways

Wed Jun 20, 2012 11:05 am

Hi

One of the projects I have in mind is to use the Raspberry Pi as a cheap router so when I take the layout out I don't need to dismantle the home network to use my iPod as a wireless throttle.

Cheers

Paul
Procrastination - The Thief of Time.

sixoh8sixoh
Posts: 1
Joined: Tue Jun 26, 2012 10:57 am

Re: Model Railways

Tue Jun 26, 2012 10:58 am

Just received my RPi from RS today. Wondering about model railway uses with it so I'll watch this with interest!

F1p
Posts: 20
Joined: Mon Aug 20, 2012 8:09 am

Re: Model Railways

Sun Oct 07, 2012 9:17 am

I have been using my Rasp & Arduino for a train detection system.

Although i have a DCC layout, i can't seem to use my Pi & Arduino any further than this project.

Hope you find it interesting: http://mrlforum.co.uk/forums/index.php/ ... trol-panel

peterw
Posts: 2
Joined: Tue Oct 16, 2012 11:04 am

Re: Model Railways

Tue Oct 16, 2012 3:27 pm

Hi, I've been experimenting using my RPi to automate a model railway. Admittedly, its a very small railway, i.e. one straight track, but the initial results are encouraging.

The train and accessories are controlled by a Hornby Elite (DCC controller) which is connected to the RPi through its USB port. A python program running on the RPi sends commands to the Elite using the XpressNet protocol. The trains position is fed back to the RPi through hall-effect sensors (well only one at the moment, but in theory the RPi could read 128) fitted to the track. The sensor(s) are connected to the RPi via a MCP23017 16 Bit I/O expander chip. The chip is then connected to the RPi through its I2C interface.

If you are interested, you can watch a demo :

http://www.youtube.com/watch?v=VdGRsR1m2Oo

Please let me know if anyone wants to know anymore about the project.

ph1lj
Posts: 6
Joined: Sun Dec 25, 2011 11:05 pm

Re: Model Railways

Fri Oct 19, 2012 10:31 pm

http://www.youtube.com/watch?v=VdGRsR1m2Oo

Please let me know if anyone wants to know anymore about the project.[/quote]

I'd love some more info on this,its just the kind of thing I want to do.

proffalken
Posts: 13
Joined: Wed Aug 31, 2011 3:11 pm
Contact: Website

Re: Model Railways

Thu Nov 15, 2012 5:10 pm

I've created JMR-Pi - a script to install JMRI on a clean R-Pi installation.

It's available at https://github.com/proffalken/JMR-Pi

Let me know what you think

Nexus12
Posts: 10
Joined: Sat Jan 05, 2013 10:37 pm

Re: Model Railways

Thu Jan 24, 2013 1:16 am

peterw wrote:Hi, I've been experimenting using my RPi to automate a model railway. Admittedly, its a very small railway, i.e. one straight track, but the initial results are encouraging.

The train and accessories are controlled by a Hornby Elite (DCC controller) which is connected to the RPi through its USB port. A python program running on the RPi sends commands to the Elite using the XpressNet protocol. The trains position is fed back to the RPi through hall-effect sensors (well only one at the moment, but in theory the RPi could read 128) fitted to the track. The sensor(s) are connected to the RPi via a MCP23017 16 Bit I/O expander chip. The chip is then connected to the RPi through its I2C interface.

If you are interested, you can watch a demo :

http://www.youtube.com/watch?v=VdGRsR1m2Oo

Please let me know if anyone wants to know anymore about the project.
So after several delays, disasters etc my little system responses well to you script - thanks for your excellent work.

I'm trying now to add some electric motor driven points using the Hornby R8247 Points & Accessory decoder, not getting on very well - can't seem to address it.

Don't suppose you have any ideas ?

Here's hoping

Phil

peterw
Posts: 2
Joined: Tue Oct 16, 2012 11:04 am

Re: Model Railways

Sun Feb 10, 2013 11:09 am

So after several delays, disasters etc my little system responses well to you script - thanks for your excellent work.

I'm trying now to add some electric motor driven points using the Hornby R8247 Points & Accessory decoder, not getting on very well - can't seem to address it.

Don't suppose you have any ideas ?

Here's hoping

Phil

Hi Phil, I am pleased you've had some success. When I started setting this up I couldn't get hold of a Hornby accessory decoder, so I used a Digitrax DS52 instead. I'm only using one output to control a signal. It worked OK as shipped using an address of 0x00. The Xpressnet protocol uses a 4 byte command to control the accessory decoder : byte0 - 0x52, byte1 is the address so I'm using
0x00, byte 2 is made up of a number of different bits which activate and deactivate the accessory as well as addressing individual devices connected to the decoder, byte 3 is the error detection byte. My only suggestion is that byte 2 is not being set properly. I'm using 0x03 and 0x02 to activate and deactivate the signal. Have a look at the Xpressnet protocol 'Accessory Decoder Operation Request' for a description of byte 2. I was going to buy a R8247 so I would be very interested in knowing if you have any success.

I've recently updated and tidied up the scripts a bit separating out the Hornby Elite and Sensor management into separate modules. While not ideal, I've uploaded them, with some notes, to a
website:
http://www.peterwallen.talktalk.net/My_ ... ation.html
I'll try and host this suff in a better way when I have time.
Peter

Nexus12
Posts: 10
Joined: Sat Jan 05, 2013 10:37 pm

Re: Model Railways

Mon Feb 18, 2013 1:20 am

Hi
Yes I can now confirm that the Hornby Points controller works, using your library. On my system I set them up as follows, For Elite default address, 61. I can control it using address 0x0f, offset 0x02, to open, the opposite movement addressed 0xff, offset 0x0b, to close.

For Elite address, 62. I used address 0xff & offset 0x05, moves one way, 0xff, & 0x0c, goes other way.

Hope that help, thanks for getting back to me, very much appreciate your help, along with your great library

Cheers

Phil

Nexus12
Posts: 10
Joined: Sat Jan 05, 2013 10:37 pm

Re: Model Railways

Mon Feb 18, 2013 3:45 pm

Sorry last message, was incorrect.
To address the first port, I used address 0x0f, offset 0x02, and 0x03. The second port address 0x0f, offset 0x04, and 0x05, etc.

My Elite controller uses v1.3

Hope that helps

Phil

Earlton2
Posts: 66
Joined: Mon May 27, 2013 1:13 am
Location: Tonight it's -28C
Contact: Website

Re: Model Railways

Sun Sep 08, 2013 2:51 pm

This is a short description of my Pi Train Interface (piti) which was built to run an HO train set atop a Diorama built for our church's 125th Anniversary in May 2013. Not only did Carleton Place, Ontario lose it's railway tracks this year but Canada lost it's penny. So I thought a model train was a suitable addition and the Raspberry Pi was a suitable candidate. The same week I ordered a Pi my son called to say he was sending me one as a present which he'd purchased from the community workshop DIYODE in Guelph.

The original design for the Diorama was five six-foot panels but a door in the church hall meant this had to be reduced to 24ft overall. The panels have four horizontal rows with picture from the church, Canada, and the World from 1888 to 2013. The bottom row has a logarithmic scale going back to the Big Bang.
SDC11520A.JPG
piti - Installation at Ottawa Maker Faire
SDC11520A.JPG (61.33 KiB) Viewed 7865 times
The Interface board has a 26-pin connector for the GPIO lines and 1/8" stereo plug for the audio. The power supply got a little out of hand and now uses +/-5V (logic/op amp), +12V (relay), +14V (track). It's a linear supply circa 1980. The Audio plug is connected via a relay to two audio sockets so I can drive four 'PC' speakers along the track. These were plenty loud enough in the church hall but not in the Science Museum (see photos). The PWM track signals are generated via an L298 Full-Bridge Driver. The signals from the 0.2 ohm sense resistors are fed back to two op-amps which trigger a 555 if the track current exceeds 1.5A. The resulting pulse disables the L298 for a second or so. Two of the GPIO lines are used to drive a couple of LEDs which appear as track signals in the Diorama. I also built in a serial current loop which was meant to drive a Marsland Teletype (more history) but while I managed to punch paper tape I never did manage to read from the keyboard. In the end I cobbled RS232 levels to talk to PuTTY on my Laptop. (only 2400 baud, so needs work). Finally I added four status lines which read from ATS177 Hall Effect latches set between the rails. Magnets slung under the engine and rear carriage allowed the position of the train to be detected. The other chips are what I had available including TTL and LS.
PitiA.gif
piti - Schematic
PitiA.gif (57.56 KiB) Viewed 7865 times
20130324ASY-01A.gif
piti - Wiring Diagram
20130324ASY-01A.gif (57.19 KiB) Viewed 7865 times
The software is written in 'rusty' C. To interface to the GPIO I used Gordon Henderson's WiringPi and to play engine sounds I used a system call to aplay wrapped in a thread. Initially I braked and only then played the Brake file. Somewhere along the way I even had sound driving the track power!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12653
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Model Railways

Sun Sep 08, 2013 3:00 pm

tried to look at your schematics, but unfortunately their resolution is way too low!

Earlton2
Posts: 66
Joined: Mon May 27, 2013 1:13 am
Location: Tonight it's -28C
Contact: Website

Re: Model Railways

Sun Sep 08, 2013 6:39 pm

Re low resolution, I spent an hour with GIMP trying to reduce my files to 64K otherwise the Forum wouldn't accept them. I only used scale and brightness. If there is something else I could do or somewhere else I can save the originals I'd be happy to do so.
David Whiteley

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12653
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Model Railways

Tue Sep 10, 2013 12:37 pm

You don't have to post them here, you can post them anywhere on the web, then use the img and /img codes around an URL to the images location, and a thumbnail picture will be shown in the message. Double clicking the image will produce the full size version as it exists elsewhere on the web. Almost nobody bothers with attached pictures.

Also, these GIF's are 8-bit depth per pixel, for a monochrome picture that is wasteful. A black and white version would probably compress much further. To achieve that using only ms-paint first save the (highres picture as a monochrome .bmp file, then load the new, now monochrome picture in-to paint again and then save it as .gif again to compress it. You will get a large reduction in filesize. Another option would be to save it as a TIFF file.

Return to “Automation, sensing and robotics”