Skip to main content

Train sequence / timetable using Arduino


                              Following discussions in a MERG Zoom meeting about potential projects for the Cumbria virtual area group I have started this blog to share my ideas for building a train sequence / timetable system based on an Arduino UNO.

The trigger for this project was Andy Robb's article in the MERG journal (June 2020 edition). In it Andy describes using an UNO with a OLED display to produce an electronic station display board. 

Having tried out Andy's version I started thinking about expanding the idea and have come up the following list of possibilities:

1. Replace my card index train sequence with an electronic version.
2. Have the train sequence synchronised with the on platform displays.
3. Display an analogue clock on the station display and have it display the train times.
4. Store the position reached in the sequence so that it starts where it left off on power up. 

To make the project of greater potential interest to other modellers the following additions could be considered:

5. Additional displays where the operators are not located at the same control point and on exhibition layouts use a display to tell viewer what's going on.
6. Implement a fast clock.
7. Rather than coding the text to display into the Arduino code write the software so the information to display can be read from a basic text file stored on an SD card. This could be further refined to allow file selection at startup so that different sequences can be run and even add LCD configuration data so the code could be used without knowledge of how to write the LCD configuration code in C. 

At this point (11/9/20) I have succeeded in getting dual displays working and displaying different text on both. They are connected using the I2C bus using different addresses. I have not tried using the OLED display used in Andy's project with mine as they use different driver libraries and I wanted to be sure they worked individually before attempting to use the 2 libraries on the same UNO. I have found articles on reading and writing to SD cards and sending text to the Arduino serial monitor. However to use multiple LCD displays some form of command structure is going to be need to route the text to the intended display.

For the analogue clock I found that a someone called Rudy has published several Arduino railway related projects, they can be found at:  https://rudysarduinoprojects.wordpress.com/ one of which is an very similar project to Andy's with an analogue clock.

If anyone else is interested in developing this idea or has ideas for additional features then let me know.

Mark Bradley




Comments

  1. Very interesting project Mark. Message and sequence storage might be challenging given the limited program memory. MEGA is a possibility but I have just ordered a Raspberry Pi 4 . Rudy does a great set of introductory Arduino videos which I'll put up in another post

    ReplyDelete
  2. Beware Project Creep! How about a station announcer linked in to your sequence ? well you did mention Swiss stations had an audible tone on train approaching.

    I'd consider having a file for each 'Card' rather than one big file, just a thought. Your code could then bring in one cards worth at update time, do stuff, then advance the card number for the next 'read'. Storing the current 'card' number would tell your code where it left off.

    Storing your data in an SD card means you could take the card out and update on a PC so I'm envisioning lots of small files perhaps with comma separated values (CSV) in a fixed format. Say card#,LCD_0_line1_data,LCD_0_line_2data,foo,bar,LCD_1_line1_data,LCD_1_line2_data,foo,bar,nada,nada,END

    One big file could have each card on a line of a spreadsheet and export it as a CSV file to the SD, this might be more difficult to handle in the Arduino code. Then again it could be easier.

    Very interested to see how this advances.

    ReplyDelete
    Replies
    1. Hi Andy, I have done a bit more work on the project and have set up a repository at:
      https://bitbucket.org/Mark4664/mergarduino/commits/86072fa9d1ab479482cf42a4d6f9a85253a3d618

      No new code yet but I have put up a an outline and specification including a possible file structure. Code wise I have had a look at storing the instances of the LCD in an array so that the same functions / methods can be used for all the displays, have it working but not posted it yet.

      Delete
    2. Can you put an image in the blog showing the contents of a typical index card

      Delete
  3. This link will take you to an article on connecting and using SD cards;
    https://create.arduino.cc/projecthub/electropeak/sd-card-module-with-arduino-how-to-read-write-data-37f390

    ReplyDelete
  4. Miss read the last comment , have got SD cards on the brain at the moment. A card or record could contain something along these lines;
    @ //Record start marker
    {} Text block marker. No need to specify which display. 1st Block goes to display 1, 2nd block to 2 etc.
    In the example below display 1 is for the main control panel, 2 faces the public or is located on the station and 3 is for the fiddle yard operator.

    @
    {Passenger train fiddle road 6
    to platform 2 and stop}
    {Arrivals:
    07:30 All stations from Bristol}
    {Put class 323 rail-car set on road 6}
    @
    {Passenger train platform 2
    departs to road 1 in fiddle}
    {Departure 07:32
    All stations to Weston-super-mare}
    {} // Empty text block leaves a display unchanged.
    {}

    ReplyDelete
  5. Have reverse engineered the button arrangement and got code working with one LCD.
    Coded for a 128x32 OLED as the auxiliary display. Will post that code version in repository (If I can figure out how and have the necessary privileges).
    Waiting for SD card reader!

    ReplyDelete
  6. Now have 3 displays working with data read from a SD card displayed, different out put on each display. Code can be viewed at;
    https://bitbucket.org/Mark4664/mergarduino/src/master/LCD_I2C_TripleDisplay_SDcard_v1/

    ReplyDelete

Post a Comment

Popular posts from this blog

3D Printing Presentation

Sunday's Zoom meeting had our largest audience so far with 19 members attending from various parts of the country. Alan Geekie gave us an excellent and well received presentation on 3D printing that included FDM (Fused Deposition Modeling) and SLA (Stereolithography apparatus) types He first showed how we can source "things to print" using sites like Thingiverse. His own filament printer was the Prusa i3 Mk 3S which is available either as a kit (£699) or pre-assembled (£899) and features a self leveling bed. It also benefited from an additional multi material upgrade kit and he demonstrated the start up sequence of leveling, homing, clearing remaining filament from the hot end and then beginning the print.  The process of slicing where a 3d object drawing file (.stl) is broken up into the x,y,z drawing coordinates for each individual layer was also explained. Alan then moved on to resin printers using another Prusa model, the SL1 and its associated curing and washing mach

Mimic Points in Visual Basic

For this project, I wanted to create a moving graphic to mimic a set of points moving from one position to the other.  This Blog shows all that is needed. The first Picture shows the 6 lines needed.                                 This Picture shows the Line Properties.    The tracks are shown with 5 lines, though only the middle ones in red are involved.  The other line shown below the others is the one that actually "moves".  It is shown below the other lines for clarity only.  At the start of the Program running, it is positioned over the lower red line. In VB, each Line has properties and these are shown above.  To get a line to appear to move, all that needs to be done is to gradually change the X2 and Y2 co-ordinates of the line. This is the code for the program. The first 6 lines create a pause Function in the program, by using the Computers internal Clock. Each of the other Procedures move the X2 and Y2 co-ordinates. For j - 1 to 20                          Starts a l