Step 7 - few questions

luccass

Member
Join Date
Jun 2009
Location
UK
Posts
56
Hi Guys,
there is a project in the near future which I'm likely to be involved with. Based on S7-300 family and 3rd party SCADA system.

At this stage I'm trying to learn Siemens (have worked with AB before).
I've been reading a thread on this forum called 'I am forced to really learn how to programme a S7' - very helpful and interesting :) Got Berger book as well, Siemens manuals, etc..
My questions would be:

1) S7Guy has shown us his way of organising data using FBs and UDTs and call them unconditionally setting AR2 and opening relevant DB - fair enough, got it!
During the first scan he finds out the length of UDT and start address of the DB, as below:
Code:
L     P##UDT_START_POINTER
      LAR1  
      L     W [AR1,P#2.0]
      SLD   3
      T     #UDT_LENGTH
      L     D [AR1,P#6.0]
      AD    DW#16#FFFFFF
      T     #UDT_START

What does the statement L W [AR1,P#2.0] do in this occasion?
In AR1 we have got the ANY pointer pointing the first 'important' element of the DB, so AFAIK, because this element is UDT type, the ANY pointer holds info about the entire element - Type, quantity, DB number, Area pointer.
Does is sound correct?
Berger books says: (regarding register-indirect addressing)
L MW[AR1,P#0.0] load the memory word whose address is located in AR1
I assume AR1 was loaded before like this LAR1 P#30.0.
So we physically store data from MW30 to ACC1 - am I right?

In S7Guy example, by executing L W [AR1,P#2.0], we're trying to find out the length of the UDT. Does this mean that we loading ACC1 with NOT the data pointed by ANY pointer, but with the contents of AR1 (Byte n+2 and n+3)?
I don't 'feel' it very well, am I missing something important?

2) When S7Guy is trying to point the data within DB, he opens a DB, sets AR2 to point the first element and then calculating the offset and providing this to the function setting AR2:
Code:
      CALL  "FC Motor"
       Motor:=21

Let's know assume that we've got 100 of this motors, it's very difficult to remember what motor's got what number. What would be your neat and convenient way of modifying the code to be able to 'choose' a motor by its tag name, for example:
Code:
      CALL  "FC Motor"
       Motor:=Motor_21


3) When we creating a UDT and DB we would like to have ALL the info about one device under one UDT, one DB element. Majority of this parameters would be calculated only within the code, but some of the signals come from 'external' world, like Inputs, Outputs, etc.
Again, what is your neat way of assigning 'external' values to the 'internal' DB values? I do realize that this would have to be done 'by hand', but it would be nice, to at least use symbolic addresses (tags) instead of direct array access like
"DB Motors".Motors.Motor[15] = I1.2

I would be extremely happy if we all guys could talk about different approaches. Thanks for your help :)
btw. Excuse my English, I'm still learning ;)


luccass
 
Let's know assume that we've got 100 of this motors, it's very difficult to remember what motor's got what number.
You need to define 100 INTs with motor names and the INTs are initalized to the motor number.
Even if you were programming in C you would need to use #define, const, or enum to define all the motor names.
 
Last edited:
Make the motor name part of the motor udt - you could use a string if it helps makes things clearer.
 
You need to define 100 INTs with motor names and the INTs are initalized to the motor number
Even if you were programming in C you would need to use #define, const, or enum to define all the motor names.[/quote]

Thanks Peter,
that was my initial idea on how to approach that task.
Then I thought: 'What if I make mistake with assigning numbers to each motor?' What I'm after is that I want to make sure, that MotorTag numbered 1 is 'connected' with FB's element 1, 2<->2, 3<->3, etc..
That case only one place I can make mistake is when I'm assigning field addresses to the relevant MotorTags - but this should be easy to troubleshoot.

Is that clear? :)
 
Make the motor name part of the motor udt - you could use a string if it helps makes things clearer.

But to be able to use it within the code I would have to create a FC 'Give me an array element from a DB which holds in its .MotorName field value 'MotorTag'?? Or I'm looking at this from the wrong angle? o_O
 
Not a huge Siemens fan but if memory serves me right you could
easily define a block of n motor data types (INTs or UDT or whatever) and name each element. I do this by creating the block in source and then compiling it. You should be able to access the block (of single UDTs) via pointer just like you would with an array of UDTs.

In order to see what the source will look like build a block manually and then generate the source for it.

When you add motors you can just redefine the block and update it with the new motor names.

Oh yea, you'd access the motors via code as follows: DBx."Motor1".element.

Correct me if I'm wrong.

Good luck,

(8{)} :) .)
(Yosi)
 

Similar Topics

I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
178
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
249
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
339
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
547
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
677
Back
Top Bottom