You are on page 1of 16

Chapter 10 The Programmable Logic Controller (PLC)

Introduction
This chapter will describe the 12 input/12 output PLC embedded in the ACR1000 controller. All the inputs
and the outputs can be user defined for various purposes. Each output can be thought to be coming from a
"contact" of a S()ftware "relay". The ladder diagcam described by the programmer in the fonn of the PLC
program will result in these relays being energized or de-energized. Thus the outputs, that are derived
from the contacts of these relays will change according to the flow of the PLC program. Similarly, each
input can be tholught of as a contact of some relay. A relay can be either in the energized state or the deenergized state. A contact can be either closed or open. Each relay has nonnally open (N.O) and nonnally
closed (N.C) contacts associated with it. The nonnal state of the relay is de-energized. Thus. the nonnally
open (N.O) contact will become closed only if the relay is energized. Programming.the PLC is done using
POKE commands to write code into the PLC memory. PLC programming is explained later.

01

02
I

+1@1------t

RELAY & CONTACT SYMBOLS

PLC Execution
After the user enters the PLC program into the controller. the program has to be activated by the PON
command. This command checks the entire PLC program for errors. This check only verifies that valid
command codes are used; no check is made for correct relay addresses or program logic. An "INVALID
PIC PGM ERR" will be returned if a problem is found. If all is OK, the timers, counters. sequencer and
scan counter are~ all initialized and the PLC program becomes active. (See the additional PON command
options in Chapt'er 7.) The ACR1000 controller will start to SCAN the entire PLC program on a regular
basis over and over again. The approximate time to scan the entire PLC program is 6 milliseconds. This
defines the SCAN TIME to do one SCANLOOP.

Categorizing

The~

Inputs And Outputs

12 inputs and 13 outputs are available to the user at the pins of the interface connector P3 and P4.
However the PLe program that the user writes can actually utilize many more internal relays to do the
application. These relays can be categorized into three different classes.
The first class consists of internal relays that the PLC program cannot change but may use (without limit)
as needed in the ladder. All relays that have addresses in tne range 84 .. 120 and the 12 inputs that are
available at the interface plug [addresses 00 through 11) are examples of this first class of relays. Note:
Attempting to control inputs from the PLC will not generate an error but can cause trouble.
The second category consists of relays that the PLC program can sense and completely control. The 12
outputs available on the interface plug.addresses 12 - 23 and 117. are of this type.
The third category consist of relays that the PLC program can sense and control but they are not brought
out to any plug. These relays are called internal relays [addresses 24 through 83J. The purpose of these
relays is to store temporary results and are valuable in a typical ladder diagram. Note: Relays 24 through
55 (24 - 31JorvS.x) are special relays used in the sequencer shifter. They should only be used as general
purpose relays if the shifter is not being used.
Each relay is used by referring to its address. The address will uniquely identify each of the many different relays available. The address is used to reference both the relay coil as well as its contacts.
The PLC program should only control an output in one place. If there are two places in the program that try
to control the state of the same relay coil, the ladder may not work properfy and the PON command will
generate an "IN\l.ALlD PIC PGM ERROR". If it is desirable to control an output in more than one place,
using the PON! oommand will eliminate this error check-this feature should be used with caution.

Timers
To implement a t~fpical PLe program, it is necessary at times to "time-out" for a specific interval. For this
Chapter 10, The Program,mable Logic Controller (PLC)

63

purpose, 4 timers are C:lvailable. The timers will time-out in 0.01 second intervals from 0.01 to 25.59
seconds. The internal counting pulse for the timer comes every 0.01 second. The following relays are
provided for controllingl the timer. The x argument may be 0,1,2 or 3.
TIMx When this rela:y is energized by the PLC program, TIMx wiD start to count up to its desired value.
When this relay is de-energized, the timer goes back to count of zero.
TIMxF After TIMx finishes its count, relay TIMxF will become energized and the timer stop counting.

The command to set the timer value is STIMX YYY and is explained in Section 10.9.3. An aHemate way is
to use the POKE command. Each timer uses 2 bytes for holding its timer values. The number of 0.1
second counts are stored in hex locations 4011,4012,4013,4014 for TIMERO through TIMER3 respectively.
The number of 0.01 second counts are stored in hex locations 4019, 401A. 4018, 401~ fgrTIMERO
through TIMER3 respel::tively. Locations 4019 through 401C can only take values from 0 through 9. For
proper TIMER operation, both the 0.1 as well as 0.01 locations must be initialized.

59

Tim 1

-1~
Timer 0

~I----

A. Contact

TIMERS

Timer 1
B. Coil

Experimenting With Tiimers


To gain familiarity with the TIMERS the following exercise will load a value of 0.95 seconds into TIMERO
and watch it count up.

10 POKE 4011=9
20 POKE 4019=5
25 PON
30 CLR 59
40 INH -84
50 SET 59
60 IF 108
o THEN PRINT "0"
70 IF 108 = 1 THEN PRINT "1"
80 IF 108 = 2 THEN PRINT "2"
90 IF 108 = 3 THEN PRINT "3"
100 IF 108
4 THEN PRINT "4"
110 IF 108 = 5 THEN PRINT "5"
120 IF 108 = 6 THEN PRINT "6"
130 IF 108
7 THEN PRINT "7"
140 IF 108
8 THEN PRINT "8"
150 IF 108
9 THEN PRINT "9"
160 IF 108 = 10 THEN PRINT "10"
170 IF--64 -= 0 THEN GOTO 60
180 PRINT "TIMER TIMED OUT!"
190 GOTO 30
The TIMERS have 0.01 :second resolution. At address-4011, load how many 0.1 second counts that you
need and load 4019 with the remaining 0.01 second counts. This might seen confusing but it is quite
simple. For a time-out of 0.95 seconds, there are 9 counts of 0.1 seconds and 5 counts of 0.01 seconds.
- Therefore the HEX equivalent of 9 must be loaded into 4011 and the HEX equivalent of 5 must be loaded
into 4019. These are the values of 9 and 5 res~vely. This is done in lines 10 and 20. Line 30 dears the
TIMO relay and line 40 waits for the TIMOF relay to clear. This waiting MUST be done because it gives the
system enough time to sense that the TIMO relay has been cleared and allow for resetting the timer. This
three step procedure must be followed before a timer is ready to be used. Line 50 then, sets the TIMO
relay again, allowing the TIMERO to start timing. Une 60 through 160 checks the status of 108 (which is
the 0.1 second counter byte of TIMO) and displays the contents on the terminal. Note that it is not possible

ACR1000 User's Guide

64

11

to simply say PRINT 108. Une 170 checks relay TIMOF (84) which will be ON if the TIMERO has timed out.

Counters
To implement a typical PLC program, it is necessary at times to count occurrences of various events. For
this purpose, 4 COUNTERS are provided. Each counter has a COUNT relay, RESET relay and a COUNT
FINISHED RElAY associated with it. The count relay should be energized and de-energized once to make
the counter count up by one. The reset should be energized and de-energized once to zero the counter.
The counters can be made to count any number between 1 and 255. When the counter reaches its target
count, all subsequent count commands are ignored and the COUNT ANISHED relay is energized.
Therefore, the Pl.C program controls the COUNT and RESET relays but senses the contads of the
COUNT FINISHED relay for each counter. x may be 0, 1, 2 or. 3. -.
CNTx When this relay is energized from a de-energized state, CNTx will count up-by 1 if it has not
already reached its final count.
When this relay is energized, CNTx is zeroed and relay CNTxF will become de-

RESET CNTx
energized.
CNTxF

This will energize when CNTx reaches its final count.

The command to set the counter value is SCNTX yyy. An aHemate way is use the POKE command. The
hex locations 4015.4016,4017 and 4018 should be loaded with the desired count value for COUNTERO
through COUNTER3 respedively.

Tim 1

----tet----

A. Reset CNT 1
Coil

B. CNT

a Coil

64

--1~
C. CNT 0 Contact

COUNTER COILS and CONTACTS


Experimenting V~ith Counters
To gain familiarit)' with the working of counters. the following exercise will load a counter with a value of 10
and watch it count up_ Note that the COUNTERS can count between 1 and 255.
10 POKE 4015= OA
15 PON
20 CLR 63
30 SET 67
40 INH -88
50 CLR 67
60 CLR 63
70 OWL 10
80 SET 63
90-0WL 10
110 IF 112 = 1 THEN PRINT"I"
120 IF 112 = 2 THEN PRINT"2"
130 IF 112 = 3 THEN PRINT"3"
140 IF 112 = 4 THEN PRINT"4"
150 IF 112 = 5 THEN PRINT"5"
160 IF 112 = 6 THEN PRINT"6"
170 IF 112 = 7 THEN PRINT"7"
180 IF 112 = 8 THEN PRINT':'8"
190 IF 112 = 9 THEN PRINT"9"
200 IF 112 = 10 THEN PRINT"10"
210 IF B8 = 0 THEN GOTO 60
220 PRINT "COUNTER HAS COUNTED OUT"
230 GOTO 20

Chapter 10, The Programrnable Logic Controller (PLC)

65

11

This example requires ,a count of 10. The HEX equivalent of 10 is OA. Une 10 POKES this value into
4015. Line 20 dears CNT 0 relay (in case it was not in the proper state). Line 30 sets the RESET CNT 0
relay to clear the counter count Une 40 WAITS until the system has had a chance to see the RESET CNT
o relay and CLEARS the counter. This must be done to ensure proper operation I Une 50 then clears the
RESET CNT 0 relay. Now the counter is sitting at count of ZERO. Une 60,70 and 80 pulse the CNTO relay
to make it count up by Clne count This delay is necessary to allow the system time to see the count pulse.
Note that the counters c::aunt on the LOW to HIGH transition. So when ever the CNTO relay goes from the
cleared state to the ENERGIZED state, the counter will count by one. Lines 90 through 200 print the value
of the counter on the terminal screen. Note that it is not possible to just say PRINT 112. The IF command
must be used for this purpose. Une 210 checks CNTOF relay to see if the COUNTER has counted out.

Sequence Shifter
To control the flow of a sequence in an application, a 32 bit shifter is provided ( 8 bits for vS.x). This
shifter can be thought olf as a 32(8) bit circular shift register. There are 32(8) relays (SEQ9-~.SEa31 or
SEaO.. SEa7) associatt~ with it that can be- usOO in the PLe program. Of these 32(8) relays,only !U!! is
energized at any given moment. The shifter can be shifted left or right. Three relays are provided to
control the operation of the Sequence Shifter.
RESET SEQ
SHIFT SEQ
REVERSE SEQ

..... :.

This relay resets the sequencer. This means that relay SEQO is energized and SEQ1
through SEQ31 are d~nergized.
This relay should be energized for 1 scan time to shift the sequencer left or right
This relay should be d~nergized if the sequencer needs to shift in the order
SEQO,SEQ1,SEQ2... If this relay is energized, the shifting will be in the order
SEQO,SEQ31 ,SEQ30,SEQ29...

NOTE: The programmE~r must ensure that the RESET and SHIFT controls for the sequencer are only
adive for 1 scan loop else the shifter will shift several times thus causing unpredictable results. The
sequencer relays may be used as temporary or user defined relays if the sequencer is not being used.
Note however that SEa 0 is set on at start-up of the PLC and all the other sequencer relays are cleared.

Reset

~~
~~

SEQ

SEQ 1

Shift

~l~

SEQ 2

Reverse

~:~

SEQ 31

A. Control RetJays

B. Contacts

SEQUENCE SHIFTER

ACR1000 User's Guide

66

11

How To Address Input, Outputs, Timers, Counters & Sequencer


As explained be~fore, each input, output. etc. must be addressed by its unique identifier address. The
following tables list all the various addresses used in the PlC program as well as the commands SET,
CLR, INH, INT clOd IF. Chapter 7 explains these in detail. When using POKE commands to program the
PLC in machine code only use the HEX addresses.
The following are the addresses and pin locations of the inputs and outputs of the ACR1000.
Addres!a
OO/OOh
01/01h
02l02h
03/03h
04/04h
05/05h
O6I06h
07/07h
OS/08h
09/09h
10/0Ah
11/0Bh

DesCription
Input P4-2
Input P44
Input P4--6
Input P4-8
Input P4-10
Input P4-12
Input P4-14
Input P4-16
Input P4-18
Input P4-20
Input P4-22
Input P4-24

Address
1210Ch
1310Dh

1410Eh
1510Fh
16110h
17/11h
18112h
19/13h
20/14h
21/15h
22116h
23117h

Description
Output P3-2
Output ~
Output P3-6
.OtJ.!put P3-8
Output P3-10
Output P3-12
Output P3-14
Output P3-16
Output P3-18
Output P3-20
Output P3-22
Output P3-24

The following 32 (8 for VerS.O) relays are used for the sequence shifter. These can be used as temporary
rela s if the shifter is not used.
24/18h
Se 0
25119h
2611Ah
27/1Bh
2811Ch
2911Dh
30/1Eh
3111Fh

32f20h
33/21h
34l22h
35123h
36124h
37125h
3812Gh
39127h
40128h
41129h
4212Ah
43J2Bh
44I2Ch
45120
46/2Eh
4712Fh
48130h
49/31h
5O/32h
51133h
52/34h
53135h
54/36h
55137h

normal
SeqS
Seq9
Seq10
Seq11
Seq12
Seq13
Seq14
Seq15
Seq16
Seq17
Seq18
Seq19
Seq20
Seq21
Seq22
Seq23
Seq2+
Seq25
Seq26
Seq27
Seq28
Seq29
Seq30
Seq31

vS.x only
Y Feed hId Pushed
Y +Jog Request
Y -Jog Request
Y Cycle Start Request
Y Home Request
Yin Accet
Yin Decel
Y Moving
Y In Feed hId
Y Feed hId Complete
Y In Jog Mode
Y Feed Direction
Y Not In Position
Y Not Excess Error
Y Cancel Move
reserved)
reserved)
reserved)
reserved)
reserved)
reserved)
reserved)
reserved)
reserved)

