Project tutorial

Automation of Railway Models Part 1 - Sensors (Updated) © CC BY

The first part of the instructions on automation. Sensors on rails and bundle cylinder neodymium magnets on locomotives.

  • 2,243 views
  • 2 comments
  • 22 respects

Components and supplies

Apps and online services

About this project

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.

Hardware

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.

Sketch

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".

Schematics

hall_simple_sheme_ctUnMPIGXr.png
Hall simple sheme 3p6ab6xpuc

Code

Simple interlockingArduino
// ARDUINORAILMAKET.RU
// SimpleHall.ino
// 15.09.2017
// Author: Steve Massikker

//// GPIO PINS ////

#define HALL_1 2 
#define HALL_2 3
#define RED_SIGNAL 10
#define GREEN_SIGNAL 11

//// VARIABLES ////
boolean interlocking_state;

void setup() {

// Initialize GPIO
  pinMode(HALL_1, INPUT); 
  pinMode(HALL_2, INPUT); 
  pinMode(RED_SIGNAL, OUTPUT); 
  pinMode(GREEN_SIGNAL, OUTPUT);  

// On start or reset
  interlocking_state = true; // Line free
  digitalWrite(RED_SIGNAL, LOW);
  digitalWrite(GREEN_SIGNAL, HIGH); 
  
}

void loop() {

  if (digitalRead(HALL_1) == LOW || digitalRead(HALL_2) == LOW) {
    interlocking_state = !interlocking_state;
    delay(200);
  }
  
  if (interlocking_state) {  //true
     digitalWrite(RED_SIGNAL, LOW);
     digitalWrite(GREEN_SIGNAL, HIGH);     
  } 
  else {
     digitalWrite(RED_SIGNAL, HIGH);
     digitalWrite(GREEN_SIGNAL, LOW);    
  }
}  

Comments

Similar projects you might like

Version 2.0 Advanced Attendance System (Without Ethernet)

Project tutorial by GadgetProgrammers

  • 2,482 views
  • 5 comments
  • 42 respects

Get The Arduino Dice

by Ingo Lohs

  • 238 views
  • 0 comments
  • 4 respects

Control LED Using Your Voice Command

by IoTBoys

  • 569 views
  • 0 comments
  • 7 respects

Critter: Crawling Arduino Robot

Project showcase by Slant Concepts

  • 4,804 views
  • 10 comments
  • 30 respects

Musical Fairy Lights

Project tutorial by Ian Cumming

  • 449 views
  • 0 comments
  • 4 respects

Cloud Costume

Project tutorial by Monica Houston

  • 1,014 views
  • 3 comments
  • 10 respects
Add projectSign up / Login