This is an attempt to write universal instructions on the creation of automatic management railway traffic. In this part, sensors are considered. Features system Hall's sensor - magnet and an simple example of signaling of a interlocking. The train turns on the red signal when passing the traffic light, and returns the green signal as leaving the block section.
The same principle can be applied to the railway crossing for the movement of the gates and all that.
I used Hall sensors as train detector triggers on the line. In comparison with other sensors, it has the advantage of a trigger "dot". The second element - the magnet - is attached to any metal part underside of a car or a locomotive (for example, to the fastening screw, etc.). I recommend small cylinder neodymium rare earth magnets. By changing their number, you can adjust the distance between the magnet on the car and the sensor on the rails. I have reliable operation at distances of 1-5 mm.
You can place a magnet on any car or locomotive, at the beginning, middle or end of the train, thus adjusting the stopping place to within a centimeter. These sensors are small, if they are neatly put between the rails, then they are like real AWS inductor.
By placing two Hall sensors on the rails on the known distance you easily get calculated the speed of the train. Using three Hall sensors in a row, you will identify the direction of the movement of the train.
You can also place magnets in the head and tail of the train (for example to stop a train before a dead-end in move any directions), but I usually only use one magnet.
There are many types of Hall Effect sensors. For applications where the speed of detection is not crucial, ordinary Hall Effect sensors like 44E can be used.
This is a very simple example and it works when the locomotive moves in any direction. You can add to it your logic of signaling behavior, for example parity or counter. Also you can install more sensors and so on.
See next chapter "Bidirectional control".