Manual Handling Modbus using Unity Pro XL
2018-10-31 07:55:12 by sikyi

There isn’t many articles relating to Schneider PLC Structured Text on using the NOM cards. So i decided to write one to remembered it in the future.
THe purpose of this setup is to use PLC to retirevied status from UPS Emerson using high level interfacing and populated it to a modbus address for RTU to retrieved.
The setup uses Schneider Quantum series with 1 RIO to do the interfacing. NOM 0200.3 is used for the interfacing and its sloted on the 2nd slot of the RIO. Hence the addressing used (1.5.1{192.168.10.3}). We will be using raw modbus address to set out ($01$03$04$10$00$01$84$).
The variable is set as ST1040 Array[0,3] INT with value of
- Array[0] = 769
- Array[1] = 4100
- Array[2] = 256
- Array[3] = -124
(* 1040 *)(* $01$03$04$10$00$01$84$FF *) IF ST1040BOOL = TRUE THEN PRINT_CHAR_QX_0 (ENABLE := ST1040BOOL, ABORT := FALSE, ADDR := ADDMX (IN := '1.5.1{192.168.10.3}\\0.1.0'), SEND_LEN := 8, SEND_BUF := ST1040, DONE => PRINT_DONE, ACTIVE => PRINT_ACTIVE, ERROR => PRINT_ERROR, STATUS => PRINT_STATUS); ST1040BOOL := FALSE; ST1030COUNTBOOL := FALSE; ST1040COUNTBOOL := TRUE; RESET_BUF := TRUE; NOMCOUNT := 0; END_IF; IF ST1040COUNTBOOL = TRUE Then REC_LEN := 1; INPUT_LEN := 1; INPUT_CHAR_QX_0 (ENABLE := ST1040COUNTBOOL, ABORT := FALSE, ADDR := ADDMX (IN := '1.5.1{192.168.10.3}\\0.1.0'), RESET_BUF := RESET_BUF, INPUT_LEN := INPUT_LEN, DONE => DONE, ACTIVE => ACTIVE, ERROR => ERROR, STATUS => STATUS, REC_LEN => REC_LEN, REC_BUF => ARRAYOFWORDS); IF COUNT = 1 & DONE = TRUE THEN ST1040_R[0] := INT_TO_WORD (IN := ARRAYOFWORDS); COUNT := 2; NOMCOUNT := 0; ELSIF COUNT = 2 & DONE = TRUE THEN ST1040_R[1] := INT_TO_WORD (IN := ARRAYOFWORDS); COUNT := 3; NOMCOUNT := 0; ELSIF COUNT = 3 & DONE = TRUE THEN ST1040_R[2] := INT_TO_WORD (IN := ARRAYOFWORDS); COUNT := 4; ELSIF COUNT = 4 & DONE = TRUE THEN ST1040_R[3] := INT_TO_WORD (IN := ARRAYOFWORDS); COUNT := 5; NOMCOUNT := 0; ELSIF COUNT = 5 & DONE = TRUE THEN ST1040_R[4] := INT_TO_WORD (IN := ARRAYOFWORDS); COUNT := 6; NOMCOUNT := 0; ELSIF COUNT = 6 & DONE = TRUE THEN ST1040_R[5] := INT_TO_WORD (IN := ARRAYOFWORDS); COUNT := 7; NOMCOUNT := 0; ELSIF COUNT = 7 & DONE = TRUE THEN ST1040_R[6] := INT_TO_WORD (IN := ARRAYOFWORDS); ST1030BOOL := TRUE; COUNT := 1; NOMCOUNT := 0; END_IF; RESET_BUF := FALSE; END_IF; %MW104.0 := ST1030_R[4].0; %MW104.1 := ST1040_R[4].2; %MW104.2 := ST1040_R[4].3; %MW104.3 := ST1040_R[4].0; %MW104.4 := ST1040_R[4].1; %MW104.5 := ST1040_R[4].6;
THe modbus address is mapped as back to $MW104 from bit 0 to bit 5.
Estimate of 50 queries in a single second which populates the data to the modbus addresses. We can used other method to control the other cycle time to prevent it from querying to frequent. The above setup also take cares in case of cable breaks or cable being plug out from the NOM cards and resumed back after the status is good.