meta data for this page
lamaLib: energyMeterToModbusRegs
The function converts a UDInt type variable into 2 Word. Specifically, the function transmits the status of an energy meter to 2 Modbus registers (the Modbus registers are word type).
Function call:
"energyMeterToModbusRegs"(energyMeter:=_udint_in_, register1=>_word_out_, register2=>_word_out_);
Source code:
FUNCTION "energyMeterToModbusRegs" : VOID { S7_Optimized_Access := 'TRUE' } VERSION : 0.1 VAR_INPUT energyMeter : UDInt; // Energy meter value to send END_VAR VAR_OUTPUT register1 : WORD; // 1st modbus register register2 : WORD; // 2nd modbus register END_VAR VAR_TEMP uint_hi : UInt; uint_lo : UInt; en_dw : UDInt; END_VAR BEGIN // copy enegymeter value #en_dw := #energyMeter; // first word #uint_hi := TRUNC(#en_dw / 16#7FFF); // 2nd word #uint_lo := #en_dw - (#uint_hi * 16#7FFF); // copy to reg1 #register1 := #uint_hi; // copy to reg2 #register2 := #uint_lo; END_FUNCTION
Main site > LamaLibrary Simatic
lamaLibSimatic topics on lamaPLC
Page | Date | User | Tags |
---|---|---|---|
2024/11/18 21:23 | Sandor Vamos | tia, scl, lamalibsimatic, source code, energy meter, modbus, register, word | |
2024/11/18 20:36 | Sandor Vamos | tia, scl, lamalibsimatic, source code, energy meter, modbus, register, word | |
2024/11/18 20:22 | Sandor Vamos | tia, scl, lamalibsimatic, source code, join, bits, byte, convert | |
2025/05/26 12:52 | Sandor Vamos | tia, scl, lamalibsimatic, source code, dt, string, convert | |
2024/11/18 19:54 | Sandor Vamos | tia, scl, lamalibsimatic, source code, math, power of 10 |
This page has been accessed for: Today: 1, Until now: 138