Sample program, 2 instructions, Parity – Omron SYSMAC CP CP1E-N@@D@-@ User Manual
Page 243
2-207
2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)
Con
v
e
rs
ion I
n
stru
ctio
ns
2
HEX
Sample program
When CIO 0.00 is ON in the following example, HEX(162) converts the ASCII data in D100 and D101
according to the settings of the digit designator. (Di=#0121 specifies no parity, the starting byte (when
reading) = leftmost byte, the number of bytes to read = 3, and the starting digit (when writing) = digit 1.)
HEX(162) converts three bytes of ASCII data (3 characters) beginning with the leftmost byte of D100
into their hexadecimal equivalents and writes this data to D200 beginning with digit 1.
Parity
It is possible to specify the parity of the ASCII data for use in error control during data transmissions.
The leftmost bit in each byte is the parity bit. With no parity the parity bit should always be zero, with
even parity the status of the parity bit should result in an even number of ON bits, and with odd parity
the status of the parity bit should result in an odd number of ON bits.
The following table shows the operation of HEX(162) for each parity setting.
Parity setting
(leftmost digit of Di)
Operation of HEX(162)
No parity (0)
HEX(162) will be executed only when the parity bit in each byte is 0. An error will occur if a parity bit is non-zero.
Even parity (1)
HEX(162) will be executed only when there is an even number of ON bits in each byte. An error will occur if a byte has an
odd number of ON bits.
Odd parity (2)
HEX(162) will be executed only when there is an odd number of ON bits in each byte. An error will occur if a byte has an
even number of ON bits.
HEX
D100
#0121
D200
0.00
S
Di
D
0
3
4
7
8
15
12 11
0
3
4
7
8
15
12 11
Di:#
1
2
1
0
Di:D200
0
1
2
3
3
4
5
0
7
8
15
S:D100
D101
33
34
35
Number of digits
3 digits
Starting digit (digit 1)
Starting byte
(leftmost byte)