Description
You can use analog 4-20 mA input and output signals with the analog 0-20 mA signal modules and signal boards. You can scale the signal range of the analog inputs and outputs using the "Scale_current_input" and "Scale_current_output" predefined functions (FCs), which you can find attached to this FAQ.
Adding the "Scale_current" Global library
- Download the attached library, and unzip it. Open the "Libraries" task card.
- Click the "Open global library" button. The "Open global library" dialog window opens.
- Browse for the "Scale_current" library folder, and open the "Scale_current.al10" file. Now, the library is displayed in the "Global libraries" pane in the "Libraries" task card.

Fig. 01
Scaling of the analog input
The range of 0-20 mA without the "Scale_current_input" instruction corresponds to the PLC’s internal signal range of 0-27648. The "Scale_current_input" instruction adapts this internal range to 4-20 mA linearly, starting with "0" for 4 mA and ending up with "27648" for 20 mA. A limit for wire break monitoring can be chosen by hand.

Fig. 02
| No. |
Scaling of the analog input |
| 1. |
Insert the "Scale_Current_input" instruction into a network
Browse the Global libraries tree for the "Scale_current_input" FC. Drag and drop this FC into a network of your S7-1200 PLC program.

Fig. 03
|
| 2. |
Scaling the analog input signal
Connect the contact "w_input_0-20mA" (2) to your analog hardware input (for example, IW96). You receive the scaled value at the contact "r_input_4-20mA" (4).
Note
For any input value lower than 4 mA the signal at "r_input_4-20mA" (4) will be set to "0". Accordingly, any input values higher than 20 mA will not exceed the maximum of "27648".

Fig. 04
|
| 3. |
Wire break monitoring
At the contact "r_wire_break_limit" (1), enter the limit for the wire break monitoring. The value "2764.8" for example will set the wire break limit to 2 mA. This means, if your input current is lower than 2 mA, the contact "b_wire_break" (3) will be set to "1". |
Table 01
Scaling of the analog output
The range of 0-20 mA without the "Scale_current_input" instruction corresponds to the PLC´1 internal signal range of 0-27648.
The Scale_current_output" instruction adapts this internal range to 4-20 mA linearly, starting with 4 mA for "0" and ending up with 20 mA for "27648".

Fig. 05
| No. |
Scaling of the analog output |
| 1. |
Insert the "Scale_current_output" instruction into a network
Browse the Global libraries tree for the "Scale_current_output" FC. Drag and drop this FC into a network of your S7-1200 PLC program.

Fig. 06
|
| 2. |
Scaling the analog input signal
Connect the contact "r_output_4-20mA" (1) to your software value. You receive the scaled value at the contact "w_output_0-20mA" (2) to send it to your analog hardware output (for example, QW96).
Note
For any input value lower than "0", the signal at "w_output_0-20mA" will be set to 4mA.
Accordingly, any input values higher than "27648"will not exceed the maximum of 20mA.

Fig. 07
|
Table 02
Requirements
- S7-1200 PLC
- Ethernet cable
- signal board / signal module for analog output / input
- STEP 7 Basic V10.5
S7-1200_Scale_current.zip ( 348 KB )
|