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:
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)
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:
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:
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
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)
I assume AR1 was loaded before like this LAR1 P#30.0.L MW[AR1,P#0.0] load the memory word whose address is located in AR1
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