Siemens SCL from Ladder

CharlesM

Member
Join Date
Aug 2005
Location
Arkansas
Posts
1,129
I am working on a com block to a motion controller. I got the basic part of it working in ladder. Now I need to put it into SCL so I can put it into a loop. In moving it over before I started the loop I wanted to make sure what I had worked and it didn't. I don't know what I'm doing wrong but I'm sure its something simple. I have two bits and any time they are both off I want to turn another bit on. Works fine in ladder but in SCL it never changes.

LADDER.JPG


IF DB450.DBX64.7 = FALSE AND DB451.DBX32.7 = FALSE THEN
DB451.DBX32.6 := TRUE; //WRITE
DB451.DBX32.7 := TRUE; //WRITE
END_IF;
 
This will do the job:-

Code:
DB451.DBX32.6 := (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7);
DB451.DBX32.7 := DB451.DBX32.6;

NB:The ladder for the code you posted would be as follows:
scl001.JPG
 
Last edited:
Not Quite

When using a set coil you should calculate the boolean result and or with the set coil. This way the set coil stays set even if the boolean result is 0. L D[AR2,P#0.0]'s code could set the outputs to 1 or 0 which isn't right.
Code:
DB451.DBX32.6 := DB451.DBX32.6 OR (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7);
DB451.DBX32.7 := DB451.DBX32.7 OR (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7);
 
I think that will get me going. I don't do enough SCL to get good at it. I just don't think in boolean terms so I never think to try it that way. I think in "if" logic from my days of doing Delphi.

FYI Peter
This is for the Enhanced+ Profibus coms to the RMC70.
 
I noticed the RMC in the network comment.

Code:
IF (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7) THEN
  DB451.DBX32.6 := TRUE;
  DB451.DBX32.7 := TRUE;
END_IF
I don't see why your original code didn't work. Normally I don't compare to TRUE or FALSE because the IF THEN is supposed to evaluate to a TRUE or FALSE as in my example. The way I wrote the code above I think is the most intuitive.

Here is an extra credit question for anyone. How does one re-write
(NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7)
without using the AND and using a OR instead. Is the solution with the OR faster?
 
Originally posted by Peter Nachtwey[b/]:

Here is an extra credit question for anyone. How does one re-write
(NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7)
without using the AND and using a OR instead. Is the solution with the OR faster?


NOT(DB450.DBX64.7 OR DB451.DBX32.7)

I'm not sure if that is faster or not. The second solution seems to perform less operations but I don't know enough about CPU architecture to know if that is really the case.

Keith
 
Peter - you must be referring to the wrong ladder diagram. Go back to post #1, there are no SETs in the ladder posted.
 
Good catch

L D[AR2 said:
Peter - you must be referring to the wrong ladder diagram. Go back to post #1, there are no SETs in the ladder posted.
You are right. Then your code is right and I can see why CharlesM code didn't work. CharlesM needed to do something like.

Code:
[left]IF (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7) THEN[/left]
DB451.DBX32.6 := TRUE;
DB451.DBX32.7 := TRUE;
ELSE
[left]DB451.DBX32.6 := FALSE;[/left]
DB451.DBX32.7 := FALSE;
END_IF
 
Thanks for all the help. This is what I ended up with.
Code:
DB451.DBX32.6 := (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7);
DB451.DBX32.7 := (NOT DB450.DBX64.7) AND (NOT DB451.DBX32.7);
 

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,071
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,060
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,760
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,982
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,379
Back
Top Bottom