Site Announcements


:-j :-h :ymhug: Hello Friend ! Welcome to ^:)^ Core Engineers | Caring for Creation ^:)^ an on-line community of engineering students and professionals just like you. You can ask questions or share ideas with over all registered engineers from over different part of this planet.
:clap: :dance: :!! (*) Registration is 100% free and takes not more than 60 seconds to complete ! (Use Social Login)
(*) :!! :dance: :clap:
Those User's Who Are Facing Log In Problems "Kindly Clear Your Browser's Cache" (Clear Cookies and Browsing Data !)

Board index Core Engineers : Lets Discuss our Core Branch Related Stuffs ! Projects | Ideas & Showcase | Seminar Topics Automatic Railway Gate Control System With Atmel AVR Atmega 8

Automatic Railway Gate Control System With Atmel AVR Atmega 8

Discuss Your projects or Showcase them, Discuss Your Projects Ideas, Post or Discuss Your Seminar Topics here !

Unread post Thu Apr 11, 2013 5:02 pm » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows Seven 64 bits Windows Seven 64 bits  Screen Resolution: 1280 x 800 1280 x 800
Core Engineer User avatar
Site Admin
Site Admin

Chilling at Core Engineers


Posts: 467
Images: 1069
Location: New Delhi
Country: India (in)
Has thanked: 5 times
Been thanked: 15 times
Gender: Male
Blog: View Blog (1)
Engineering Discipline: Electrical & Electronics

Automatic Railway Gate Control System With Atmel AVR Atmega 8


Hello Friends,
After a long time, now again I am ready to post some interesting projects. Here I am sharing Automatic Railway Gate Control System using AVR micro controller upon the request of one of our forum member @girish.nautiyal1 .

Gates will close automatically when train arrival and open when train departure from crossing. The main purpose of this project is to avoid accidents and save time.



Automatic Railway Gate Control System With Atmel AVR Atmega 8


This project utilizes Two IR Tx./Rx. Pair is placed at either side of the gate with some distance as shown in the picture above. When train cuts first sensor light signal toggled from Green to Red; a buzzer gets activated for 2 seconds and railway gate will closed. When train cuts second sensor then a countdown timer starts and when it counts zero light signal again toggled from Red to Green ; again buzzer gets activated for 2 Seconds and gates will closed. Timing for countdown timer is set in the controller according to the speed and length of the train. You can easily measure this timing for your toy train. I made this bidirectional so train’s direction doesn't matter.

I design circuit using AVR ATmega8 microcontroller.IR sensors output is connected to comparator LM324. LM324 generates TTL High/Low signal at its output pins which is fed to MCU pins as Input. According to input from LM324 Microcontroller take action. Two DC Motors is used for controlling the gate, these motor's current requirement is much more than MCU hence we need a Motor Driver IC L293D.


Required Components:
  1. DC Geared Motors RPM:30 - 2
  2. IR Tx./Rx. Pairs - 2
  3. MCU ATmega8 - 1
  4. IC-LM324 - 1
  5. IC-L293D - 1
  6. Registers 470E - 10,10K-2,4.7K-1
  7. Capacitors : 1000uF.16volt -1 , 100nF-1
  8. Seven Segment CC - 1
  9. Some LED's : 2- Green, 2-Red, 3 others
  10. 7805 -1
  11. 6 Volt, 4.5 MAh Battery
  12. some wires, burg strips etc.

and a Toy Train --


Toy Train


Circuit Diagram:


Circuit Diagram


Step Wise Building Instructions:

Step 1 : First make the sensor setup.IR Tx./Rx. should be connected in line of sight. Two signal LEDs. Total five wire comes out from this sensor setup- VCC, GND, Sensor Output, Red LED anode, Green LED anode. Distance between IR Tx./Rx. is about 12cm.


Sensor Setup - 1


Sensor Setup - 2


Step-2 : Gear Motor's Setup.


DC Geared Motor RPM 30


DC Geared Motor Setup


Step-3 : Circuit design. I design the layout in PCB-Wizard.


PCB Layout Bootom View


PCB Layout Top View


Final Printed PCB


Step-4 : Whole setup -


Whole Setup 1


Whole Setup 2


Whole Setup 3


Whole Setup 4


Software : Source Code is written in C. MCU - Atmega8 @1MHz internal. Compiler - AVR Studio 5 & WINAVR.

//-------------------------------------
//Automatic Railway gate control system
//By - Core Engineer
//Website - www.ceindia.co.in
//MCU : ATmega8 @ 1MHz(internal)
//compiler : WINAVR
//-------------------------------------

