Hi All,
I need programming help regarding S7-1200 SCL. I have written pointer in S7-300 for bulk data save and read again. Please see two types of logic which was written S7-300. I don’t have enough knowledge about SCL programming in S7-1200. Please guide be how to write below pointer logic in SCL
1. Data save Logic:
QTY_DB_NO is array of 1000 real address. SET_BATCH_NO is interger address it will enter number like 1 to 1000. E.g if operator enter 1 then value will be save in first location of QTY_DB [ DBxx. DBD4]
OPN #QTY_DB_NO
L #SET_BATCH_NO
L 4
*I
SLW 3
LAR1
L DBD [AR1,P#0.0]
T #location
L #SET_BATCH_NO
L #batch_acc
==I
JC M002
JU M001
M001: L #location
T #SET_QTY
L #SET_BATCH_NO
T #batch_acc
M002: NOP 0
L #SET_QTY
T DBD [AR1,P#0.0]
2. Read data again
QTY_DB_NO is array of 1000 real address. #SELECT_BATCH is integer address it will enter number like 1 to 1000. E.g if operator enter 1 then value will be sread from first location of QTY_DB [ DBxx. DBD4] and transfer to #SELECTED_QTY
OPN #QTY_DB_NO
L #SELECT_BATCH
T #SELECTED_BATCH
L #SELECTED_BATCH
L 4
*I
SLW 3
LAR1
L DBD [AR1,P#0.0]
T #SELECTED_QTY
Waiting for reply.
Regards,
Yogendra
S7-1200 SCL Programming Help
-
- Posts: 104
- Joined: Sat Jun 13, 2009 12:25 pm
- Location: Europe
Re: S7-1200 SCL Programming Help
Hi,
You can find below two sample:
First sample : Direct adress => The Data block is "DB_Array_Real" (array of [1..1000] of real
Second sample : Indirect adress => The Data block is given by number. This data block must be "non optimiezd Access"
Best regard
You can find below two sample:
First sample : Direct adress => The Data block is "DB_Array_Real" (array of [1..1000] of real
Code: Select all
FUNCTION_BLOCK "Read_Write_Direct_Adress"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
Write_Cmd : Bool;
Value_To_Write : Real;
WriteValueNumber : Int;
Read_Cmd : Bool;
ReadValueNumber : Int;
END_VAR
VAR_OUTPUT
Readed_Value : Real;
END_VAR
BEGIN
IF #Write_Cmd AND #WriteValueNumber >0 AND #WriteValueNumber <1001 THEN
"DB_Array_Real".Real_Value[#WriteValueNumber] := #Value_To_Write;
END_IF;
IF #Read_Cmd AND #ReadValueNumber > 0 AND #ReadValueNumber < 1001 THEN
#Readed_Value := "DB_Array_Real".Real_Value[#ReadValueNumber];
END_IF;
END_FUNCTION_BLOCK
Code: Select all
FUNCTION_BLOCK "Read_Write_Indirect_Adress"
{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
VAR_INPUT
Write_Cmd : Bool;
Value_To_Write : Real;
WriteValueNumber : Int;
DBNumber : Int;
Read_Cmd : Bool;
ReadValueNumber : Int;
END_VAR
VAR_OUTPUT
Readed_Value : Real;
END_VAR
BEGIN
IF #Write_Cmd AND #WriteValueNumber >0 AND #WriteValueNumber <1001 THEN
POKE(area := 16#84, dbNumber := #DBNumber, byteOffset := ((#WriteValueNumber-1)*4),value := REAL_TO_DWORD(IN:=#Value_To_Write));
END_IF;
IF #Read_Cmd AND #ReadValueNumber > 0 AND #ReadValueNumber < 1001 THEN
#Readed_Value := DWORD_TO_REAL(IN := PEEK_DWORD(area := 16#84, dbNumber := #DBNumber, byteOffset := ((#ReadValueNumber - 1) * 4)));
END_IF;
END_FUNCTION_BLOCK
-
- Posts: 15
- Joined: Fri May 18, 2012 8:54 am
Re: S7-1200 SCL Programming Help
Sorry for late reply. I was on site and Thank you very much for your help. This logic solved my purpose.dehell wrote:Hi,
You can find below two sample:
First sample : Direct adress => The Data block is "DB_Array_Real" (array of [1..1000] of real
.....
Best regard
Regards,
Yogendra