2/19/2024 5:22 PM | |
Joined: 2/19/2024 Last visit: 2/19/2024 Posts: 1 Rating:
|
Hi All, I am looking to have a MODBUS Server using the MB_SERVER block and have it be able to pull from a buffer with both Real and Bool values. From what I can find in the online tutorials for this everyone uses an array for the buffer which means it can only be a single data type. I found one reference which shows how to use absolute data block referencing to allow for multiple data types here but I cannot get this to work in TIA Portal v18 as it does not allow the syntax for absolute addressing as shown in that reference. Does anyone have any idea how this can be accomplished? Thanks! |
2/19/2024 6:00 PM | |
Joined: 7/7/2010 Last visit: 8/28/2024 Posts: 15116 Rating:
|
Several approaches, all of which have been posted repeatedly over the years, with new options posted as they are provided/supported with firmware and new Portal versions. What has always worked: MB_Buffer: Array[0..buffersize-1] of Byte Then map or copy data from the bytes into various tags, preferably in a DB, minding the Endian-ness (byte order) of the multi-byte data (integer/real) as needed during the mapping (moving). Eventually UDTs were added and people started block moving the byte array into a UDT preconfigured with everything the way they wanted, and fixing any Endian-ness issues during the mapping (which often appear here because of 2/4 byte Siemens datatypes end up being swapped when using a UDT (more often than not). With more complaints and such, Siemens provided the Serialize / Deserialize instructions to help facilitate byte array date mapped into a UDT or a DB struct preconfigured with the correct layout to match the expected return values and data sizes / types. If you want to dig into any of these 3 suggested options, you have something you can use in F1-Help within TIA Portal and these forums to find more detailed solutions. Pay particular attention to forum replies by @qwazee on these subjects as he is extremely good at providing directly useful examples and screenshots with steps to complete specific tasks to enable any one of these options.
|
science guy |
|
This contribution was helpful to
1 thankful Users |
2/19/2024 8:46 PM | |
Joined: 3/30/2020 Last visit: 8/28/2024 Posts: 4706 Rating:
|
A compliment from 0_Einstein must be his way of reminding me @Autogen: Be on the lookout for the fact that the memory that you feed into the server instruction is non-optimized. you can fill out the DB as you want but the elements must fill up to a word-boundary. The notes below is additional to what 0_Einstein already mentioned. To simplified case is to use M-memory instead of a DB. We have plenty of M-memory. Assume for the moment we are using a block memory that starts with %M3000.0. Assume we have
The any-pointer address that connects to the holding address pin of the instruction is then P#M3000.0 BYTE 8. (In the example you linked to it was P#DB3.DBX0.0 BYTE 62.) The above method avoids the complications of making a UDT. But you must keep to the rule to use the memory in word sizes. There is no need to push the data into an array of bytes. The instruction handles the data in a raw format so it is blind to the structure you used. exchanges by Modbus/TCP is however in word sized chunks. It is up to the client to decode those words to individual elements. Also review the following example: |
Last edited by: qwazee at: 02/19/2024 20:47:54Last edited by: qwazee at: 02/19/2024 20:51:06Last edited by: qwazee at: 02/20/2024 04:11:55Activities of this user is voluntary. There is no obligation or liability placed on this user. Though optional, your 'please' and 'thank you' is highly valued. |
|
This contribution was helpful to
1 thankful Users |
Follow us on