#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>

#define CUT1 bit_is_clear(PIND,0)
#define CUT2 bit_is_clear(PIND,1)

#define BEEP PORTD|=(1<<PD4);\
delayms(1500);\
PORTD &=~(1<<PD4);\

#define MOTOR_CW PORTC = 0B00111010;\
delayms(800);\
PORTC=0X00;\

#define MOTOR_ACW PORTC = 0B00110101;\
delayms(800);\
PORTC=0X00;\

#define RED_ON  PORTD|=(1<<PD6);\
PORTD&=~(1<<PD7);

#define GREEN_ON PORTD|=(1<<PD7);\
PORTD&=~(1<<PD6);

char seg[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

void delayms(uint16_t ms){
  while(ms){
    _delay_ms(1);
    ms--;
  }
}

int main()
{
DDRC = 0xFF;//All Outputs
DDRB = 0xFF;//All Outputs
DDRD = 0XF0;//PD0,PD1 Inputs,PD4-PD7 Outputs
PORTD|=(1<<PD0)|(1<<PD1);//Internal Pull Ups

int i,done;
while(1){
   done=0;
   GREEN_ON;
   PORTB=0X00;//Segment OFF

    if(CUT1){
    BEEP;
    while(CUT1);
    while(!CUT2){RED_ON;if(!done){MOTOR_CW;done=1;}}
    if(CUT2){for(i=9;i>=0;i--){PORTB=seg[i];delayms(700);}
    BEEP;GREEN_ON;MOTOR_ACW;
      }
    }

    if(CUT2){
    BEEP;
    while(CUT2);
    while(!CUT1){RED_ON;if(!done){MOTOR_CW;done=1;}}
    if(CUT1){for(i=9;i>=0;i--){PORTB=seg[i];delayms(700);}
    BEEP;GREEN_ON;MOTOR_ACW;}
    }
  }
 return 0;
}


Note: After making this project I realize some limitation, first it required different type of IR sensors which should not detect human interrupt and second thing is at gate closing time if any vehicle present in between and below the gate then gate should detect the presence of any vehicle or obstacle. If you resolve these then please share.

Downloads: Complete Code with HEX File & Circuit Diagram
Print This Post

Unread post Thu Apr 11, 2013 9:12 pm » Firefox 13.0.1 Firefox 13.0.1  Windows Seven 64 bits Windows Seven 64 bits  Screen Resolution: 1366 x 768 1366 x 768
NareshKumar User avatar
rank1
rank1

Posts: 2
Has thanked: 0 time
Been thanked: 0 time
Gender: None specified
Blog: View Blog (0)
Engineering Discipline: Choose Your Discipline....

hi sir im naresh kumar , team mate with grish nautiyal , working for this project , a very thank you for guiding for this project ......

once again thank you sir....
^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^
Print This Post

Unread post Thu Apr 11, 2013 10:11 pm » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows Seven 64 bits Windows Seven 64 bits  Screen Resolution: 1280 x 800 1280 x 800
Core Engineer User avatar
Site Admin
Site Admin

Chilling at Core Engineers


Posts: 467
Images: 1069
Location: New Delhi
Country: India (in)
Has thanked: 5 times
Been thanked: 15 times
Gender: Male
Blog: View Blog (1)
Engineering Discipline: Electrical & Electronics

hi sir im naresh kumar , team mate with grish nautiyal , working for this project , a very thank you for guiding for this project ......

once again thank you sir....
^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^ ^:)^


:-! You Are Always Welcome Bro ! :) :ceian: :ymhug: :-bd
Print This Post

Unread post Fri Apr 12, 2013 10:02 am » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows NT 64 bits Windows NT 64 bits  Screen Resolution: 1024 x 768 1024 x 768

Posts: 4
Location: Dehra Dun, India
Has thanked: 2 times
Been thanked: 0 time
Gender: None specified
Blog: View Blog (0)
Engineering Discipline: Choose Your Discipline....

sir i want use in my project rf trans rcvr, and also a weight sensor with ir sensor is this possible....
Print This Post

Unread post Fri Apr 12, 2013 10:34 am » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows Seven 64 bits Windows Seven 64 bits  Screen Resolution: 1280 x 800 1280 x 800
Core Engineer User avatar
Site Admin
Site Admin

Chilling at Core Engineers


Posts: 467
Images: 1069
Location: New Delhi
Country: India (in)
Has thanked: 5 times
Been thanked: 15 times
Gender: Male
Blog: View Blog (1)
Engineering Discipline: Electrical & Electronics

