Could you please provide a screenshot for com mod mast to read float value?
I found one thread where to u had a same problem. I am not able to read float value through com mod mast. I came across this PLC first time. Screenshot of data type or any structure will help me to get correct data.
Answers
Hi,
You can't read directly float values by using of COM_MOD_MAST - that is serial Modbus RTU. So you can transfer only bits (coils) and words (registers). Usually float values are transferred by means of one or two consequence words - check your slave's mapping.
Here is example for reading of 2 consequence words and transfer them to real:


Provide pulses on EN input.
COM_PORT: BYTE := 1;
SLAVE_ADD_VF1: BYTE := 1;
FCT_READ: BYTE := 3;
TIME_OUT: WORD := 300;
START_ADDRESS_ANSW: WORD := 0;
NUMBER_REG_READ: WORD := 2;
VF1_FREQ_W:DWORD;
VF1_FREQ:REAL;
You can't read directly float values by using of COM_MOD_MAST - that is serial Modbus RTU. So you can transfer only bits (coils) and words (registers). Usually float values are transferred by means of one or two consequence words - check your slave's mapping.
Here is example for reading of 2 consequence words and transfer them to real:
Provide pulses on EN input.
COM_PORT: BYTE := 1;
SLAVE_ADD_VF1: BYTE := 1;
FCT_READ: BYTE := 3;
TIME_OUT: WORD := 300;
START_ADDRESS_ANSW: WORD := 0;
NUMBER_REG_READ: WORD := 2;
VF1_FREQ_W:DWORD;
VF1_FREQ:REAL;
You can read directly float (real) values with COM_MOD_MAST. Just replace VF1_FREQ_W to VF1_FREQ in previous example and it will work if your data on other side is type float (real 32 bit). You may have an issue with byte orders, but this you just need to test and fix. If you need to read several real values then you can replace COM_MOD_MAST.DATA := ADR(VF1_FREQ_W) with array type data. COM_MOD_MAST.NB need to be two times the ammount of real values you are reading eg. one real (32 bit) value NB = 2 (2x16 bit), 10 real (320 bit) NB = 20 (20x16 bit).
If you use structured data type with different data types eg. first variable type int (16 bit), second variable type real (32 bit) then AC500 will create an empty 16 bit space between first and second variable. You can't see this "feature" in simulation mode, only when you are in online.
If you use structured data type with different data types eg. first variable type int (16 bit), second variable type real (32 bit) then AC500 will create an empty 16 bit space between first and second variable. You can't see this "feature" in simulation mode, only when you are in online.
Add new comment