Pointer in Step 7 (Again)

barryoc

Lifetime Supporting Member
Join Date
Nov 2009
Location
Kilkenny
Posts
148
Hi all,


I'm looking for a steer using a pointer. The code is working in a fashion but i'm not setting the bit i require.


The code looks at db17. This is 2D array 1-18 switches with 1-6 integer values. This is dbw0 - dbw214. The value in the DBW (1-18) will point to the bool i require to turn on.



E.G. 6 in any DBW (0-214) will turn on DB17.DBX216.6
8 in any DBW (0-214) will turn on DB17.DBX217.0



The issue i'm having is how to keep the value in AR1 between 0.0 and 2.2 so i only address bits in my range. I'm adding 2 to this to increment the word to look at but then i offset the bool i require.



Regards,
Barry.

Pointer.JPG
 
Pointer

All,


I changed the code to the following. It is now working except that if db17 contains 0 it will not set bit 0.



Thanks all for looking.
Barry.

Pointer1.JPG
 
Last edited:
Any chance you could show the processing required in pseudo code (like scl)?


There is no setting of any bits in your code - only assignments :)
 
Last edited:
L D,


You are correct. I do not need to set a bit, just turn a bit on if bit 0 of the word i am checking is true. It will always be bit zero i am checking as these are bools coming from a modbus unit into a word. (Each bool uses a complete word). The only issue with the code is db17.dbx216.0 will not turn on in PLCSIM when the value of 0 is in db17.dbw0-dbw214.


I will attempt to supply pseudo code.


Many thanks,
Barry.
 
It might be easier to do in SCL instead of STL, unless the goal is to practice pointers in STL.
 
Ot

So...


I've messed with machine code and assembly before; how hard could it be to learn enough to understand what is going on here?


I found the Siemens SIMATIC STL Function Manual, which contains this statement



The manual also includes a reference section that describes the syntax and functions of the language elements of STL.
Which is fine, except for the part regarding syntax, about which there is nothing. Nada. Bupkis. Too funny. Almost as good as the Red Lion video about IEC 61121, which was apparently about tumble dryer performance. I'm not making this stuff up!

xxx.png
 
I really need to go back to STL school. No matter how long I stare at this I can't figure put how there is any access to anything other than bit 0 of any of the bytes being addressed.

Keith
 
How about using the DECO instruction? You should be able to incorporate it into your loop. If this is accumulative... ie: once it's set you check the next word, use a WOR (word or) of the result of the DECO with DB17.DBW216.

DECO_Instruction.png
 
Last edited:
Hi all,



The below code works, but will need to be written 108 times to acheive what i need. The array of int in db17 contain the offset to the light i need to switch. (1-18). After this is the 18 bools for said light. The code i posted earlier works on plcsim but not on the real plc. (Micro Box 427c).


All, switch 1 gang 2 will point to DB17.DBX218.1, not DB17.DBX216.3 as in the image



Thanks agin,

B.

Pointer2.JPG DB17.JPG
 
Last edited:
Your comments are wrong, it should be:



If switch is on then turn .. on
If switch is off then turn ..off


Just being double sure that is what you intend.
 
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?
 
Damn, why this thread have only pictures of codes.
Code is much more easier to copy for testing and modify if STL is text also here 🤞🏻:mad:


On TIA you probably can code with symbolic and array[#pointer]?
 
Last edited:
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
 

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,096
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