sir i want use in my project rf trans rcvr, and also a weight sensor with ir sensor is this possible....


1. For What purpose You Want to Use RF Transciever with what module do you wanna communicate?
2. Wight Sensor with IR sensor I didn't understand?
3. If you wanna use Weight Sensor, Write, Sensor name or module name with shop link
4. Why and where you wanna use weight sensor and Rf Transceiver?

Answer these ASAP ! :ceian: :!!
Print This Post

Unread post Fri Apr 12, 2013 12:36 pm » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows NT 64 bits Windows NT 64 bits  Screen Resolution: 1024 x 768 1024 x 768

Posts: 4
Location: Dehra Dun, India
Has thanked: 2 times
Been thanked: 0 time
Gender: None specified
Blog: View Blog (0)
Engineering Discipline: Choose Your Discipline....

sir i would send u block diagram of this, plese tel me how can this possible.
Print This Post

Unread post Fri Apr 12, 2013 12:40 pm » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows NT 64 bits Windows NT 64 bits  Screen Resolution: 1024 x 768 1024 x 768

Posts: 4
Location: Dehra Dun, India
Has thanked: 2 times
Been thanked: 0 time
Gender: None specified
Blog: View Blog (0)
Engineering Discipline: Choose Your Discipline....

sir i sent u block diagram for my project.
Print This Post
You do not have the required permissions to view the files attached to this post.

Unread post Fri Apr 12, 2013 12:57 pm » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows Seven 64 bits Windows Seven 64 bits  Screen Resolution: 1280 x 800 1280 x 800
Core Engineer User avatar
Site Admin
Site Admin

Chilling at Core Engineers


Posts: 467
Images: 1069
Location: New Delhi
Country: India (in)
Has thanked: 5 times
Been thanked: 15 times
Gender: Male
Blog: View Blog (1)
Engineering Discipline: Electrical & Electronics

The above project is doing the same as the block diagram mentioned, in the case of this block diagram when train comes from the top side the sensor detects send the output via RF1 to the crossing station to close the Gate, And when when train comes from the top side the sensor detects send the output via RF2 to the crossing station to close the Gate.

In case of the above project this RF1, RF2 is replaced via a wired link instead of wireless to avoid packet losses and weather dependencies that occur frequently in wireless communication. And yeah its an accident avoiding project so it should be highly reliable.

Hope You understood what i wanted to say :)



Block Diagram of Automatic Railway Gate Crossing Control System
Print This Post

Unread post Sat Apr 20, 2013 11:28 pm » Firefox 5.0.1 Firefox 5.0.1  Windows Seven Windows Seven  Screen Resolution: 1366 x 768 1366 x 768

Posts: 4
Location: Dehra Dun, India
Has thanked: 2 times
Been thanked: 0 time
Gender: None specified
Blog: View Blog (0)
Engineering Discipline: Choose Your Discipline....

gud ev. sir i hv some quaries about my project kindly suggest me
1- which atmega will be used (8l 8pu) or (8 16pu)
2-programe burn fuse setting
3-what should be crystal value
4- burn time optimization and frequancy.
Print This Post

Unread post Sun Apr 21, 2013 12:09 am » Google Chrome 26.0.141 Google Chrome 26.0.141  Windows Seven 64 bits Windows Seven 64 bits  Screen Resolution: 1280 x 800 1280 x 800
Core Engineer User avatar
Site Admin
Site Admin

Chilling at Core Engineers


Posts: 467
Images: 1069
Location: New Delhi
Country: India (in)
Has thanked: 5 times
Been thanked: 15 times
Gender: Male
Blog: View Blog (1)
Engineering Discipline: Electrical & Electronics

gud ev. sir i hv some queries about my project kindly suggest me
1- which atmega will be used (8l 8pu) or (8 16pu)
2-programme burn fuse setting
3-what should be crystal value
4- burn time optimization and frequency.


  1. If Possible Go for Atmega8-16 PU Otherwise You can use Atmega8L-8 PU as we are not using frequency greater than 8 MHz in this project.
  2. Set High Fuse = D9(Hex) Low Fuse = D4(Hex).
  3. We are using Atmega internal Oscillator so no need to use External Crystal, As You can see in the circuit diagram, i have not connected any crystal t atmega.
  4. Set Optimization as "O2" and CPU frequency as 1000000Hz.
Print This Post

Next

Return to Projects | Ideas & Showcase | Seminar Topics


Get Social With Us !




Googlepage: GooglePullerPage