Pointer in Step 7 (Again)

Link to manual please.


What am I, your google-intern?


It's the [Download] link here:


https://support.industry.siemens.co...-s7-300-and-s7-400-programming?dti=0&lc=en-WW


It's got gobbledegook in it so probably best to get it from there, but it was, for me,



https://support.industry.siemens.com/cs/attachments/45523446/s7awl__b.pdf?download=true


Or see it in-browser without the ?download=true i.e.



https://support.industry.siemens.com/cs/attachments/45523446/s7awl__b.pdf
 
Last edited:
Sorry to poke my nose in, but do you earn a medal for having to work with this?
Fascinating how Siemens still has a stranglehold if they don't move with the times.
Is Step7 still symbols overlaid on absolute addresses? Looks the same as when I was using Step5 in the 90's.
Hasn't everyone else moved on to purely symbols?




I thought C was the champion of "all the power of assembler with all the convenience of assembler;" maybe STL is competing for that title?
 
So, here's my intepretation in SCL. Given that light is a two dimensional array, what index of the second dimension is to be used?

what1.jpg
 
Apologies.


LAR1 P#DBX0.0
LAR2 P#DBX0.0
L 108
next: T #count
LAR2 P#DBX0.0
OPN "Light Switch Config Data"
L DBW [ AR1 , P#0.0 ]
+AR2

OPN "MB_Collection"
A DBX [ AR1 , P#0.0 ]
OPN "Light Switch Config Data"
= DBX [ AR2 , P#216.0 ]

+AR1 P#2.0
//+AR2 P#2.0

L #count
LOOP next




Thanks.


Thinking that you could do this also on word compare.


First, copy from DB17 6 ints indirectly.


index have value 0..17 to first array (looping from 0 to 17)




"DB17".switch[#index, 1] - move-> cmp1_word1
"DB17".switch[#index, 2] - move-> cmp1_word2
"DB17".switch[#index, 3] - move-> cmp1_word3
"DB17".switch[#index, 4] - move-> cmp1_word4
"DB17".switch[#index, 5] - move-> cmp1_word5
"DB17".switch[#index, 6] - move-> cmp1_word6




"DB18".switch[#index, 1] - move-> cmp2_word1
"DB18".switch[#index, 2] - move-> cmp2_word2
"DB18".switch[#index, 3] - move-> cmp2_word3
"DB18".switch[#index, 4] - move-> cmp2_word4
"DB18".switch[#index, 5] - move-> cmp2_word5
"DB18".switch[#index, 6] - move-> cmp2_word6

then And_word block for these word values, so you get 6 compare result of words of DB17 and DB18 arrays.


Now you need to set/reset DB216.0-218.2 bits depending of compare result.


then loop this 18 times?




And sorry, don't have TIA portal available right now, so no complete block code, more like pseudo code.
 
Last edited:
Thank all for the help.


I'm confused as to why my code does not work. Everything works fine except for DB17.DBX216.0 in PLCSIM. It shows working fine in the real PLC but will not turn on any bit. The code i wrote for the first 8 switches works fine but will take nearly 900 lines to write, hence the reason for trying the loop and pointer.



Will keep trying.



B.
 
Sorry to poke my nose in, but do you earn a medal for having to work with this?
Fascinating how Siemens still has a stranglehold if they don't move with the times.
Is Step7 still symbols overlaid on absolute addresses? Looks the same as when I was using Step5 in the 90's.
Hasn't everyone else moved on to purely symbols?


The new generation PLC's default to pure symbolic, but you can turn it off for legacy migration purposes.
 
Here is my word compare coding, maybe some errors or same than AR1/AR2 indirectly coding


I tested with MD180 = 0, 1 and 17 values.

array_test_db_blocks.jpg
 

Attachments

  • FC_TEST_COPY (FB1).pdf
    96.7 KB · Views: 3
I'm not sure how you would know the code is not setting any bits unless they happen to be in the last 18 stitches you check.

I'm making something of an assumption here. I believe that the contents of DB17.DBW0 through DB17.DBW214 are pointer offsets to reference the correct bit in the range of DB17.DBX216.0 through DB17.DBX218.1. This would mean that the values in the lower portion of DB17 are just six groups of repeating offset.

If this is true, DB17.DBX216.0 through DB17.DBX218.1 will end up with the status values of DB8.DBW178 through DB8.DBW214. If none of those happen to be 1 then none of the bits will be set.

Are you ultimately trying to determine if ANY of the referenced swtiches are on or are you trying to detect ALL of the switches that are on?

Keith
 
The algorithm will loop 108 times and control 18 outputs. The last output selecting a particular bit will win. If there is no entry for a particular bit, it will not change.



e.g.



Say the switch/gang array contains no zeros. Output bit 0 will not be changed.


Say the switch/gang array is full of zeros. What happens to output bit 0 will be determined by the processing in the last loop.



etc. etc.
 
The algorithm will loop 108 times and control 18 outputs. The last output selecting a particular bit will win. If there is no entry for a particular bit, it will not change.



e.g.



Say the switch/gang array contains no zeros. Output bit 0 will not be changed.


Say the switch/gang array is full of zeros. What happens to output bit 0 will be determined by the processing in the last loop.



etc. etc.


if the intent is to read data from modbus in a big loop of a 2 dimensional array then surely the output of the function needs a corresponing target array otherwise, as LD said, the function will always use the final incoming word
 

Similar Topics

Hello, Is it possible to perform operation like pointer on function. Regardless of value inside pointer or what ever variable I want to call...
Replies
2
Views
1,480
I would need advice in design which we are currently making in Step 5. Control system is based on Control modules which have defined structure...
Replies
6
Views
1,660
Hello Folks! I'm still trying to get the hang of using STL and Pointers in Step 7 (V5.5). For background, I'm writing a sample application...
Replies
7
Views
3,265
Hi guys, I am just starting to write some STL and thanks to this forum I got the solution to what i was trying to achieve. The question i have...
Replies
23
Views
9,097
Hello everybody How we can use pointer for Timers and counters,so that we could change Timer or counter address in the program?
Replies
7
Views
2,259
Back
Top Bottom