Rockwell-automation 5370-CMPK Color CVIM Module MATH-PAK Manual de usuario Pagina 38

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 89
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 37
Chapter 4
Defining Formulas
423
Modulo operator: %
Format/Usage: The modulo operator (%) performs the long division
operation on one operand by a second operand, and yields the whole number
remainder of that division operation. In general, use two operands, placing
the modulo operator in the formula between the two operands. The left
operand is the dividend, the right operand is the divisor.
The modulo operator can be applied in formulas, for example, to produce
binary values from decimal-based integer values.
Example usage: Use the modulo operator to calculate a 5-place binary
result from a gage 1 object-counting result (for values 031 decimal), using a
series of 10 formulas:
Formula 1:
GAGE1 % 2
Formula 2: GAGE1 / 2
Formula 3: RSLT2 % 2
Formula 4: RSLT2 / 2
Formula 5: RSLT4 % 2
Formula 6: RSLT4 / 2
Formula 7: RSLT6 % 2
Formula 8: RSLT6 / 2
Formula 9: RSLT8 % 2
Formula 10: RSLT9
*
10000 + RSLT7
*
1000 + RSLT5
*
100 + RSLT3
*
10 + RSLT1
For example, if the gage 1 result were 19:
Formula 1:
19 % 2 (RSLT1=1)
Formula 2: 19 / 2 (RSLT2=9)
Formula 3: 9 % 2 (RSLT3=1)
Formula 4: 9 / 2 (RSLT4=4)
Formula 5: 4 % 2 (RSLT5=0)
Formula 6: 4 / 2 (RSLT6=2)
Formula 7: 2 % 2 (RSLT7=0)
Formula 8: 2 / 2 (RSLT8=1)
Formula 9: 1 % 2 (RSLT9=1)
Formula 10: 1
*
10000 + 0
*
1000 + 0
*
100 + 1
*
10 + 1 (RSLT 10=10011)
In the above example, the result of formula 10 is 10011, which, if interpreted
as a binary value, would equal 19 (decimal).
Vista de pagina 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 88 89

Comentarios a estos manuales

Sin comentarios