Friday, 24 June 2016

TIMER PROGRAMMING

TIMER PROGRAMMING
(Toggle LED using timer programming ON time delay greater than 3 times OFF time delay)
v What is timer?
Timer is a clock that controls the sequence of an event while counting in fixed intervals of time. A Timer is used for producing precise time delay. Secondly, it can be used to repeat or initiate an action after/at a known period of time. This feature is very commonly used in several applications. An example could be setting up an alarm which triggers at a point of time or after a period of time.
v Types of timer?
Two types of timer in 8051
Ø  Timer0
Ø  Timer1


Timer0 register



D15
D14
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0


Timer1 register



D15
D14
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0


TMOD register
GATE
Timer/counter
M1
M0
GATE
Timer/Counter
M1
M0

GATE
Gate=0 Internally run timer
Gate=1 External pin are used for timer run
TIMER/COUNTER
C/T=0 for Timer mode
C/T=1 for Counter mode
MODE

M1
M0
Mode description
0
0
13 bit timer/counter mode
THx= 8 bit
TLx= 5 bit
0
1
16 bit timer/counter mode
THx=8 bit
TLx= 8 bit
1
0
 8 bit auto reload mode
THx=TLx
1
1
Split mode

TCON register
TF1 = Timer1 overflow flag
TR1 = Timer1 run flag
TF0 = Timer0 overflow flag
TR0 = Timer0 run flag

Timer calculation
Clock frequency of atmel microcontroller = 11.0592 MHZ
Time period =1/11.0592
Time period = 1.085 microsecond
For 5 ms second delay generate
                             =5 ms/ 1.085 us
                             =4608
For TH and TL value = 65536 – 4608
                               = 60927
60927 convert into hex value = EDFFh
TH=EDh
TL=FFh               


Basic programming in C

Basic C structure




C Datatype

Type
Size
Value
Unsigned Char
8 bit
0 to 255
Signed char
8 bit
-128 to +127
Unsigned int
16 bit
0 to 65536
Signed int
16 bit
-32768 to +32768

Statement in C

  1. "if" statement
  2. "if...else" statement
  3. "else...if" statement
  4. "switch...case" statement
  5. "while loop" statement
  6. "Do...while loop" statement
  7. "for loop" statement 

if Statement

It takes an expression in parenthesis and a statement or block of statements. if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.
Flow chart of if statement
if(condition1)

     {

      statement1;
      statement2;

     }
statement3;
statement4;

else...if Statement

It takes an expression in parenthesis and a statement or block of statements. if the expression is true then the statement or block of statements gets executed otherwise second condition check if this expression is true then statement gets execute otherwise statement skipped.
Flowchart of  else...if statement
if(condition1)

     {

      statement1;
      statement2;

     }
else...if(condition2)
    {
     statement3;
     statement4;
    }

if...else Statement

It takes an expression in parenthesis and a statement or block of statements. if the expression is true then the statement or block of statements gets executed if the expression is false then other statement are executed.
Flow chart of if...else statement
if(condition1)

     {

      statement1;
      statement2;

     }
else
    {
     statement3;
     statement4;
    }

Switch...case Statement

The switch statement is much like a nested if .. else statement. Its mostly a matter of preference which you use, switch statement can be slightly more efficient and easier to read.

switch(n)
   {
     case 0 : statement1;
     case 1 : statement2;
     case 2 : statement3;
     case 3 : statement4;
     default : default statement;
    } 

While loop statement

The most basic loop in C is the while loop.A while statement is like a repeating if statement. Like an If statement, if the test condition is true: the statments get executed. The difference is that after the statements have been executed, the test condition is checked again. If it is still true the statements get executed again.This cycle repeats until the test condition evaluates to false.
Flow chart of while loop statement
while(condition)

     {

      statement1;
      statement2;

     }
statement3;
statement4;

Do...while loop statement

do ... while is just like a while loop except that the test condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed at least once.
Flow chart of do...while loop
do

     {

      statement1;
      statement2;

     }
while(condition)

statement3;
statement4;

for loop statement

for loop is similar to while, it's just written differently. for statements are often used to process lists such a range of numbers.

for(initialization;condition;increment/decrement)  // for(m=0;m<10;m++)
      {
      statement1;
      statement2;
      }
statement3;
statement4;

Friday, 29 April 2016

ALLEAN BREADLY AND SIEMENS PLC

ALLEAN BREADLY


PLC Series : SLC 500, SLC 5100, SLC 5000
INPUT port : 24
OUTPUT port : 16
Programming Software : RSLogix 500
Communication software : RSLinx
Address : (i) Input :- I:0/0
                (ii) Output :- O:0/0

                (iii) Memory :- B3:0/0
For Allean Breadly PLC software RSLogix 500 and RSLinx work with PLC and with emulator(without PLC) Configuration of Allean Breadly PLC in below PDF file.

With PLC : With PLC Configuration

Without PLC : Without PLC Configuration (emulator)


SIEMENS



PLC Series : S300, S1200, S200, S1400
INPUT port : 16
OUTPUT port : 8
Programming & Communication Software :
1.     SIMATIC MANAGER  (S300)
2.     TIA Portal (S300, S1200, S1400)
3.     STEP-7 MICROWIN (S200)
·        Windows 7 -  V5.5
·        Windows XP – V5.4
·        Address :- (i)   Input – I124.0
                  (ii) Output – Q124.0
For Siemens PLC software Simentic manager work with PLC Configuration show below PDF file. 

With PLC : Seimens PLC Configuration