I work in a control center for a train company in the UK. Our trains work in either direction but only one end has first class carriages. Because trains on our network reverse quite a lot it is difficult for us to track and advertise where first class will be.

Is it possible to create a device using a digital compass that will identify whether the train is travelling North or South and that can push this information via a GPRS transmitter so that it can be read on a PC? The device would be positioned at the first class end of the train with North pointing forwards. In theory If the compass direction is north and pin also north we would know that first class would be north facing. If the compass read out was south first class would be south facing.

I presume the main difficulties with this would be transmitting the information being read from the compass. Can anybody offer a solution?

  • \$\begingroup\$ This 'problem' can be removed by placing the first class carriages in the centre of the train. Perhaps then the train operating company can concentrate on fair reduction and reducing over-crowding in the lesser classes. \$\endgroup\$ – paulkayuk Mar 13 '13 at 14:35

This could be very easily prototyped in it's entirety with a smartphone - you have the sensor, the programmable platform, and the radio network link.

Doing it that way with cheap off the shelf hardware matching a widespread developer skillset will let you explore the idea and start to discover what unanticipated issues might be lurking.

For example, you haven' been very clear about when the measurement will be taken. If the train is still in the station, it's possible the station tracks aren't really pointing in the direction of the journey. A solution based on data pulled out of your scheduling system should be weighed as well.

  • \$\begingroup\$ Thanks for the answer. You raise a valid point, not all stations tracks are facing in North/South directions. However, if the readings were taken at the start of service from origin stations the results could be used to calculate formations of trains for the rest of the day. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 18:44
  • \$\begingroup\$ Chris, how easy would it be to create an app that could send its facing direction in degrees to a another location? Most of the google results seem very technical, although programming isn't something I am familiar with. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 22:09
  • \$\begingroup\$ It would not be particularly hard. Most of the challenge would be figuring out the rules for what/when it should send, and figuring out what to send it to. For example, email (takes a little doing to have that be entirely non-interactive), or coming up with a server it can post to. You might even look at some of the analytics platforms which do things like fill information into google docs spreadsheets. For initial testing, another possibility I had mentioned would be to just log data for a week to the device's storage, and then retrieve it - that way you wouldn't even need a data plan. \$\endgroup\$ – Chris Stratton Mar 11 '13 at 22:21
  • \$\begingroup\$ I suppose with so many apps uploading data to the all powerful cloud these days it would be fairly straight forward for a software developer. Perhaps I will contact some. In the mean time a weeks experiment using an old smartphone will go ahead. Thank you again. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 22:28

GPS would be my choice (over compass and accelerometer). At least, it could be a good backup plan if the compass doesn't work. I don't know how easy it is for you to have a GPS antenna with an adequate view of the sky.

1st GPS receiver in the 1st class car. 2nd GPS receiver on the other end of the train. This will provide all the information for identifying the direction and orientation of the train. If the 1st receiver is in point A and the 2nd receiver gets there, say, 3 seconds later, then the sought 1st class car is at the front of the train.

Like compass and accelerometer, the GPS approach is also easy to prototype with a smartphone.

  • \$\begingroup\$ Thank you. Another great solution. GPS locators are relatively cheap and many come with software so this could be the cheapest option as well as being effective. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 19:18

The problem with a compass is that it only tells you which direction the carriage is facing. It doesn't tell you which direction it is going in, or which end of the train it is at. You need additional information to do that.

Take the London Kings Cross to Glasgow Central route. In both locations the train will be pointing virtually North/South, and the trains simply reverse back down the line - I don't recall the last time first class wasn't at the near end of the platform at Kings Cross. The compass doesn't help you here without additional information, namely a timetable or where the train has just come from.

