Jump to content

Layout Controlled by a Raspberry Pi


RDS

Recommended Posts

I use a raspberry pi with JMRI.

 

Hi, Do you have any more details that you could share.

Okay, I have 3 separate raspberry Pis, some jobs can be merged into 1 to reduce the number of Pis Needed:

  • RPi no.1 - Controls JMRI WiThrottle Interface, with small screen and keyboard for changing roster etc
  • RPi no.2 - Controls Signals and Points via relays connected to GPIO pins. Pin output is controlled via a python program on the Pi, listening, and a separate program on a control computer, which connects to the Pi accross the wifi.
  • RPi no.3 (optional) - Announcements - Python program once again connects to control computer, trains are scheduled from this computer, to be announced, and also are placed on a mini-screen next to the operator.

Code Length: >1000 Lines

Code Diffculty: Moderate (easier if control device runs a text-based interfase rather than a GUI)

Programming with JMRI - I have looked into this, although it runs on Jython, which is not my favourite programming language ever, and the documentation is sparse.

Potential

Sensors could be used to interlock and automate signals

Link to comment
Share on other sites

I favour the GUI approach.  I have started using tkinter on my programs now.

I used tkinter, but personally find it hard to make it look nice, and some of the features have limitations, ie. for some features your code has to generate and execute code through the program itself, although this sort of complexity would only be seen in programs coded for generic use, not for use on a particular railway unless complex.

Also, I found programs coded for generic use, although worked, required more user input for simple tasks, so hardcoding would be less time-consuming for the operator.

Experimenting ended my up with 5 prototypes, and conclusions:

  • Don't code it generic or it'll consume operator time
  • Google TTS is the most similar TTS for announcements in real life
  • A similar screen used in the train-tech smart screen can be found online for use with RPis

 

Link to comment
Share on other sites

Before I forget, my favourite tkinter tool is the tkinter.messagebox:

Imported via

from tkinter.messagebox import*

and then for information dialogs

showinfo(title=None, message=None)

and for error dialogs

showerror(title=None, message=None)

These use the default dialog box settings for the computer in use, and add a nice touch compared to bland tkinter typical light-grey windows and a few lines of text.

(also tkinter.filedialog may be useful for opening items such as train rosters, or mimic panels)

Link to comment
Share on other sites

  • 1 year later...

Hi. Ive just completed the first stage of a Raspberry Pi controlled system, using an RPI 4, PiHut relay board for the signals, a 298 motor controller and a number of IR sensors. Its all working great now. But I need to control two tracks independently using a single RPI, Im thinking I need to learn some form of concurrent control such as threading. Does anyone have any advice if this is the right approach, or know where I can get good advice on this. I will add a picture of the layout (N gauge) later if anyone is interested

Link to comment
Share on other sites

I meant to say that the code is all written in Python using the Mu editor. The locos are analogue and the L298N motor controller (usually used for Robotics) controls the speed using Pulse Width Modulation. Its incredibly easy to use though using the Python Motor function. The whole program is only 120 or so lines of code at the moment. I got started on the project after watching a tutorial by Penguin Tutorials on YouTube. Worthwhile watching

Link to comment
Share on other sites

  • 1 year later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
  • Create New...