The followin
56l38h
57139h
5813Ah

1\7

Chapter 10, The Programrnable Logic Controller (PLCJ

11

Th e ~0 IIoWing 4 re ays oontroIth e TIMERS


59/3Bh
TIMO
60/3Ch
TIM1
i
6113Dh
TIM2
TIM3,
,
/
6213Eh

Th e f 0 IIoWing 8 relays Olntro the COUNTERS.


6313Fh
CNTO
64/40h
CNT1
65141h
CNT2
66/42h
CNT3
67/43h
RESETCNTO
68/44h
RESETCNT1
69/45h
RESETCNT2
70/46h
RESETCNT3
T he ~0 IIoWing 11 relays may be used as the user wishes.
71/47h
UserO
72148h
User1
73149h
User2
74/4Ah
User3
The following 7 relays are not accessible from the main program using the SET,CLR.,INH and INT
commands
2411F1h
User4
2421F2h
UserS
2431F3h
User6
2441F4h
User7
245IFSh
UserS
2461F6h
User9
2471F7h
User10

75/4Bh

76/4Ch

77/40h

7814Eh
79/4Fh

.80/50h
81/51h

82152h

The follOwing 9 relays interact with axis movement. When energized in the PLC program, they request the
system to go into various modes. The two jog relays only work if the system is not in the program mode.
The Run Program RequE~st relay must only be pulsed. If it is left in the ON state, the program can not be
t ennlna
. t e d as th e sy:st ern WI'11 Imm
.
ed'lately
I resta rt th e program.
Feed hid Request
If this is set, an automatic ctrt-K command is done. The system will clear this relay
after starting a Feed hid cycle. Tt\is will stop motion and cancel any JOG in
progress.
Jog+ Request
If this is set, a JOG+ command is done. The system clears this relay after starting
the jog cycle. This command only works in the immediate mode. To jog within a
program use the JOG+ command.
Jog-Request
If this is set. a JOG- command is done. The system clears this relay after starting
the jog cycle. This command only works in the immediate mode. To jog within a
~rogram use the JOG- command.
Cycle Start Request
If this is set, an automatic ctrI-C command is done. The system clears this relay
after doinS a C~cle Start.
If this is set, an automatic ESC command is done. The system clears this relay after
Escape Request
escaping from a program or immediate mode command. NOTE: Controlling escape
request from within the PlC may cause odd behavior if this relay is held on. Escape
has the function of clearing out bufferS, stopping motion, terminating listings, and
sto~~ing ~rogram execution.
If this is set, an automatic RUN command is done. The system clears this relay after
Run Program Request
starting to run the ~rosram.
If this is set, an automatic HOWON command is done. The system clears this relay
Hand weel Mode RE~quest
. after starting the HOW mode.
If this is set, an automatic BLK command is done. The system clears this relay after
Block Mode Reques.t
acting on it
1
Home Sequence Re~uest
If this is set, an automatic HOME command is done. The system clears this relay
after starting the HOME ~cle.
f

83/53h

ACR1000 User's Guide

68

11

~.

The following relays can only be sensed by either the PLC or a AcroBasic program.
84/54h>.-... ."
TIMOF
85/55h
TIM1F
86156h
/' TIM2F
87/57h ..//
TIM3F
88l58h
CNTOF
89/59h
CNT1F
90/5Ah
CNT2F
CNT3F
91/5Bh
PON Clear
9215Ch
This relay is energized for 1 scan after the PLC is turned ON using the
PON command.
Incremental
93150h
In-Accel
94/5Eh
In-Oecei
95/5Fh
Axis Move In Progress
96/60h
97161h
In Feed hid Cycle
98/62h
Feed hid Cycle Over
99/63h
Jog Mode Active
100l64h
Minus Dir,ection Feed
101/65h
0.1 Second Pulse
This relay is active for 1 scan fNery 0.1 seconds.
118n6h
0.01 Second Pulse .
This relay is active for 1scan fNery 0.01 seconds. It can only be used in
the PLC. The PLC must be turned on for this to work.
102l66h
Run ModE! Active
103/67h
Hand weel Mode Active
104/68h
CLEAR as long as the following error is LESS than the IN-POSITIONNot-In-Position
BAND window set using the IPB command. The default is 8 pulses.
105/69h
SET as long as the following error is LESS than the EXCESS ERROR
Not-Excess-Error
window set using the EXC command.
106/93h
Not Primcuy Marker P1:5-6
107/92h
Not Aux. Marker P9:10-12
Addresses 106, 107 .and 117 are to be used by the I F command. The actual addresses are given in the hex
position. The hex addresses refer to actual counters and timers and not to the relays TIMO-TIM3 or CNTOCNT3. The TIM/CNT addresses can be loaded with a number in the range 0-255d100-FFh.
The minimum count resolution for TIMERS is 0.01 seconds. The number of 0.1 second counts needed are to
be entered into 4011, 4012, 4013, 4Q14. The number of 0.01 second counts need to be entered into hex 4019,
401A, 401 Band 401 C for TIMO-TIM3. This can be done in the PLC program or using the POKE command.
108d/4011h
109d14012h
110dl4013h
111d14014h
112d14015h
113d1~01Sh

114d14017h
115d14018h
(n.a. ~4019h
1n.a. dl401Ah
(n.a. dl401Bh
(n.a. dl401Ch
116d1(n.a.)h
117d194h
118J6Ah

0.1 s TimerOc
0.1s Timer1c
0.1s Timer2c
0.1s Timer3c
CountOc
Couht1c
Count2c
Count3.c
0.01s llmerOc
0.01s llmer1c
G.01s llmer2c
0.01s Timer3c
Outputs 12-23
User11 Rela"y
Cancel Move

required steps>
119d/(n.a.)h
120d/(n.a.)h

UNIDI~~ Enable
BACKLASH
Enable

This
This
This
This

the is
the is
the is
the is

0.1 s count
0.1 s count
0.1 s count
0.1 s count

for TimerOc J
for Timer1 c
for Timer2c
for Timer3c

This the is 0.01s count for TimerOc


This the is 0.01s count for Timer1c
This the is 0.01s count for Timer2c
This the is 0.01s count for Timer3c
SET 116 will tum on all outputs, CLR 116 will tum off all outputs.
External contacts available on P2:3,4,8
This relay is used to cancel a move currently in progress. This is useful in cases
where it is required to abort motion based on some occurrence, without stopping the
program. Both regular MOVE command indexes as well as JOG motion is stopped.
1. SET 118
2. INH -96:. REM Wait for the move to be over
3. CLR 118
This must be set to enable the unidirectional approach.
This must be set to enable the Backlash Compensation Mode.

>

Chapter 10, The Prograrrlmable Logic Controller (PLC)

69

PLC Command Set<E~


AND (82 XX)

AND-NOT (80 XX)


LOAD (A2XX)

This is the logical AND operative. In terms of the ladder, this command makes a series connection
on the current rung with the normally open contact of xx. For using a normally closed contact use
the AND-NOT command.
This is the AND-NOT operative. In terms of the ladder, this command makes the series connection
on the current rung with the normally closed contact of
This is the LOAD command. This command is used to start a new rung with the normally open
oontact of
To use the normally closed contact. use LD XX NOT.
This is the logical OR operative. In terms of the ladder. this command makes a parallel connection
To use the normally closed contact. use
onto the current rung with the normally open contact of
the OR-NOT command.
This is the logical OR NOT operative. In terms of the ladder, this command makes a parallel
o)nnection onto the current rung with the normally closed contact of
This is the logical NOT directive. This command is used as a post fix t9 a ~ntact number to obtain
its normally closed state versus the normally open state. As an example, the instruction LD 01 will
IOlad the current RUNG of the ladder with the normally OPEN contact of coil #1. On the other hand,
UJ 01 NOT will load the normally closed contact. Similarly, OR 01 NOT, AND 01 NOT, will act on
the normally closed contacts.
Completes the current rung in the ladder and assigns the result to the coil of relay
This commands signals the end of the ladder. This command must be the last command in the each
.BANK of the PLC program. The system will give an error if no END is found when the paN
cc)mmand is given.
NOTE: A better way to set the TIMER and COUNTER values is to use the POKE command in the
user program to directly enter values into locations 4011- 4018.
This comm~nd SETS TIMER x for counting in (O.01s) intervals. Where x =
1 For TIMO (0.15) intervals;
2 For TIM1 (O.1s) intervals;
3 For TIM2 (O.1s) intervals;
4 For TIM3 (0.15) intervals;
9 For TIMO (O.01s) intervals;
A For TIM1 (0.01s) intervals;
8 For TIM2 (0.015) intervals;
C For TIM3 (0.01s) intervals.
The W parameter is a number between 00 and FF. For example, to set TIMER #2 to count 6.54
seccmds, use 90,40,13,74,41,FO,90,40,1B,74,04,FO. NOTE: This does not start the timer but merely
initializes it The energizing of the TIM3 relay will activate the timer.
This command sets the COUNTER #x (x is 5,6,7 or 8 for CNTO.. CNT3) for counting a number
between 1 and 255. As an example, to set counter #2 to count to 100 and energize its associated
FINISH relay, use 90,40, 17,74,64,FO.

xx.

xx.

OR (72 XX)

xx.

OR-NOT (AO XX)


NOT (83)

xx.

xx.

OUT (92 XX)


END (22)

STIM x.,W
(90401x74yyFO)

SCNTx,W
(90401x74yyFO)

NOTE: All numbers xx clOd yyy are hexadecimal numbers.

Programming the PLC:


This sedion will describe the method of entering the PLC program into the ACR1000 memory using the
POKE and PEEK commands. This section will also describe all the codes for the various commands. To
understand the command in detail see chapter 7.

Memory Allocation
The PLC program mem()ry is organized as 383 bytes divided into 6 64 byte sections starting at location
4400 and continul.ng thrcmgh 457Fh. The user must begin entering the PLC program at the first location of
the 1st sedion (4400h).lf this section fills up, the PLC program can be continued on in the next sedion
and so on. Many simple PLCS will fit within a single sedion. Each section must end with a completed
rung, followed by an END (22h) command. Failure to put an END after the last rung in a section will result
.
in a "INVALID PIC PGl'1 ERR".

PLe Memory Organization


SCAN 1
SCAN2
SCAN3
SCAN4
SCANS
SCAN6

ACR1000 Users Guide

4400 to 443F
4440 to 447F
4480 to 44BF
44CO to 44FF
4500 to 453F
4540 to 457F

70

11

PLC Timing
Every 468 microseconds, the CPU executes one section of the PLC program. The following is the order of
execution:
r-1~.----'~U~p~d~at-e~II~O~.~P~L~C~T~IC~K~S-----------------------'

2.
3.

4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Scan 1
Scan2
Scan3
Scan4

ScanS
ScanS
TIMERSO,1
TIMERS1.2
COUNTER SO, 1
COUNTERS2.3
SEQUENCER
IGAIN
Status Requests (If any)
Status Requests (If any)

sse

Sixteen scans m.akes for a maximum of 7.5 milliseconds to scan through the entire PLC. However, when
the PLC comes across an empty user program section it will skip the remaining sections and continue on
with the TIMERS, etc. This allows smaller PLC programs to execute as fast as possible. with a 1 section
program looping every 4 milliseconds. This time increases by 468 microseconds for each program section
added. For this n~ason. make sure unused PLC sections have an END (22h) as the first command.
Addresses E1. E2. E3. E4. ES. E6 and E7 may be used to store intennediate results. To save a temporary
result, use the command 92xx where xx E1 .... E7. Keep in mind that the integrity of E1-E7 is only
reliable within each SCAN section. Their state is not to be trusted beyond the current scan. STIM and
SCNT instructions destroy the state of E1 ... E7.

Entering a PLe Program


PLC programs are entered into PLC memory using the POKE command (See chapter 7 for details on the
POKE command). Starting with the first PLC section (4400h). POKE the equivalent codes for PLC
commands into sequential locations. Keep aware of the 64 byte limit for each section, making sure that the
section ends with a complete rung of data and a 22 code. Note that the POKE command uses hexadecimal
values for both the address and the data, and use the hex values for relay addresses as shown earlier in
this chapter.
If the PLC rung is;
LD 04 AND 82 OR 06 OUT 12 END
the following POKE command will put it in the first PLC section:
POKE 4400=A2,04,82,60,72,06,92,OC,22

The easiest way to code a PLC program is to first draw out a ladder diagram. Then translate the ladder
symbols and connections to the standard PLC language (LD/ANDIORlOUT/etc.). It is then a simple matter
of substituting the! proper PLC codes and relay addresses (in HEX) and entering them via POKE
commands... _
Before starting your PLC program up, it is a good idea to verify that the codes have been properly entered.
The PEEK commcmd is provided for this purpose. Entering PEEK 4400,40 will list out the contents of the
first section of PLe memory. (See chapter 7 for more details of the PEEK command.)

It is good practice for the PLe program POKE commands to be part of your main ACR1000 program.
Putting these commands within the program is a good way to document the contents of the PLe and make
sure it remains with the program that depends on its operation_
Note that the POKE command turns the PLe off, so enter the PLe first, then execute the PON command to
get things running'.

71

Chapter 10, The Programalable Logic Controller (PLC)

11

PLC Programming Example 1

00

---1

01

0:2

~------------~-~

03

- - - - - - - - - - - -_ _~-:a.~--------

TIMO

---11.-.-.---01:
03

TIMO=35
PLC example 1
The following prograrn will implement the above ladder.
'_ ......
PLC code
90,40, 11,74,23,fO,90,40, 19,74,OO,FO
-A2,OO ~
80,01
72,02

92,14~

A2,03

82,54
92,OC~
A2,03
92(38)

22

ACR1000 Users Guide

Meaning
This assigns time-out of 3.5 seconds to TIMO.
Start the rung with N.O. contact of 0,
place in series with the N. C. contact of 1,
OR's the result to the normally open (N.O.) contact of input #2..
This assIgns the result to output #20 (14h).
Start the next rung with N.O. contact of 3
AND with the N. O. contact of TIMER 0,
assign the result to output 12.
Start the rung with N.O. contact of 3,
if 3 is open, TIMO starts countinQ.
This is the end of the PLC.

72

PLC Programming Example 2

01

02

03

04

02

03

04

~'----I

--1

PLC example 2
The following PLC will implement the above ladder.

s tep
1

2
3
4
5

6
7
8
9
10
11
12
13
14
15

p LC code
A2,01
80,02
92,47
A2,01,83
82,02
72,47
92,47
A2,03
80,04
92,48
A2,03,83
82,04
72,47
72,48
92,OA

Meaning
Start the rung
This saves

tem2ora~

resutt into USER71.

This causes the resutt of Ste2 4 to be OR'ed with the saved resutt of Ste2 2.
This saves tem2ora~ resutt into USER71

This save tem2ora~ resutt into USER72

This OR's the result of Ste2 9 with the resutt of Ste2 7.


This OR's the resutt of Ste~ 12 with the saved resutt of Ste2 9.
This transfers the result of Ste2 11 to Out2ut #10.

Custom Machine Language Code


The ACR1000 family of controllers have a unique feature that allows the user to embed CUSTOM
MACHINE LANGUAGE programs in unused portions of the PLC Program Memory. There are virtually
unlimited possibHities of useful features that the user can add to the controller. As an example, a high
speed background position compare, 110 cam .. etc. routines can be written. The code is written in native
assembler code f'or the microprocessor. Call the factory for more information.

73

Chapter 10, The Program,mable Logic Controller (PLC)

11

11

Chapter 11 WEB Control


The ACR1 000 has several commands that facilitate controlling WEB speed and master/slave ratio control
on the fly. This type of control is needed for FLYING CUT OFF, PRINTING, ROTARY DIE CUTTING ... etc.
The following standard commands can be used to do this type of control.
HDWON
IPR
CAP

IHPOS

MOVE
VEL
ACC
STP

This command causes axis to slave to a master encoder.


This command sets the slave/master ratio in increments of 1/65536.
This command "captures" the elapsed distance in pulses of the slave encoder. The
sample starts upon reception of a chosen signal and ends when a second signal is
received. The sampling is interrupt driven.
This command waits until a specified number of pulses have gorLE~. by on a chosen
encoder.
The following may be used when in the HDWON 3 mode.
This command allows "advancing" or "retarding" the slave motor with respect to the
master pulses coming into the encoder input.
This command specifies the velocity of the advance or retard move.
This command sets the ACCEL of the advance or restart move.
This command sets the DECEL of the advance or retard move.

WEB Example
DO 18
I:J IDIIJ!!I

1-

Cc=::J

~mmm~

Ornmm 0

Cc::J

8[!)O~~

Optional
Operator Interface

Sig. 1 (Prox) ~

~D

~~'Q)

Sig. 2 (Photo)

WE.

Typical WEB control line


Controllin!rwhefE~t relative to the print pattern, a web is

cut by a rotary cutting axis is a typical application


of the CAPTURE: mode. In this application one signal is from a proximity switch on the rotary cutting axis
(which could be the mari<er signal on a 1: 1 encoder) while the other signal is taken from a photo mari< on
the printed web. The following e?(ample shows the power of using the CAP, HDWON, IHPOS and the
IPR commands that are specific to Master/Slave ratios. Note that parameters P12, P13, P14 and P31 are
d~lcatd
e parameters used by the CAP 0 command.

o PBOOT

2 P2=2: RES
3 P3=2: RES2
8 P8=5

Run this program immediately after power-up.


MAl N encoder controls
, WEB DEAD BAND. If the error is within this much, it will not be
corrected. If this value is too small then measurement noise will cause
non-real error "correction". If it is too large, the system will not
respond v8!"i fast to real errors.

75

Chapter 11, WEB Control'

11

IDEAl OFFSET. This is the desired offset between SIG1 and SIG2.
The measured error is the difference between this and the
measurement
AUX ENCODER CONTROLS

9 P9=400

10 P10=3
11 P11=3
12 P12--O
13 P13=6000
14 P14=0
16 P16=0
17 P43=O
19 P19=O
20 P20=32

MINIMUM WINDOW
MAXIMUM WINDOW
NUMBER OF CYCLES

23 P23=200
28
29
31
34

P28=100
P29=65536
P31=0
P34=8000

110 IPR P29


140 HDWON
150 CAP 0
157 SET 71: P14=0: P31=0
160 SET 71
170 IF P14>0 THEN GOTO 460

180 ClR 71
190 IF 6 THEN ADO P28,P29
: IPR P29 : GOTO 210
200 GOTO 230
210 IF 6=0 THEN ADD -P28,P29: IPR P29:
GOT0290
220 GOTO 210
230 IF 7 THEN ADD -P28,P29
: IPR P29 : GOTO 250
240 GOT0270
250 IF 7=0 THEN ADD P28.P29
: IPR P29 : GOTO 290
260 GOTO 250
270 OWL 2
272 ADD 7,P7
278 IF P7>150 THEN P7=0: GOTO 160
280 GOTO 190
290 SET 71
300 P31=O

--

310 P14=0
320 SET 71
330 IF P14>3 THEN GOTO 370
340 CLR 71
350 OWL 150
360 GOTO 320
370 P32=P14
380 P33=P31

ACR1000 Users Guide

TEMP
SOFT-TACH
FEEO-FORWARO. Feed-Forward should be set to minimized
following error at normal operating speed. If it is not set, changing
Following Error will introduce a phase error during a~eleration and
deceleration periods.
MAXIMUM RUN WINDOW. If this error is exceeded an alarm will be
set.
How much to vary P29 during manual phase correct.
DEFAULT IPR (1:1).
TOTAL MEASURED OFFSET.
NUMBER OF PULSES TO CORRECT OVER. This is the distance, in
pulses, to do any correction over. It is possible to do an -instanr
correction, but often this would break the WEB. The technique used in
this program spreads the correction over this many pulses of WEB.
Set the default IPR and tum on Hand weel Mode.
Tum on the CAPTURE mode.
Set the BUSY bit. Clear measurement parameters
Set BUSY bit so P14 access in next line does not corrupt the
background access to P14.
Check to see if the number of cycles measured is greater than some
minimum (0 in this case). If so, go to line 460 to check measurements
and do corrections if needed.
Clear the BUSY bit.
Input 6 is the phase advance input If 6 is on, bump up the IPR by the
value of P28 and go to line 210 to wait for Input 6 to go low.
Wait for 6 to go off and restore normal IPR.

Input 7 is the phase retard input. See line 190.

This adds some time to this service loop.


The number added to P7 in this loop determines how often P14 is
checked.
Service phase adjust switches in a loop until P7>150. then check P14
again.
Measure the new ideal offset after a manual phase adjust
Clear any previous measurements made during phase adjust to make
sure a good reading is made.

'-

Get the measurement.

71

11

"."

This is looped to in line 360.


Measure at least 4 cycles.
Wait for some more cycles to happen.

390 P31=0
400 P14-0
410 CLR 71
420 DIV P33,P32
430 P9=P32
445 1:1 "NEW OFFSET IS ";P9
450 GOTO 190
460 P32=P14
470 P33=P31
475 P38=P14
4n P40=P31
480 P31=0
490 P14=0
500 CLR 71
510 DIV P33,P32
520 P33=P9
530 SUB P32,P33
535 MUL -1,P33

Find the average offset


Print new offset to console.
Go back to main loop.
Measure offset, correct if needed.
For printout in lines 660 and 670.

Find the average measured offset


Compare against P9 (ideal offset).
This is needed if machine is "backwards". i.e. correcting actually
makes the offset worse. This can also be accomplished by changing
the sign of the "0" argument to the CAP D command.

640 IF P33>-P23 THEN


IF P33<P23 THEN CLR 17
: SET 16: GOTO 650
645 CLR 16: SET 17:
1CHR$(10);CHR$(13);"OUT OF RUN BAND";
650 IF P33<-P8 THEN ADD -i,P15: GOTO 670
655 IF P33>P8 THEN ADO 1,PiS: GOTO 670
660 ?P38;" M;P33;" ";P40;" ";CHR$( 13); :
GOTO 190
670 ?P38;" ";P33;" ";P40;" "
680 P36=P34
690 olV P33,P36
700 MUL P29.P36
710 MUL .9,P36

Check the RUN BAND.

If here, then out of the RUN BAND.


Check the DEAD (no correct) BAND.
If here, then within the DEAD BAND.

This calculates the correct IPR to use to correct measured error over
P34pulses.

Correction scaling. Use this if you find the machine often overcorrects.

720 ADD P29,P36


730 P35=P36
I

740
750
760
780

SET 71
P14=0
P31=0
IF 100 THEN GOTO

790
820
840
850
860

ROPOS 1, P30
ADD P34,P30
IPR P35
IHPOS P30,T,500
GOTO 940

Do correction. Inhibit measurements during correction.

~170

-.-

870 ROPOS 1,P30

900 ADD -P34,P30


920 IPR P35
930 IHPOS -P30, T,500
940 IPR P29
950 OWL 10
960 GOTO 180

Check direction, if it is moving in the "negative" direction then go to


line 870.

Wait for P34 pulses or 5 seconds to pass, whichever comes first

Correct in "negative" direction. Note most machines only move in one


direction so line 780 could be eliminated and ether this or the above
paragraph used, whichever is right

Wait for P34 pulses or 5 seconds to pass, whichever comes first.


Done with correction. Return to main loop.

77

Chapter 11, WEB Control

11

11

You might also like