STL Advice

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Hi

To grade myself up I sometimes ask opnions of other programmers

vvbc.JPG


is this well written, or get it be done better ?

COIDKE is a return command for a length meter on RS232
 
I'm being picky here, but you could swap the order of the loads

Code:
L #Length
L 0.0 
==R
to
Code:
L 0.0
L #Length
==R

to save the TAK - but you may be using this fact in the remainder of the code that we can't see.

Also the JC HIGH could be JU HIGH as the RLO will always be true if program flow arrives at this point. The JC implies that there is a decision being made when in fact it has already been made earlier.
 
hey

Great tips !!!

Thanks

L D[AR2 said:
I'm being picky here, but you could swap the order of the loads

Code:
L #Length
L 0.0 
==R
to
Code:
L 0.0
L #Length
==R

to save the TAK - but you may be using this fact in the remainder of the code that we can't see.

Also the JC HIGH could be JU HIGH as the RLO will always be true if program flow arrives at this point. The JC implies that there is a decision being made when in fact it has already been made earlier.
 
What a difference from the usual 'traffic lights' homework questions.

When someone posts "Quick. I need help with my assignment. Give me the answer." the common response is "Well, show us what you've done so far and we'll help assess it."

But here we have someone who opens up his code straightaway and asks for advice, not on writing it, but on improving it. And they get a prompt relevant response and seem delighted with the answer.

If only they were all like this!

regards

Ken
 
Combo, I would look at NW1 and see if it is necessary to write constants to the same addresses every time. Usually if my program needs constants, I write to them once during start-up rather than doing it every scan.

Also, another minor point, you could also initialize your CHARs using something other than the byte data type. For instance:

L 'COID'
T DBD 0

It sometimes makes the code a little easier to read.


Ken M said:
If only they were all like this!

Yes, I agree. Combo is one of my favorite posters.
 
Ohh

Favorite poster, ohh really, thanks :)

:site:

I'll try L 'COID'

thanks

S7Guy said:
Combo, I would look at NW1 and see if it is necessary to write constants to the same addresses every time. Usually if my program needs constants, I write to them once during start-up rather than doing it every scan.

Also, another minor point, you could also initialize your CHARs using something other than the byte data type. For instance:

L 'COID'
T DBD 0

It sometimes makes the code a little easier to read.




Yes, I agree. Combo is one of my favorite posters.
 
..;

L 'C'
T DB100.DBB 0
L 'O'
T DB100.DBB 1
L 'I'
T DB100.DBB 2
L 'D'
T DB100.DBB 3
L 'K'
T DB100.DBB 4
L 'E'
T DB100.DBB 5
L '$R'
T DB100.DBB 6
L '$L'
T DB100.DBB 7


I wrote it like this tnx to your suggestion:

L 'COID'
T DB100.DBD 0
L 'KE'
T DB100.DBW 4
L '$R'
T DB100.DBB 6
L '$L'
T DB100.DBB 7
 
L 'COID'
T DB100.DBD 0
L 'KE$R$L'
T DB100.DBD 4

This works, tnx.


jacekd said:
I don't have a CPU at hand to check it for sure, but this also should work:

L 'KE$R$L'
T DB100.DBW4
 
Don't understand why you changed from

OPN DB100

L 'C'
T DBB0

to

T DB100.DBB0

unless the DB is symbolised and the comment is on the DBB is important.

The newer way means that you attempt to open DB100 every time, this uses up scan time, even though the block is already open.
 
hey

OPN #DATA_DB
L 'COID'
T DBD 0
L 'KE$R$L'
T DBD 4


PeterW said:
Don't understand why you changed from

OPN DB100

L 'C'
T DBB0

to

T DB100.DBB0

unless the DB is symbolised and the comment is on the DBB is important.

The newer way means that you attempt to open DB100 every time, this uses up scan time, even though the block is already open.
 

Similar Topics

i am new to simatic manager and i am trying to figure what this part do in the code : A I 5.6 = DB50.DBX 4.6...
Replies
3
Views
125
Hello everyone, can anyone help me with covert the STL code to ladder. Iam using plc s71200. A %DB1.DBX33.7 // angel of vaccum...
Replies
2
Views
202
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
310
First off thank you in advance. Second I am very new to STL. I am trying to build a counter that has one count up and 23 count down options. Am...
Replies
6
Views
363
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
651
Back
Top Bottom