![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Member
![]() ![]() Join Date: Jun 2010
Location: London
Posts: 140
|
Tia Portal Pro - Word Array to Real Struct?
Hi there,
I have an array of 44 words that contain the two parts of a set of real numbers. I want to copy these words over to my Struct which contains the 22 Reals. I've tried all the obvious Block Move type instruction options in TIA portal but non of them seem to work for me. Can anyone suggest away to do this? The image should make things clearer. Many thanks, Justin |
![]() |
![]() |
#2 |
Lifetime Supporting Member
|
What are the correct values for some of the REALs, and the corresponding values for the WORDs? Doesn't have to be exact, if the numbers are fluctuating.
Offhand, the REAL values being negative suggests the order of the words and/or of the bytes are reversed. Try swapping every other word before the block move, then try swapping bytes within the words. There are only so many possibilities.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#3 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,616
|
Example code to swap the modbus words to give different flooting point results. As already said, what should the data be?
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com |
![]() |
![]() |
#4 |
Member
![]() ![]() Join Date: Jan 2006
Location: Finland
Posts: 1,945
|
https://support.industry.siemens.com.../view/42603881
Example 2 is for copying between different types, but do you need also word -> real conversion between? |
![]() |
![]() |
#5 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,616
|
db contents:
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com |
![]() |
![]() |
#6 |
Lifetime Supporting Member
|
@LD and @Lare have it:
I have no idea where OP is getting the data for their floating point values in [AlgInput], it is almost certainly not from the Words in [InputRegister] There may be an issue with how the data are physically laid out in the Struct with the 22 reals. Isn't there an "optimized" option for data blocks?
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#7 | |
Member
|
Quote:
If those 2 words contain floating point number formatted as IEEE 754, then proceed as follows: Code:
L FirstModbusWord T MW20 L SecondModbusWord T MW22 ... L MD20 |
|
![]() |
![]() |
#8 |
Member
![]() ![]() Join Date: Jun 2010
Location: London
Posts: 140
|
Hi everyone,
Please ignore the actual data in the reals. It's old data not any data that was copied across. Sorry for confusion. I basically just need to understand what instruction will allow me to move the data from one data type to another. Being words in an array to Reals in a struct. the start address and count of the array I need to be able to adjust. The destination structs will of course be fixed. I will have a look at the Siemens link Lare provided, Many thanks |
![]() |
![]() |
#9 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,616
|
If you have to swap the words, there is no instruction to do this whilst performing a block move or the like. You will have to create in intermediate array as in my example - you can then block move the swapped array to your struct of reals.
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com |
![]() |
![]() |
#10 | |
Member
![]() ![]() Join Date: Jan 2006
Location: Finland
Posts: 1,945
|
Quote:
Swap command should work also for P area if data is words or dwords. Haven't tested how it works if serialize blocks outputs is word area, then swap for entire structure and after that deserialize. At least it should work if first moving from bytes to words and after that swap. |
|
![]() |
![]() |
#11 |
Lifetime Supporting Member
|
Even though you did not supply the actual values, I am pretty sure that @LD nailed it on the values:
xxx.png
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; January 16th, 2022 at 04:18 PM. |
![]() |
![]() |
#12 |
Lifetime Supporting Member
|
P.S. I did uncheck [Optimized block access] for the block containing the Struct with the Reals, but that may not be necessary.
yyy.png
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#13 | |
Member
![]() ![]() Join Date: Jan 2006
Location: Finland
Posts: 1,945
|
Quote:
I maybe would use temp bytes with lenght of 0..249 bytes. That way it would work to all modbus query lenghts, lenght 255 for sure. |
|
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
TIA Portal Indirect Addressing/Recipe Management | ASF | LIVE PLC Questions And Answers | 19 | April 6th, 2018 12:52 AM |
TIA Portal: change tag value | ASF | LIVE PLC Questions And Answers | 3 | September 27th, 2016 01:45 PM |
TIA Portal V12 | FireBeard | LIVE PLC Questions And Answers | 1 | September 24th, 2014 04:07 PM |
Siemens OP77B Trouble in TIA Portal | Tim James | LIVE PLC Questions And Answers | 4 | December 24th, 2012 03:27 PM |
Not able to understand this S7-code | drspanda | LIVE PLC Questions And Answers | 8 | November 13th, 2007 01:06 PM |