The reason I say this is that all announcements I have heard on the platform or train all refer to front/rear. It seems far easier to just know front/rear than infer it from additional information such as a timetable (which can't be relied on in the UK) or live scheduling information (which seems to vary from TOC to TOC - SouthWestTrains is always correct, FGW have to override automated announcements manually all of the time).

You need to know which direction the train is moving in, which is very different. The complex solution to this is GPS. You could use one unit (only useful once the train is moving) or two units (useful when stationary) to do this. It seems like a lot of work.

Easier than this would be an accelerometer, but again, this will only work once the train is moving.

How would I suggest doing it? A small box with a GPRS modem in each driving cab. The driver presses a button during his pre-departure checks. Depending on which one is pressed, you know which end is the front. The issue with it is that you have to rely on the driver, and implementing a fleet-wide additional step to checks may be hard. You could try detecting the presence of the driver in other ways - PIR might work (fails if the guard sits in the non-driving cab). I doubt you'd be able to link into the trains systems to detect where the driver was.

  • \$\begingroup\$ Please explain in your example why knowing which way the first class carriage is pointed is insufficient to know which end of the train it is at, given knowledge of the orientation of the track and the assumption that it's always to be found at one end or the other? The situation you don't recall ever having changed does seem to be precisely what the poster is trying to indicate the possible daily variation of for their particular line. \$\endgroup\$ – Chris Stratton Mar 11 '13 at 20:17
  • \$\begingroup\$ The carriage in both situations is pointing North. In Kings Cross, the carriage is at the rear. At Glasgow it is at the front. Both stations have track running North/South. How do I tell the difference? \$\endgroup\$ – Cybergibbons Mar 11 '13 at 20:21
  • \$\begingroup\$ The desire isn't to tell which station it is at, but to tell which end of the train it is at, and therefore which end of the platform it will be at in a given station. For it to swap ends of the train on this north/south track, it would have to end up pointing in the other direction (or else the train decoupled and recoupled with the cars placed differently) \$\endgroup\$ – Chris Stratton Mar 11 '13 at 20:24
  • 1
    \$\begingroup\$ Imagine a train with a compass fixed so that if it was travelling north, the pointer would be pointing at North. This indicates the train is first class front. If that train was the opposite way round the compass needle would be facing north although in relation to the compass it would be reading south. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 21:00
  • 1
    \$\begingroup\$ Currently most companies rely on information coming from depots to work out first class positions for entire day. However this is still prone to human error. Also add to this that during disruption trains will divert which will change the position of first class. The aim here is to cut out human error using electonic equipment. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 21:08

Why not use an accelerometer?

Presumably, all you care about is whether the train is going forward or backwards as far as the first class cabin is concerned. That way you don't have to worry about interference.

The trouble with the compass is that it'll still be pointing the same direction unless the cabin (device) physically turns around.

  • \$\begingroup\$ Thank you. Would an accelerometer give a negative reading if the train was travelling backward? \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 18:48
  • \$\begingroup\$ yes, exactly. That's the idea. Though it may be a small value given that trains don't accelerate fast, and once at cruising speed, it'll go to zero. You should still be able to tell which direction it's going based on previous values. \$\endgroup\$ – MandoMando Mar 11 '13 at 18:55
  • \$\begingroup\$ This may actually prove tricky for that reason. An accelerometer does not detect velocity, rather it detects acceleration (and in an electric railway, it's primarily the same mechanism used for both, so magnitude may be similar). Which is to say it will detect both starting out of a station, and also slowing/braking into one, so you'd have to have a rule to know which one to look at. But a smartphone has an accelerometer, too, so if you want to combine the ideas and can arrange for a fixed-orientation mounting the cab during your tests, you can play with sensor fusion. \$\endgroup\$ – Chris Stratton Mar 11 '13 at 19:00
  • \$\begingroup\$ Thank you for the feedback. I understand the difficulties you have identified. I will have a ride out and test using a smart phone to see if there is a pattern. \$\endgroup\$ – Daniel Autiero Mar 11 '13 at 19:15
  • \$\begingroup\$ There are some sensor Accelerometer and Compass demos in the Android SDK samples. They only graph and do not log, but it would not be hard to modify them to log. If you can get mains or USB power in a protected location in any of the the cars, you could mount a phone for a week (even a castoff without a service plan) and have a lot of data to look at. \$\endgroup\$ – Chris Stratton Mar 11 '13 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.