PLC-LADDER LOGIC-ATMEGA8

Photo of author

By Jackson Taylor

Micro-controller –Atmel AVR ATmega8 28-PDIP’

Crystal frequency—16.000000 MHz 

HOW TO COMPILE AND UPLOAD LDMICRO PROGRAM FOR ATMEGA8

YouTube video

Proteus simulation for atmega8

YouTube video

1) Digital input and output

Pin D1 will be high when a digital high is given at pin D0

LADDER DIAGRAM:

   ||                     ||
   ||       Xd0          Yd1       ||
1 ||-------] [--------------( )-------||
   ||                     ||
   ||                     ||
   ||                     ||
   ||------[END]-------------------||
   ||                     ||
   ||                     ||

I/O ASSIGNMENT:

NameTypePin
Xd0digital in2
Yd1digital out3

2) Input negated digital switch

Pin B0 in Microcontroller will be high when a digital low is given at pin B6

LADDER DIAGRAM:

   ||                     ||
   ||       Xb0          Yb6       ||
1 ||-------]/[--------------( )-------||
   ||                     ||
   ||                     ||
   ||                     ||
   ||------[END]-------------------||
   ||                     ||
   ||                     ||

I/O ASSIGNMENT:

NameTypePin
Xb0digital in27
Yb6digital out28

3) TON TIMER

The pin RB5 will on after one second delay after program starts

LADDER DIAGRAM:

   ||                     ||
   ||        Tnew         YRB5       ||
1 ||--[TON 1.000 s]---------( )-------||
   ||                     ||
   ||                     ||
   ||                     ||
   ||------[END]-------------------||
   ||                     ||
   ||                     ||

I/O ASSIGNMENT:

NameTypePin
YRB5digital out19
Tnewturn-on delay

4) XOR Gate

LADDER DIAGRAM:

   ||                       ||
   ||       XD0          XD1          YB5       ||
1 ||-------] [--------------]/[------+-------( )-------||
   ||                     |               ||
   ||       XD0          XD1       |               ||
   ||-------]/[--------------] [------+               ||
   ||                                          ||
   ||                                          ||
   ||------[END]-------------------------------||
   ||                                          ||
   ||                                          ||

I/O ASSIGNMENT:

NameTypePin
XD0digital in2
XD1digital in3
YB5digital out19

5) OR Gate

LADDER DIAGRAM:

   ||                     ||
   ||       XDO          YB5       ||
1 ||-------] [------+-------( )-------||
   ||                |               ||
   ||       XD1      |               ||
   ||-------] [------+               ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||------[END]-------------------||
   ||                     ||
   ||                     ||

I/O ASSIGNMENT:

NameTypePin
XD1digital in3
XDOdigital in2
YB5digital out19

6) AND Gate

LADDER DIAGRAM:

   ||                       ||
   ||       XD0          XD1          YPB5       ||
1 ||-------] [--------------] [--------------( )-------||
   ||                       ||
   ||                       ||
   ||                       ||
   ||------[END]-------------------------------||
   ||                       ||
   ||                       ||

I/O ASSIGNMENT:

NameTypePin
XD0digital in2
XD1digital in3
YPB5digital out19
See also
BOOST CONVERTER USING ARDUINO - SIMULATION IN PROTEUS

7) ADC with digital output

LADDER DIAGRAM:

   ||                     ||
   ||                     A5    ||
1 ||----------------{READ ADC}----||
   ||                     ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||     [A5 <]         YD3       ||
2 ||-----[ 500]-------------( )-------||
   ||                     ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||     [A5 >]         YD4       ||
3 ||-----[ 499]-------------( )-------||
   ||                     ||
   ||                     ||
   ||                     ||
   ||------[END]-------------------||
   ||                     ||
   ||                     ||

I/O ASSIGNMENT:

NameTypePin
YD3digital out5
YD4digital out6
A5adc input28

8) UART

Send the letter “J” over uart

LADDER DIAGRAM:

   ||                ||
   || {A  :=       }  ||
1 ||-{ 'J'     MOV}--||
   ||                ||
   ||                ||
   ||                ||
   ||                ||
   ||        A        ||
2 ||---{UART SEND}---||
   ||                ||
   ||                ||
   ||                ||
   ||------[END]------||
   ||                ||
   ||                ||

9) Sending ADC result over UART

Here i have converted 10-bit ADC result into 8- bit data(ASCII code) by dividing by 4 for proper UART reading

LADDER DIAGRAM:

   ||                     ||
   ||                     A5    ||
1 ||----------------{READ ADC}----||
   ||                     ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||       {DIV  B  :=}          ||
2 ||-----------{ A5 / 4   }-----------||
   ||                     ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||        B                ||
3 ||---{UART SEND}---           ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||            {D  :=   }       ||
4 ||----------{ 13      MOV}--||
   ||                     ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||        D                ||
5 ||---{UART SEND}---           ||
   ||                     ||
   ||                     ||
   ||                     ||
   ||------[END]-------------------||
   ||                     ||
   ||                     ||

I/O ASSIGNMENT:

NameTypePin
A5adc input28
BUART tx3
DUART tx3