Tuesday, 22 January 2013

PIC Tutorial Series -Basics of PIC Programming

ANSEL=0;   //INPUT AND OUTPUT ARE MADE DIGITAL
ANSELH=0; //INPUT AND OUTPUT ARE MADE DIGITAL

PORTB=0XFF; //RESET PORTB
TRISB=0; //ALL PINS OF PORTB ARE MADE AS OUTPUT.
Delay_ms(milliseconds); //USED TO MAKE DELAY IN LOOP EXECUTION OR HOLD THE PROCESS OF MICROCONTROLLER.
PORTB=0; //INITIAL STATE ASSIGNED AS 0 FOR PORTB.
PORTB=%10000001; //PINS OF PORTB SUCH AS RB0 AND RB7 ARE MADE AS HIGH AND OTHERS ARE MADE LOW.
PORTB=~PORTB;  OR PORTB= not PORTB; //INVERT THE STATE OF PORTB.



Sidharthan G
Electrical Miracles.

Tags:syntax,syntax for pic programming,basic syntax of pic,basics for pic programming.

PIC Tutorial Series-LCD Interfacing

This Program makes the LCD Display to interface with the PIC micro controller and display the characters.
// LCD module connections

sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

char txt1[] = "Electrical Miracles";   
char txt2[] = "PIC LCD Tutorial";
char txt3[] = "Lcd4bit";
char txt4[] = "example";

char i;                              // Loop variable

void Move_Delay() {                  // Function used for text moving
  Delay_ms(500);                     // You can change the moving speed here
}

void main(){
  ANSEL  = 0;                        // Configure AN pins as digital I/O
  ANSELH = 0;
  C1ON_bit = 0;                      // Disable comparators
  C2ON_bit = 0;
 
  Lcd_Init();                        // Initialize LCD

  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,6,txt3);                 // Write text in first row

  Lcd_Out(2,6,txt4);                 // Write text in second row
  Delay_ms(2000);
  Lcd_Cmd(_LCD_CLEAR);               // Clear display

  Lcd_Out(1,1,txt1);                 // Write text in first row
  Lcd_Out(2,5,txt2);                 // Write text in second row

  Delay_ms(2000);

  // Moving text
  for(i=0; i<4; i++) {               // Move text to the right 4 times
    Lcd_Cmd(_LCD_SHIFT_RIGHT);
    Move_Delay();
  }

  while(1) {                         // Endless loop
    for(i=0; i<8; i++) {             // Move text to the left 7 times
      Lcd_Cmd(_LCD_SHIFT_LEFT);
      Move_Delay();
    }

    for(i=0; i<8; i++) {             // Move text to the right 7 times
      Lcd_Cmd(_LCD_SHIFT_RIGHT);
      Move_Delay();
    }
  }
}


Sidharthan G
Electrical Miracles.

Tags:PIC tutorial,pic basics,introduction to pic basics,microcontroller programmimg,lcd interfacing,lcd interfacing with microcontroller,lcd interfacing with pic.

PIC Tutorial Series-Led Blinking Project For PIC Microcontrollers

It turns on/off LEDs connected to
     PORTA, PORTB, PORTC and PORTD
void main() {

  ANSEL  = 0;            // Configure AN pins as digital
  ANSELH = 0;
  C1ON_bit = 0;          // Disable comparators
  C2ON_bit = 0;

  TRISA = 0x00;          // set direction to be output
  TRISB = 0x00;          // set direction to be output
  TRISC = 0x00;          // set direction to be output
  TRISD = 0x00;          // set direction to be output
 
  do {
    PORTA = 0x00;        // Turn OFF LEDs on PORTA
    PORTB = 0x00;        // Turn OFF LEDs on PORTB
    PORTC = 0x00;        // Turn OFF LEDs on PORTC
    PORTD = 0x00;        // Turn OFF LEDs on PORTD
    Delay_ms(1000);      // 1 second delay
   
    PORTA = 0xFF;        // Turn ON LEDs on PORTA
    PORTB = 0xFF;        // Turn ON LEDs on PORTB
    PORTC = 0xFF;        // Turn ON LEDs on PORTC
    PORTD = 0xFF;        // Turn ON LEDs on PORTD
    Delay_ms(1000);      // 1 second delay
  } while(1);            // Endless loop
}

Friday, 14 December 2012

Automatic Train Operation(ATP)

Automatic Train Operation(ATP)

So far, we have only seen how ATP systems work on metros.  ATP is the safety system which ensures that trains remain a safe distance a part and have sufficient warning to allow them to stop without colliding with another train.  ATO (Automatic Train Operation) is the non-safety part of train operation related to station stops and starts.
The basic requirement of ATO is to tell the train approaching a station where to stop so that the complete train is in the platform.  This is assuming that the ATP has confirmed that the line is clear.  The sequence operates as shown below.

sig401.gif (3198 bytes) 

 The train approaches the station under clear signals so it can do a normal run in.  When it reaches the first beacon - originally a looped cable, now usually a fixed transponder - a station brake command is received by the train. The on board computer calculates the braking curve to enable it to stop at the correct point and, as the train runs in towards the platform, the curve is updated a number of times (it varies from system to system) to ensure accuracy.
London's Victoria Line, now 35 years old, has up to 13 "patches" checking the train speed as it brakes into a station. This high number of checks is needed because the on-board braking control gives only three fixed rates of deceleration.  Even then, stopping accuracy is ± 2 metres.    A detailed description of the Victoria Line's ATO system is here.    Modern systems require less wayside checking because of the dynamic and more accurate on-board braking curve calculations.  Now, modern installations can achieve ± 0.15 metres stopping accuracy - 14 times better.

Metro Station Stops

