SCL help

Mrslipmat

Member
Join Date
Mar 2009
Location
Inside a cabinet somewhere....
Posts
199
Hi guys

Its been some time since I worked with SCL and have a few lines of code I need some help with, I have the SCL raw code and am currently trying to convert it in TIA V14, could anybody please point me in the right direction with the ladder solution ?

Code is as follows:

// Actual Position
MOVE_BLK(IN:=#DATA_IN[4],
COUNT:=4,
OUT=>#TMP_ARRAY[1]);

#X := DINT_TO_REAL(DWORD_TO_DINT(#TMP_VAL)) / 1000.0;

I have a function for the block move, however I'm not sure if they are converting DINT_TO_REAL and then dividing by 1000.0 as apposed to converting DWORD to REAL then REAL to DINT then dividing by 1000.0

A few other pieces of code are attached below I'm having problems with converting too.

// Differential pressure
MOVE_BLK(IN := #DATA_IN[16],
COUNT := 2,
OUT => #TMP_ARRAY_16[1]);
#TMP_VAL_REAL := INT_TO_REAL(WORD_TO_INT(#TMP_VAL_WORD));
#XDP := #TMP_VAL_REAL / 16.383;

// Speed setpoint 1 limit and conversion

#TMP_VAL_REAL := #VA1;
IF ((#TMP_VAL_REAL < 0.0) AND NOT (#PQ_ACTIVE)) THEN
#TMP_VAL_REAL := 0.0;
ELSIF (#TMP_VAL_REAL < -100.0) THEN
#TMP_VAL_REAL := -100.0;
END_IF;

IF (#TMP_VAL_REAL > 100.0) THEN
#TMP_VAL_REAL := 100.0;
END_IF;

#TMP_VAL_REAL := #TMP_VAL_REAL * 163.83;

#TMP_VAL := DINT_TO_DWORD(REAL_TO_DINT(#TMP_VAL_REAL));

MOVE_BLK(IN := #TMP_ARRAY[3], // Only written to the lower word
COUNT := 2,
OUT => #DATA_OUT[8]);

Any help would be greatly appreciated and many thanks in advance.

Mrslipmat
 
In ladder, you have to create a temporary variable of the correct type to serve as a placeholder between instructions.

So you would need a DInt variable and call the Dword to Dint in a rung and assign it to the temp variable.
Then take the temp variable and use it as the input to the INT_TO_REAL function and write to X.
The next rung you would divide X by 1000.0 and assign it to X.

One thing to bear in mind though is if X is a variable to be read or transmitted to a SCADA system. If it is, you would want to buffer it, so that there is no chance of X being read before being divided by 1000.0.

The other bits of logic seem variations of the same problem.
 

Similar Topics

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
349
Hi! I am working on a project were we will be replacing an 300 CPU with a 1500 CPU and we are working on migrating / converting code. There is a...
Replies
9
Views
1,087
Hi, Can someone translate this for me please, or at least help to explain what the instructions mean? SET SAVE =...
Replies
17
Views
4,634
Working with a SCL instruction and need a little help. The logic is a Heat / Cool circuit controlled by a PID. The PID Zone_4.CVEU tag is coming...
Replies
3
Views
3,173
Hi, I am new to SCL and would like to do the following: Read an input, divide the input by a constant and produce an output. I want this to...
Replies
3
Views
1,822
Back
Top Bottom