Project tutorial

Automation of Railway Models Part 1 - Sensors © CC BY

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

  • 442 views
  • 3 comments
  • 13 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, 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, known Arduino devices and URB block, but you can use a breadboard.

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.

I have a strange module, and its contacts are located otherwise, than rather most common ones, and it also gives a negative signal when triggered. Therefore, I have the code - if (digitalRead(Hall)==LOW) - generally HIGH. Pay attention to the polarity of the power supply when connecting.

Attention! The SCHEMATICS show my "strange" Hall module.

I apply magnets because it's convenient. You can fasten them anywhere in the train, both at the beginning and at the end. Also you can put magnets on both the first and the last cars, then the logic of switching signals will become even more interesting.

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.

Schematics

hall_simple_sheme_ctUnMPIGXr.png
Hall simple sheme ctunmpigxr

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

Vintage Bench-Top DC Hybrid Voltmeter using Arduino

Project tutorial by Shahariar

  • 127 views
  • 0 comments
  • 5 respects

LittleBot Simple Arduino Robot

Project showcase by Slant Concepts

  • 279 views
  • 0 comments
  • 7 respects

Moisty v2 - a Plant Moisture Sensor

Project showcase by Mitch K

  • 388 views
  • 0 comments
  • 7 respects

Automatizing Percussion with Solenoids: "The Sound Compass"

Project tutorial by touchmysound

  • 1,495 views
  • 2 comments
  • 6 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 138 views
  • 0 comments
  • 2 respects
Add projectSign up / Login