Magelis EdgeBox (Node-Red) to S7 PLC (baca PLC S7-1500)

Berikut adalah langkah langkah yang dilakukan untuk komunikasi ke PLC S7, bisa di implement ke S7-1500 / S7-1200 tanpa harus menggunakan gateway lagi atau merubah/modifikasi di sisi setting PLC.

metode ini juga bisa digunakan untuk menjadikan Magelis Edge Box menjadi gateway dari S7 TCP ke Modbus TCP.

—Read full article……

Node-Red ~ Modbus Floating Point Convert (Float32 / Real)

this function script is used to convert your 2 words into Float32bit

/* Converts from an number, string, buffer or array representing an IEEE-754 value
 to a javascript float.
 The following may be given in msg.payload:
 A string representing a number, which may be hex or binary
 examples, "1735" "0x02045789" 0b01000000010010010000111111011011
 An integer value
 A two element array or buffer of 16 bit values, less significant byte first.
 A four element array or buffer of 8 bit values, most significant byte first.
 Source: https://flows.nodered.org/flow/359ead34237b7ab6ec0465ee85a34b62
 */
 // first make a number from the given payload if necessary
 let intValue;
 if (typeof msg.payload === "number") 
{
 intValue = msg.payload;
 } else if (typeof msg.payload === "string") {
 intValue = Number(msg.payload);
 } else if (msg.payload.length == 2) {
 // two int array or buffer
 intValue = (msg.payload[1] << 16) + msg.payload[0];
 } else if (msg.payload.length == 4) {
 // four byte array or buffer
 intValue = (((((msg.payload[0] << 8) + msg.payload[1]) << 8) + msg.payload[2]) <<
 8) + msg.payload[3];
 } else {
 node.warn("Unrecognised payload type or length");
 } 
 msg.payload = Int2Float32(intValue);
 msg.payload = msg.payload.toFixed(1);
 return msg;
 function Int2Float32(bytes) {
 var sign = (bytes & 0x80000000) ? -1 : 1;
 var exponent = ((bytes >> 23) & 0xFF) - 127;
 var significand = (bytes & ~(-1 << 23));
 if (exponent == 128)
 return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);
 if (exponent == -127) {
 if (significand === 0) return sign * 0.0;
 exponent = -126;
 significand /= (1 << 22);
 } else significand = (significand | (1 << 23)) / (1 << 23);
 return sign * significand * Math.pow(2, exponent);
 }

Modbus-IoT (Modbus over MQTT)

Modbus?? old school protocol (more than 40th years).

when Modbus created, it was created for Serial communication via RS485. after year by year, technology was changing and ethernet / TCP widely used in PLC and industrial control system, then Modbus move their medium to Ethernet and wrap their message in TCP (encapsulated) over ethernet.

Now, when everything going to the cloud or  RTU/PLC are not in the same place with SCADA and it only have internet connection, it will be hard and expensive for Modbus to keep exist in Internet area. because we need at least public IP for each device, or creating VPN.

but with MQTT the message can be send over the broker (on the cloud), so it will be exiting if modbus can be sent through MQTT.

if you’ve heard about Node-red this is cool IoT tools/platform built in NodeJS.

I’m using Node-red to make it’s encapsulation, and Modscan as Modbus Master (or SCADA), and Modsim as Modbus Slave (or  PLC)

—Read full article……