Topic: DMD0073

Help File Version: 2.10.0.636

PUBLISH - Translate from Do-more


The Translate from Do-more (PUBLISH) instruction copies and converts ranges of data from Do-more memory to a data format that is directly usable by an external source, for example: converting memory to BCD data that will be used by a DirectLOGIC CPU, or byte-swapping data that will be used by a Modbus device. There is no sequencing or stepping regarding the rows in this instruction, every row in the instruction is processed every time the instruction is executed.

 

 

The Translate from Do-more instruction can have from 1 to 50 rows of data blocks to convert. For each of the rows, this instruction will copy each of the Elements from the Source block to the Destination block, converting each of them from the native data format of the Source block to the specified format.

 

The following functions are used to manage the rows in the instruction: Ok closes the editor, saving any changes, and Cancel closes the editor, discarding any changes. Edit opens the editor for the currently selected row. Insert inserts a new row before the currently selected row. Remove removes the currently selected row. Move Up / Move Down moves the currently selected row up one row / down one row respectively.

 


Parameters:

Note: Use the F9 key or click the 'three dot box' at the right edge of the parameter field to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.

 

 

Source - specifies the beginning address of the data block to be copied and converted. This can be any readable numeric location.

 

Destination - specifies the beginning address of the block to store the converted data. This can be any writable numeric location.

 

As - specifies the type of format conversion to be applied to each element in the Source block as they are copied to the Destination block.

 

 

Format

Size

Signed

Unsigned

BCD

Real

Byte

Ok

Ok

Ok

n/a

Word

Ok

Ok

Ok

n/a

DWord

Ok

n/a

Ok

Ok

 

#Elements - specifies the number of Source locations to convert. This can be any constant value between 1 and 255.

 

Swap Byte - checking this option will cause the Bytes of each Source Word or DWord to be swapped before the data conversion operation is applied.

Swap Word - checking this option will cause the Words of each Source DWord to be swapped before the data conversion operation is applied.

 

Note: As of Do-more Designer version 1.1, the Reverse Bytes option in the PUBLISH instruction was split in two options: Swap Byte and Swap Word. This change allows any combination of Swap Bytes in Word-size elements and / or Swap Words in DWord or Real elements. However, if the Do-more CPU is running a firmware version older that v1.1 there is a caveat: if the instruction is setup to operate on a DWord-size element, and ONLY Swap Byte or Swap Word is selected, this cannot be downloaded to the Do-more CPU with the older firmware. Selecting Swap Word AND Swap Byte can be downloaded to the Do-more CPU with older firmware. This issue is best remedied by upgrading the CPU firmware to v1.1 or later.

 

Note: checking both Swap Byte and Swap Word will reverse the bytes in a DWord.

 


Status Display:

 

The status display of the PUBLISH instruction is a textual description of the data conversion.

 


See Also:

PUBLISH - Transport from Do-more

 

SUBSCRIB - Translate to Do-more

 


Rung Example:

 

 

The following table shows how the PUBLISH instruction manipulates the data in the above example using various values:

 

SOURCE

Value

DESTINATION

Value

Notes

N0

-100

DLV0

0x0000

Negative numbers cannot be represented in BCD, so the result is zero

N1

-10

DLV1

0x0000

Negative numbers cannot be represented in BCD, so the result is zero

N2

-1

DLV2

0x0000

Negative numbers cannot be represented in BCD, so the result is zero

N3

0

DLV3

0x0000

 

N4

1

DLV4

0x0001

 

N5

2

DLV5

0x0002

 

N6

3

DLV6

0x0003

 

N7

4

DLV7

0x0004

 

N8

5

DLV10

0x0005

 

N9

10

DLV11

0x0010

 

N10

20

DLV12

0x0020

 

N11

30

DLV13

0x0030

 

N12

32,767

DLV14

0x2767

Wraps around because largest value is 0x9999: 32,767 - 10,000 (1 wrap) - 10,000 (2 wraps) - 10,000 (3 wraps)

