Appendix
A.1 Source of the user program
SM331; AI 8x12 Bit Getting Started part 1: 4 -20mA
Getting Started, 11/2006, A5E00253410-02
A-3
END_VAR
BEGIN
NETWORK
TITLE =Read channels
// Channel values 0 to 7 are loaded and stored in DB1 (channel values)
L PEW 256;
//Channel 0
T DB1.DBW 0;
L PEW 258;
//Channel 1
T DB1.DBW 2;
L PEW 260;
//Channel 2
T DB1.DBW 4;
L PEW 262;
//Channel 3
T DB1.DBW 6;
L PEW 264;
//Channel 4
T DB1.DBW 8;
L PEW 266;
//Channel 5
T DB1.DBW 10;
L PEW 268;
//Channel 6
T DB1.DBW 12;
L PEW 270;
//Channel 7
T DB1.DBW 14;
NETWORK
TITLE = Conversion
// Conversion of the channel’s raw data into current values (mA)
CALL FC 1 (
Raw
Current
:= DB1.DBW 0,
:= DB2.DBD 0);
CALL FC 1 (
Raw
Current
:= DB1.DBW 4,
:= DB2.DBD 4);
CALL FC 1 (
Raw
Current
:= DB1.DBW 6,
:= DB2.DBD 8);
NETWORK
TITLE = Reset hardware interrupt
// Even though the hardware interrupt was reset by the hardware upon terminating OB40
// the value of the hardware interrupt must be reset manually