Real value shows as Double Word in DB in Simatic Manager

When you set up the DB in classic Step7 or PCS7, all the addressing is in bytes. When you are building the DB and you declare a value as Real, it will automatically reserve 4 bytes. It will show something like Byte 0.0 Real, then the next entry will be Byte 4.0.

Since the OP says it was declared as a Real in the DB, then it will try and show real values, something is wrong outside the DB.


Modbus don't standardize order of bytes on integers and real values. That is why modbus drivers have selection for byte orders.

More likely slave have different byte order on real values than Siemens.



On bit side also LSB and MSB bytes can be different on different devices.
 
Modbus don't standardize order of bytes on integers and real values. That is why modbus drivers have selection for byte orders.


De facto Modbus, yes, I agree.

But according to the actual spec, I think it does standardize: MSByte-first for all 16-bit unsigned integers (except the CRC in Modbus RTU, IIRC).

That said, not every vendor's driver implements the actual spec correctly, and some also allow you to flip byte order to correct for that.

And if the device combines 16-bit registers to make 32-bit or larger bit-entities, then the word order may be a problem no matter if it follows the spec byte order or not.
 
Thank you all for all your answers.

I am at site today, and looked at values both in the device, and in the DB which is receiving the values from the device.

I attached two screenshots. One is from the device readings, showing 3 voltage values. In the DB these values are showing correct. Notice that it is not the values of VB and VC in the device is not exactly the same, as REAL value 4 and 8 in teh DB, because screenshots were taken at different times. The values are fluctuating around 1 Volt. I put a red frame around the values I am comparing.

Strange enough, it seems that random values in the DB are shown in Double Word value.

And I am not using PCS7, we are using Simatic Manager.

Reading from device.png Reading from DB.png
 
Is this a new program, or one that used to work but now does not?


My guess is that this is a new program, and you have two problems that semi-cancel each other:

  1. you are off by one holding register in the Modbus data transfer address
  2. There needs to be a word-swap performed when the off-by-one addressing error is corrected.
    1. Because the three values are in the same ballpark, so only the low 16 bits or so of the mantissa of each REAL are significantly different between the three values.
Here are some items that could be useful to diagnose (otherwise we are all just guessing):

  • A document, or link to same, with the device's Modbus address map
    • Specifically, what is the value of the register, or registers, that is just before these three REALs? I am guessing that it is 0.
  • Screenshots of your Modbus message instruction in the PLC
    • Include any setup screens, associated data and data structures with values (addressing, Modbus function code, etc.)
  • The entire program
  • Change the Modbus instruction to read four reals from the device, starting at the current holding register address
    • Show the value of all of those reals.
  • Add a similar Modbus instruction get the same data as eight 16-bit words.
    • Show the values of those words.
 
Last edited:
Yes and no: the writing of the zero is done by the Modbus function code 0x03 Read Holding Registers from an earlier holding register.


On second thought, I don't think the off-by-one hypothesis is going to hold up: it would put 1.147 in the PLC's VA and 1.178 in the PLC's VC, and the device's 1.132 would not show up in the PLC.
 
It looks weird that the DW values in the DB are in random positions.
If it was an issue with overwriting registers, maybe we should've had more pattern to it.

If you look at attached there isn't the same difference between the DW values within all the REAL values.

DB.png
 
@orense:


1) Please post the Modbus mapping document you are using
2) Please read the Modbus data to 16- or 32-bit integer words
3) Please list the floating-point values you expect to see

Without those data, you are flailing, and no one here can help you.
 

Similar Topics

OK I'm ashamed that I'm here asking this as I think in 23 years I would have ran into this before. But here we are. Created an AOI to manipulate...
Replies
6
Views
1,963
Hi all, Let's say we have a nice real (analog) value that has already been scaled with an SCP in Studio5000. Is there a slick method to...
Replies
6
Views
1,558
My company imposes programming standards and insists on using AOIs for AI, AO, DI, DO points. I like AOIs and use them as subroutines when I have...
Replies
10
Views
2,997
Hi Guys, i'm begginer and i'm trying to convert a real value (not fix value) to BCD. It works if i put fix real value but when i put variable...
Replies
2
Views
1,913
Hi everyone :* I am using using unity pro v.13 i want to do the mathematical function of floor() which makes for example 1.2 to 1 and makes 2.9...
Replies
7
Views
3,022
Back
Top Bottom