ATO works well when the line is clear and station run-ins and run-outs are unimpeded by the train ahead.  However, ATO has to be capable of adapting to congested conditions, so it has to be combined with ATP at stations when trains are closely following each other.  Metro operation at stations has always been a particular challenge and, long before ATO appeared in the late 1960s, systems were developed to minimise the impact when a train delayed too long at a station.
sig402.gif (3680 bytes)
 To provide a frequent train service on a metro, dwell times at stations must be kept to a minimum.  In spite of the best endeavours of staff, trains sometimes overstay their time at stations, so signalling was been developed to reduce the impact on following trains.  To see how this works, we begin with an example (left) of a conventionally signalled station with a starting Signal A1 (green) and a home Signal A2 (red) protecting a train (Train 1) standing in the station.  We can assume mechanical ATP (trainstops) is provided so the overlap of Signal A2 is a full speed braking distance in advance of the platform.
As Train 2 approaches, it slows when the driver sees the home Signal A2 at danger.  Even if Train 1 then starts and begins to leave the station, Signal A2 will remain at danger until Train 1 has cleared the overlap of Signal A1.  Train 2 will have to stop at A2 but will then restart almost immediately when Signal A2 clears.  This causes a delay to Train 2 and it requires more energy to restart the train.  A way was found to allow the second train to keep moving.  It is called multi-home signalling.

Multi Home Signalling - Approach

sig403.gif (6982 bytes)
Where multi-home signalling is installed at a station (left), it involves the provision of more but shorter blocks, each with its own signal.  The original home signal in our example has become Signal A2A and, while Train 1 is in the platform, it will remain at danger.  However, Block A2 is broken up into three smaller sub-blocks, A2A, A2B and A2C, each with its own signal.  They will also be at danger while Train 1 is in the platform.  Train 2 is approaching and beginning to brake so as to stop at Signal A2A.
When Train 1 begins to leave the station, it will clear sub-block A2A first and signal A2A will then show green.  Train 2 will have reduced speed somewhat but can now begin its run in towards the platform.

Multi Home Signalling - Run In

sig404.gif (6926 bytes)
 At this next stage in the sequence, we can see (left) that Train 1 has now cleared two sub-blocks, A2A and A2B, so two of the multi-home signals are now clear.  Note that the starting signal is now red as the train has entered the next block A1.  Train 2 is running towards the station at a reduced speed but it has not had to stop.
When Train 1 clears the overlap of signal A1, the whole of block A2 is clear and signal A2C clears to allow Train 2 an unobstructed run into the platform.

ATO/ATP Multi Home Signalling

sig405.gif (7513 bytes)
 Fixed block metro systems use multi-home signalling with ATO and ATP.  A series of sub-blocks are provided in the platform area.  These impose reduced speed braking curves on the incoming train and allow it to run towards the platform as the preceding train departs, whilst keeping a safe braking distance between them.  Each curve represents a sub-block. Enforcement is carried out by the ATP system monitoring the train speed.  The station stop beacons still give the train the data for the braking curve for the station stop but the train will recalculate the curve to compensate for the lower speed imposed by the ATP system.

ATO Docking and Starting

sig406.gif (3173 bytes)
 In addition to providing an automatic station stop, ATO will allow "docking" for door operation and restarting from a station.  If a "driver", more often called a "train operator" nowadays, is provided, he may be given the job of opening and closing the train doors at a station and restarting the train when all doors are proved closed.  Some systems are designed to prevent doors being opened until the train is "docked" in the right place.  Some systems even take door operation away from the operator and give it to the ATO system so additional equipment is provided as shown left.
When the train has stopped, it verifies that its brakes are applied and checks that it has stopped within the door enabling loops.  These loops verify the position of the train relative to the platform and which side the doors should open.  Once all this is complete, the ATO will open the doors.  After a set time, predetermined or varied by the control centre as required, the ATO will close the doors and automatically restart the train if the door closed proving circuit is complete.  Some systems have platform screen doors as well.  ATO will also provide a signal for these to open once it has completed the on-board checking procedure.  Although described here as an ATO function, door enabling at stations is often incorporated as part of the ATP equipment because it is regarded as a "vital" system and requires the same safety validation processes as ATP.
Once door operation is completed, ATO will then accelerate the train to its cruising speed, allow it to coast to the next station brake command beacon and then brake into the next station, assuming no intervention by the ATP system.

Sidharthan G
electricalmiracles.

Tags:Automatic train operation,train operation,metro train control,chennai metro,chennai metro rail,metro rail. 

 

Sunday, 9 December 2012

PICsim - PIC microcontroller simulator

PICsim - PIC microcontroller simulator 

Download
Sidharthan G
electricalmiracles. 
Tags:PICsim,PIC microcontroller simulator,download free.

Sunday, 4 November 2012

LED Blinking PIC16F877A

void main()
        {
        TRISB = 0 ;     // set PORTB as OUTPUT         for(;;)         // forever
                {
                PORTB = 0xff ;          // turn all LEDs ON
                Delay_ms(500) ;         // wait 500 ms
                PORTB = 0 ;             // turn all LEDs OFF
                Delay_ms(500) ;         // wait 500 ms
                }
        }

Sidharthan G
electricalmiracles.
 

Friday, 2 November 2012

Components Of Electrical Substation


A:Primary power lines' side B:Secondary power lines' side
1.Primary power lines 2.Ground wire 3.Overhead lines 4.Transformer for measurement of electric voltage 5.Disconnect switch 6.Circuit breaker 7.Current transformer 8.Lightning arrester 9.Main transformer 10.Control building 11.Security fence 12.Secondary power lines
Sidharthan G
electricalmiracles. File:Electrical substation model (side-view).PNG