4-30 Series 90-30/20/Micro Programmable Controllers Reference Manual September 1998 GFK-0467K

4
A common application is to scale analog input values with a MUL operation followed by a DIV andpossibly an ADD operation. With a range up to 32000, using a MUL INT will overflow. Using an%AI value for a MUL DINT will also not work as the 32-bit I1 will combine 2 analog inputs at thesame time. You must move the analog input to the low word of a double register, then test the signand set the second register to 0 if positive or –1 if it was negative. Use the double register with theMUL DINT for a 32 product for the following DIV function.For example, the following logic could be used to scale a +/–10 volt input %AI1 to +/– 25000engineering units in %R5.
| _____ _____ _____
|ALW_ON | | | | | |
|——] [———| MOVE|—————————————————| MOVE|—————————————————| LT_ | ——————————<+>
| | | | | | |
| | INT | | INT | | INT | |
| | | | | | | |
|%AI0001–|IN Q|–%R0001 CONST –|IN Q|–%R0002 %R0001 –|I1 Q|-
| | LEN | +00000 | LEN | | |
| |00001| |00001| | |
| |_____| |_____| CONST –|I2 |
| +00000 |_____|
|
| _____
| | |
|<+>—————|MOVE_|–
| | |
| | INT |
| | |
| CONST –|IN Q|–%R0002
| –00001 | LEN |
| |00001|
| |_____|
|
|
| _____ _____
|ALW_ON | | | |
|——] [———————————| MUL_|—————————————————————————————————| DIV_|–
| | | | |
| | DINT| | DINT|
| | | | |
| %R0001 –|I1 Q|–%R0003 %R0003 –|I1 Q|–%R0005
| | | | |
| CONST –|I2 | CONST –|I2 |
| +0000025000 |_____| +0000032000 |_____|
|