App. - 46
Appendix 4.28 Program using digital switch to import data
When a set value of the digital switch is always input and stored to D10 of the
programmable controller
1 2 3 4
Digital switch
Input module
CPU
X20
X2F
Data
register
D10
to
Converted into BIN
BIN K4X20 D10
SM400 (always ON)
Wrong
configuration
In the above program, changing a value of the digital switch while the programmable
controller is in RUN may cause codes other than 0 to 9 depending on the timing of
the change, which may cause an operation error of the CPU.
To avoid this, write a program as follows.
(Example 1) For 4 digits of X20 to X2F
SM400
0
K1X20
K0<=
K1M20
K1X20MOV
K1M24
K1X24MOV
K1M28
K1X28
MOV
K1M32
K1X2C
MOV
D10
K4M20BIN
K1X24
K0
K1X28
K0
K1X2CK0
K1X20
K9>=
K1X24
K1X28
K1X2C
<=
<=
<=
K9
K9
K9
>=
>=
>=
(Example 2) For 8 digits of X20 to X3F
SM400
0
Z0
RST
K8
FOR
K1M100Z
K1X20Z
MOV
Z0
K4
+
NEXT
K1X20Z0
K0
K1X20Z0
<=
K9
>=
4
7
31
32
D10
K8M100DBIN
K8Y40
D10
DBCD
SM400