To_real (plcnext) vs dword_to_real(pcworx)

Hi, i have to use the data convertion function to read out and write into a word array of a Modbus Server. In PC Worx i used follwing Code (arrData[0] → 71B0; arrData[1] → 000B): “DW_EM100_101.W0 := arrModbusData[1].arrData[0]; DW_EM100_101.W1 := arrModbusData[1].arrData[1]; rSetpoint_EM:= dword_to_real(DW_EM100_101);” → rSetpoint_EM:= 750000 750000 is what i need to get. In PlcNext: “DW_EM100_101.W0 := arrModbusData[1].arrData[0]; DW_EM100_101.W1 := arrModbusData[1].arrData[1]; rSetpoint_EM:= to_real(DW_EM100_101);” Here i get a complete other value. Best regards Michael

Hello, In PLCnext reasult od TO_REAL function depends on input data type.

In your case input data type is DWORD, so TO_REAL use its bits value to exponent and mantissa of real data type. If you want to convert value of this DWORD you have to convert it first do DINT, and then to REAL.

rSetpoint_EM:= to_real(to_dint(DW_EM100_101));

Should work fine.

Hey Konrad, thanks for answering. Moved to PLCnext Engineer Section. Frank