Icon

USC Config - u. Using Integer Maths

Also see "The Equation Editor"

The USC701 has four memories CH1, CH2, P1 and P2 (M0 to M3) that contain input measurements, these measurements are floating point numbers.

The output devices O1 (mA, V, PWM, Frequency), RLY1 and RLY2 can be controlled from M0 to M9 (memory's).

The values in M0 to M9 must be floating point numbers to control the output devices correctly.

There are two problems that occur when using floating-point maths in custom applications:

  • Floating point arithmetic requires more cycles of the CPU and therefore takes more time to complete. Each floating-point addition / subtraction takes about 2mS while each floating-point multiplication / division takes about 5mS.
  • Testing for a particular value can be risky as simply starting at 0 and adding 1 progressively will not result in exactly whole numbers in every case, some will be ever so slightly lower than the whole number while others will be ever so slightly higher than the whole number.

The equation editor has commands to branch on the condition of P1 and P2 making it possible to implement different processing based on the condition of the input. By setting the equation update time to a known value this same technique can be used for counting and period measurement functions with resolution and speed limitations.

When using the user equation at the maximum update speed of 5mS care must be taken to ensure the equation can be processed within that time. Obviously floating-point division and multiplication are out of the question while one or two floating-point addition and subtractions are possible.
Another problem that can occur at fast update times is excessive use of the send memory command. The send memory command is not required for USC701 output components to use the values in memory. If M4 was connected to the milliamp output and the equation contained no send M4 commands the milliamp output will still be updated each time the equation is run.

If using a field bus card or logging results with the COA703 the values in M4 to M9 do require the send memory to occur. For applications running at up date times faster than 40mS then extra branching should be added to send values say once every eighth time or 40mS as shown in the following example.

The "Integer Maths Branching Demonstration" features:

  • Integer maths is used to calculate values for use in the equation at power up. This technique can be used to free up the equation constants for use in the user interface.
  • Integer variables are directly controlling program branching. Three logical decisions are available after the variable is read into the stack, "=Int0", ">Int0" and "<Int0".
  • Integer counter variables are used to generate the output values due to their very fast calculating time.