Siemens S7 SCL-rookie

A great deal of the collisions with the customers code can be avoided by choosing symbolic adress priority. You can then write and maintain your code without having to worry about changing adresses.
However, for indexing through an array in a dynamic kind of way, I think there is no other way than extracting the number of elements programatically just like you are doing.
 
Hi, L D[AR2,P#0.0], JasperMP

By counting source code lines in an editor: 3000 lines minus blanks and comments, my rough estimation is 2500 lines.

The code makes C-like heavy use of pointer arithmetic and "bit shuffling". It also communicates via TCP-IP to a host-computer.
It's a realtime data-acquisition app.

I'm well aware, that my first SCL code will be a mess (the same was true when I began programming in C many years back...)
(I don't think my boss lets me rewrite & beautify the code, though)



JesperMP:
by "symbolic adress priority" you're talking about of solely using symbolic FC-Names and so on?
That's fine for me. I really try to avoid "hardcoded" names....
 
You are aware of the settings for absolute or symbolic adress priority, right ?
You find it in the project tree, when you select the blocks folder and right-click to open the properties. There will be several tabs, one is for "Adress priority". Because this setting is hidden so well, many beginners are not even aware of its existence. I was pointed to it by S7Guy on the forum.
I really really recommend to select symbolic address priority for all accesses.
 
A quick check reveals the following:

100 lines of SCL produces a block of approx 3300 bytes. (I took the 10 lines of code from FC90 previously posted and repeated it 10 times)

2500 lines extrapolates to 82500 bytes of memory.

How much memory is available in your 314 CPU ?
 
Yeah, I don't think you have a prayer of making this work unless you use symbolic priority. Even within the S7 code, without using an app to modify the source code, I routinely handle cases where the absolute addresses change. If I had a udt that previously had 10 udts of 120 byes and change it to an array of 15 with 150 bytes, it just continues to work without changing anything. Basically, it allows me to do things as you descibe, such as addressing an array of [1..max] instead of hardcoding the max.
 
Hi folks!

JesperM:
--------

Thank you for pointing that out. Right now, I do not yet know what "address-priority" means, but I gonna check that out...

L D[AR2,P#0.0]:
---------------
Supposedly: 128 kByte (but I'm not sure.)
I already implemented the TCP-Interface using AG_SEND/AG_RECEIVE. For my testing purpose I coded a simple echo-server which receives a block of 16 bytes and echoes the date back on the same TCP-connection.

Once again: the support and samples of your's helped me way more than the explanations of that Siemens guy. The implementation was straight-forward and one very relieving thing: handling of Anypointer's is easy. Looking at your code, I did the following:

 TYPE AnyPointer
STRUCT
byId : BYTE;
byTyp : BYTE;
iCount : INT;
iDbn : INT;
dwPtr : DWORD;
END_STRUCT;
END_TYPE

....

//
//------------- DB "Glob"
//
DATA_BLOCK Glob
STRUCT
TcpRxFsm : STRUCT
RxBuf : STRUCT
Daten : STRUCT
Header : ARRAY[0..3] OF BYTE;
Data : Paket;
END_STRUCT;
bFull : BOOL;
END_STRUCT;
END_STRUCT;

//
//------------- FSM
//
FUNCTION TcpFSM
VAR_TEMP
AnyPniRx : AnyPointer;
pAnyRx AT AnyPniRx : ANY;

...

END_VAR;

...

pAnyRx := "Glob".TcpRxFsm.RxBuf.Daten; // <--- that's easy!!!!

....


AG_RECV ( ID := Config.IpConfig_Can.iId,
LADDR := Config.IpConfig_Can.wLaddr,
RECV := pAnyRx,
NDR := bDone,
ERROR := bError,
STATUS := wStatus,
LEN := iLen
);

....

                                                     



(How can code snippets be posted so that formatting is kept?)


The assop "pAnyRx := "Glob".TcpRxFsm.RxBuf.Daten;" does all the job regarding the Anypointer :)

I will check out the code size tomorrow.



Hello S7Guy!
------------


I'm a bloody rookie on the S7-field and have to learn a lot of things ....

And I won't give up!!!

:)



Reagards, guys!
 
Last edited:
To preserve code snippets use

codecode.JPG
 
Right now, I do not yet know what "address-priority" means, but I gonna check that out
Symbolic adress priority means that symbols takes presence when programming. If you change symbols, by moving absolute adresses, the code will follow these changes automatically. You dont want to even live without this feature ! Without it it soon becomes a nightmare to make sure that code follow changes in for example FB and UDT declarations. Also data from shared DBs can change, for example if you have several STRUCT's in the same DB and you modify an ARRAY from 10 to 12 elements, then all the following will be moved without you thinking about it. Symbolic address priority takes a burden off your shoulders.

By the way, if you use ethernet, then why use a 314 CPU ?
If you go for a 315-2PN/DP you get 256kB memory (against 64kB) and the onboard ethernet is much faster than a CP343-1. And the price for a 315-2PN/DP is practically the same as a 314 + CP343-1.
 
JesperMP !

JesperMP,

I'm not sure if I got you right regarding "Symbolic address priority" (I will read the docs tomorrow).
When I grow an array from 10 to 12 bytes it's clear that all following data will be move located 2 bytes "later" in memory.

In my code I will use only "names" for variables, so if I increase the array I will re-compile all affected modules.


Mmmmh. I have to read ...

Regarding the CPU:
that's not our decision, currently our customer has already a 314 CPU.
As I already stated (hopefully) we have to run our code on an already installed cpu, so we (unfortunatelly) usually cannot tell our customers what cpu they have to use, :-(


BTW:

Has anybody experience in using Vipa-PLCs?
 
Whilst you maintain all of your source code in the same SCL file and use symbolic names for everything and re-compile the whole lot, you need not worry about symbolic or absolute address priority.

If you split the SCL into several source files you can create an SCL compile control file which specifies the order in which the source files are compiled.

However, I have never used symbolic address priority, so it will be interesting to see how it works when using SCL source files.
 
augenstern said:
In my code I will use only "names" for variables, so if I increase the array I will re-compile all affected modules.
I know for STL and LAD, that if Absolute Adress Priority is selected, then your code will not update correctly when symbols are modified (like when a DB is modified).
Maybe SCL is not included in the Absolute/Symbolic Adress Priority distinction. It sounds logical enough because it probably loads the currently active symbol table at compile time.
I would have to experiment to know for sure.
 
Hi JesperM et al.!

Hi JesperM et al.!

Thanks again for the help!

I'm still wondering how to deal with Vipa-PLCs.
The other day I talked to a programmer who is familiar with Vipa and he told me that ther are quite some differences between S7 and Vipa SPS. E.g. the S7 AG_SEND (FC5) and AG_RECEIVE (FC6) are SFCxxx in Vipa PLC? Is that right?

Has somebody used S7's SFC64 (Get Systemtime). It's hearsay that there are some irregularities with that SFC?
 
We once decided to try Vipa plc's in a project that we had to connect several plc's to an it system using Iso on tcp connections. Ag send and ag recive was used on the plc end. The Vipa systems seems to handle the connections diffrently than Siemens and the Germans at Vipa couldent solve it so we went with Siemens. I later decided to give the Vipa cpu another shot in another project that had several RFID readers from Pepper and fuchs connected on profibus an ran into problems once again. The readers worked perfectly with a siemens plc's but the Vipa complained and i never got the readers to work. So if you want to buy a Vipa cpu cheap i got one for sale.
 
augenstern said:
Hi JesperM et al.!

Thanks again for the help!

I'm still wondering how to deal with Vipa-PLCs.
The other day I talked to a programmer who is familiar with Vipa and he told me that ther are quite some differences between S7 and Vipa SPS. E.g. the S7 AG_SEND (FC5) and AG_RECEIVE (FC6) are SFCxxx in Vipa PLC? Is that right?

Has somebody used S7's SFC64 (Get Systemtime). It's hearsay that there are some irregularities with that SFC?


Hello,

SFC 64 should be no problem, it is a very simple SFC.

There are differences between VIPA and SIEMENS PLCs,
but there are also differences between SIEMENS sub 315 CPUs and 315PN/DP/317 and 319 and 318 and 400 CPUs which are not negligible !!!

If you change CPUs or Firmware check always for differences!
With SIEMENS or VIPA or anyone else!
 
Longbow said:
but there are also differences between SIEMENS sub 315 CPUs and 315PN/DP/317 and 319 and 318 and 400 CPUs which are not negligible !!!
Now, such a comment just begs for some details. I am interested in the differences between a 315-2DP and a 315-2PN/DP.
 

Similar Topics

Hello, When you want compare values of an array to a range of numbers is it a right way to do that? FUNCTION ADD VAR_IN_OUT A:ARRAY[1..50]...
Replies
5
Views
2,073
Hi All, I need to try and convert some code from Siemens SCL (TIA16) over to Allen Bradley RS5000. I have attached an image of the SCL and what...
Replies
10
Views
4,061
in the scl code written in screenshot Line 1 condition is false but still the program checking the line 2 condition and says it is true i had...
Replies
3
Views
1,762
I am new to PLC programming. Is there a standard way to incorporate alarms / warnings / events such as the exceptions in C++ or Java where you can...
Replies
5
Views
1,986
Hello All, I am new to programming with Tia Portal and I am having difficulty with something that we have found "easy" in other programming...
Replies
3
Views
2,381
Back
Top Bottom