plcforum.uz.ua

International PLC Forum
It is currently Wed Apr 25, 2018 8:09 am

All times are UTC + 3 hours


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Feb 12, 2018 7:20 am 

Joined: Fri May 18, 2012 11:54 am
Posts: 12
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


Top
 Profile  
 
PostPosted: Mon Feb 12, 2018 12:56 pm 

Joined: Sat Jun 13, 2009 3:25 pm
Posts: 104
Location: Europe
Hi,
You can find below two sample:
First sample : Direct adress => The Data block is "DB_Array_Real" (array of [1..1000] of real
Code:
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



Second sample : Indirect adress => The Data block is given by number. This data block must be "non optimiezd Access"

Code:
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


Best regard


Top
 Profile  
 
PostPosted: Tue Feb 20, 2018 4:26 pm 

Joined: Fri May 18, 2012 11:54 am
Posts: 12
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

Sorry for late reply. I was on site and Thank you very much for your help. This logic solved my purpose.


Regards,

Yogendra


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by International PLCforum® Forum Software © PLCforum
Mobile version