PLC Based Automatic Railway Gate Controller and Obstacle Detector