preacher.ca
Lifetime Supporting Member
Good day.
I have a device on profibus that I am reading data from using SFC14. This data is written into an array within a DB. The array is 128 bytes in size. The formatting of each byte is not useful to me on its own as it is in hexadecimal. I have to do a bitwise swap to each byte and move it to another array formatted as INTs. I show both arrays in a VAT, one display format as "character" and the other as "DEC". Yes, the device sends alphanumeric values, but I only care for the numeric part of the data sent.
Example 1:
Device sends a byte as hex "32". PLC reads "32". In the VAT for array 1 shows "2". Array 2 will show "2".
Example 2:
Device sends a byte as hex "41". PLC reads "41". In the VAT for array 1 shows "A". Array 2 will show "2".
Good so far?
My question is more so for efficiency. Instead of copy and pasting 128 bitwise swaps, how can a loop be created to go through the array? I have google'd numerous combinations of Step 7 array loops to either say use "SCL" (which I have not used or am familiar with) or the examples did not seem to relate to what I am doing.
In my head I would think something similar to a do-while. While array does not equal 128, do bitwise swap for array1[0] and write to array2[0] and then increment the counter.
Any ways, if any one has a thought, I would appreciate the schooling. Or if you have a better way, feel free to throw that at me as well. The logic I have does work... it is just tedious to set up or modify...
Additional info:
-Siemens S7-417.
-Step 7 v5.5 + SP4 + HF11.
-Device is Anybus Profibus M30.
I have a device on profibus that I am reading data from using SFC14. This data is written into an array within a DB. The array is 128 bytes in size. The formatting of each byte is not useful to me on its own as it is in hexadecimal. I have to do a bitwise swap to each byte and move it to another array formatted as INTs. I show both arrays in a VAT, one display format as "character" and the other as "DEC". Yes, the device sends alphanumeric values, but I only care for the numeric part of the data sent.
Example 1:
Device sends a byte as hex "32". PLC reads "32". In the VAT for array 1 shows "2". Array 2 will show "2".
Example 2:
Device sends a byte as hex "41". PLC reads "41". In the VAT for array 1 shows "A". Array 2 will show "2".
Good so far?
My question is more so for efficiency. Instead of copy and pasting 128 bitwise swaps, how can a loop be created to go through the array? I have google'd numerous combinations of Step 7 array loops to either say use "SCL" (which I have not used or am familiar with) or the examples did not seem to relate to what I am doing.
In my head I would think something similar to a do-while. While array does not equal 128, do bitwise swap for array1[0] and write to array2[0] and then increment the counter.
Any ways, if any one has a thought, I would appreciate the schooling. Or if you have a better way, feel free to throw that at me as well. The logic I have does work... it is just tedious to set up or modify...
Additional info:
-Siemens S7-417.
-Step 7 v5.5 + SP4 + HF11.
-Device is Anybus Profibus M30.