07.03.2014 Views

Introduction.

Introduction.

Introduction.

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Workshop PG5<br />

Resources<br />

Counter Example:<br />

We will program a counter which counts up each time the input 5 receives a<br />

signal. Each time input 6 receives a signal, the counter will count down. (the<br />

counts will be activated on the rising edge of the input signal). The counter can<br />

be set to zero with a high on input 2. We will load the initial count with 3.<br />

This is just an example. If you are a little confused, don’t worry you will understand<br />

it better once we start actually writing some programs.<br />

Load the counter:<br />

LD C 35<br />

3<br />

Integer value:<br />

Increment the counter:<br />

INC C 35<br />

Read the counter content<br />

and display it on the output<br />

LD C 35<br />

0<br />

Binary value:<br />

Q equals high if the counter content<br />

is not zero.<br />

STH C 35<br />

Solution:<br />

Instruction list program: FUPLA program:<br />

COB 0 ;Cyclic organization block<br />

0 ;<br />

STH I 1 ;If input 1 equals 1<br />

LD C 35 ;then load the counter 35<br />

3 ; with 3<br />

STH I 2 ; If input 2 equals 1<br />

LD C 35 ; then load the counter<br />

0 ; with zero<br />

STH I 5 ;If there's a rising edge<br />

DYN F 13 ;on input 5<br />

INC C 35 ;then increment the counter 35<br />

STH I 6 ;If there's a rising edge<br />

DYN F 14 ;on input 6<br />

DEC C 35 ;then decrement the counter<br />

ECOB<br />

( FBox:<br />

Counters, UP-Down pre-set and<br />

clear)<br />

© Saia-Burgess Controls Ltd. Page 3-9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!