Rockwell Automation 1746-HSCE2 Multi-Channel High Speed Counter Module User Manual

Page 55

Advertising
background image

Publication 1746-UM002B-EN-P - August 2004

Configuration and Programming 4-5

Converting from Floating-Point to Two-word Integer Format

RSLogix500 programming software can also be used to convert from
floating-point to two-word integer format as shown.

0001

0002

0003

0004

Divide
Source A

F8:4

0.0

<

Source B

1000.0

1000.0

<

Dest

F8:3

0.0

<

Move
Source

F8:3

0.0

<

Dest

N7:34

0<

Grtr Than or Eql (A>=B)
Source A

F8:4

0.0

<

Source B

0.0

0.0

<

Greater Than (A>B)
Source A

N7:34

0<
Source B

F8:3

0.0

<

Subtract
Source A

N7:34

0<
Source B

1

1<
Dest

N7:34

0<

Compute
Dest

N7:35

0<
Expression F8:4 - ( N7:34 * 1000.0 )

Less Than (A<B)
Source A

F8:4

0.0

<

Source B

0.0

0.0

<

LES

Less Than (A<B)
Source A

N7:34

0<
Source B

F8:3

0.0

<

ADD

Add
Source A

N7:34

0<
Source B

1

1<
Dest

N7:34

0<

Compute
Dest

N7:35

0<
Expression F8:4 + ( ( - N7:34 ) * 1000.0 )

TWO-WORD 1 TEMP

TWO-WORD 1 MSW

FLOAT TO TWO-WORD
INT VALUE

FLOAT TO TWO-WORD
INT VALUE

TWO-WORD INT 1 MSW

TWO-WORD INT 1 MSW

TWO-WORD INT 1 MSW

TWO-WORD INT 1 MSW

TWO-WORD INT 1 LSW

TWO-WORD INT 1 LSW

LES

CPT

CPT

SUB

GRT

GEQ

DIV

MOV

F8:4 holds the number to be converted. It is divided by 1000 and the result is placed in F8:3.

The value in F8:3 is moved to N7:34, yielding the upper word
(Most Significant Word - MSW).

Rung 3 is used only when the original value in F8:4 is positive. If the value in N7:34 was rounded up, as determined
by comparing it to the floating point version in F8:3, the value must be adjusted by subtracting one from it. The
lower (Least Significant Word) - LSW) is then calculated by subtracting (MSW multiplied by 1000) from the original
value.

Rung 4 is used only when the original value in F8:4 is negative. If the value in N7:34 was rounded up, as determined
by comparing it to the floating point version in F8:3, the value must be adjusted by adding one to it. The lower
(LSW) is then calculated by adding (MSW multiplied by 1000) to the original value.

Advertising