N13

10,000

DLV15

0x0000

Wraps around to zero

N14

9999

DLV16

0x9999

Largest value that can be represented in BCD word (16-bits)

N15

10,001

DLV17

0x0001

Wraps around to one: 10,001 - 10,000 (1 wrap)

R0

-100

DLV20

0x0000

Negative numbers cannot be represented in BCD, so the result is zero.

DLV21

0x0000

R1

1

DLV22

0x0001

 

DLV23

0x0000

R2

9999

DLV24

0x9999

 

DLV25

0x0000

R3

1,000,000

DLV26

0x0000

 

DLV27

0x0100

R4

1.0E+08

DLV30

0x0000

100,000,000 is too large (largest is 0x9999 9999; i.e. 99,999,999), so the result is zero

DLV31

0x0000

R5

1.0E+09

DLV32

0x0000

1,000,000,000 is too large, so the result is zero

DLV33

0x0000

R6

3,291,114

DLV34

0x1114

 

DLV35

0x0329

R7

55

DLV36

0x0055

 

DLV37

0x0000

D0

2,147,483,647

(0x7FFF FFFF)

MHR1

-129

(0xFF7F)

Notice not only are the bytes (8-bits) swapped, but the words (16-bits) are as well:

For example: ABCD EFGH --> (swap words) --> EFGH ABCD --> (swap bytes) --> GHEF CDAB

MHR2

-1

(0xFFFF)

D1

-1

(0xFFFF FFFF)

MHR3

-1

(0xFFFF)

 

MHR4

-1

(0xFFFF)

D2

-10,000,000

(0xFF67 6980)

MHR5

26,623

(0x67FF)

 

MHR6

-32,663

(0x8069)

D3

4

(0x0000 0004)

MHR7

0

(0x0000)

 

MHR8

1024

(0x0400)

D4

5

(0x000 0005)

MHR9

0

(0x0000)

 

MHR10

1280

(0x0500)

D5

1,234,567

(0x0012 D687)

MHR11

4608

(0x1200)

 

MHR12

-30,762

(0x87D6)

D6

5,000,000

(0x004C 4B40)

MHR13

19,456

(0x4C00)

 

MHR14

16,459

(0x404B)

D7

-332,147

(0xFFFA EE8D)

MHR15

-1281

(0xFAFF)

 

MHR16

-29,202

(0x8DEE)

D8

2000

(0x0000 07D0)

MHR17

0

(0x0000)

 

MHR18

-12,281

(0xD007)

D9

-10,500

(0xFFFF D6FC)

MHR19

-1

(0xFFFF)

 

MHR20

-810

(0xFCD6)

D10

0

(0x0000 0000)

MHR21

0

(0x0000)

 

MHR22

0

(0x0000)

D11

10

(0x0000 000A)

MHR23

0

(0x0000)

 

MHR24

2560

(0x0A00)

D12

5500

(0x0000 157C)

MHR25

0

(0x0000)

 

MHR26

31,765

(0x7C15)

D13

891,319,411

(0x3520 7473)

MHR27

8245

(0x2035)

 

MHR28

29,556

(0x7374)

D14

57

(0x0000 0039)

MHR29

0

(0x0000)

 

MHR30

14,592

(0x3900)

D15

13,363

(0x0000 3433)

MHR31

0

(0x0000)

 

MHR32

13,108

(0x3334)

D16

2,000,000,000

(0x7735 9400)

MHR33

13,687

(0x3577)

 

MHR34

148

(0x0094)

D17

1,000,000,000

(0x3B9A CA00)

MHR35

-26,053

(0x9A3B)

 

MHR36

202

(0x00CA)

D18

90,000,000

(0x055D 4A80)

MHR37

23,813

(0x5D05)

 

MHR38

-32,694

(0x804A)

D19

400,000

(0x0006 1A80)

MHR39

1536

(0x0600)

 

MHR40

-32,742

(0x801A)