Скачиваний:
16
Добавлен:
10.07.2023
Размер:
975.62 Кб
Скачать

plc advanced functions - 16.26

16.6DESIGN CASES

16.6.1If-Then

Problem: Convert the following C/Java program to ladder logic.

void main(){ int A;

for(A = 1; A < 10 ; A++){ if (A >= 5) then A = add(A);

}

}

int add(int x){

x = x + 1; return x;

}

Solution:

plc advanced functions - 16.27

Program 2

S2:1/15

 

- first scan

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

Program 3

Figure 16.28 C Program Implementation

FOR

label number 0 index N7:0 initial value 1 terminal value 10 step size 2

JSR

Program File 3 Input par N7:0 Return par N7:0

NXT

label number 0

SBR

Input par N9:0

ADD

SourceA N9:0

SourceB 1

Dest N9:0

RET

Return par N9:0

16.6.2 Traffic Light

Problem: Design and write ladder logic for a simple traffic light controller that has a single fixed sequence of 16 seconds for both green lights and 4 second for both yellow lights. Use either stacks or sequencers.

Solution: The sequencer is the best solution to this problem.

Соседние файлы в папке PLC