====== 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
{{:download:energymetertomodbusregs.scl|energyMeterToModbusRegs (SCL) Download}}
Main site > [[simatic:lamalib|LamaLibrary Simatic]]
===== lamaLibSimatic topics on lamaPLC =====
{{topic>lamaLibSimatic}}
{{tag>TIA SCL lamaLibSimatic source_code energy_meter modbus register word}}
\\
This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}