2/1/2013 8:47 AM | |
Joined: 4/22/2010 Last visit: 5/3/2024 Posts: 5697 Rating:
|
Hello, You adress with the size (in bits)of the variable, bit is dbx, byte dbb, word dbw, doubleword dbd. In your dB you enter the datatype of the byte,word or D word. Attached the elementary datatypes and their sizes. Regards, Marcjan Attachmentelementary datatypes.pdf (12003 Downloads) |
Last edited by: Marcjan at: 2/1/2013 8:49 AMProblem solved? |
|
This contribution was helpful to
2 thankful Users |
2/1/2013 12:23 PM | |
Joined: 1/28/2009 Last visit: 9/2/2024 Posts: 6846 Rating:
|
Hello , Just to add some points mentioned above by MarcJan: As the accumulators (internal registers) of S7 controllers are 32-bit,Handling elementary data type(such as Byte, WORD,DWORD,...) can be easily done by syntax already mentioned.This is what we know as absolute addressing as it seems a bit complex.Alternative would be using symbolic addressing to access cells in a DB and it is really much easier than absolute addressing: "Name of DB in symbol table". "Name of cell" This is a sample I have prepared for elementray data types(attachment) and in editor you can switch to sumbolic mode by"CTRL+Q". [code]//Boolean SET = DB1.DBX 0.0 //BYTE L B#16#FF T DB1.DBB 1 //WORD L W#16#FFFF T DB1.DBW 2 //DINT L L#1 T DB1.DBD 4 //real L 1.000000e+001 T DB1.DBD 8 //DWORD L DW#16#FFFFFFFF T DB1.DBD 12[/code] For a complex data types such as "Date and time", string and array,you should know their internal data structure to manipulate the content.For those case, if a function needs a complec data type as a parameter (in/out), still symolic adressing works as illustrated below. Manipulating complex data type such as "STRING", can be done by extra information on its structure. [code]//Date and Time CALL "READ_CLK" RET_VAL:=#test CDT :="TEST".hd7 //Struct--> first byte(Max length) and 2nd byte //(current length) L DB1.DBB 24 T MB 30 L DB1.DBB 25 T MB 31 L "TEST".hd8[1] L 'h' ==I = Q 0.0 // array L "TEST".hd9[0] T "TEST".hd9[1][/code] Also there is option of using indirect adressing to access cells in a DB,See here for more information: http://support.automation.siemens.com/WW/view/en/24519683 Best regards Hamid Hosseini |
This contribution was helpful to
4 thankful Users |
3/31/2018 5:46 PM | |
Posts: 5 Rating:
|
Hello friend , look this docuemnt AttachmentSCL-cheat-sheet.pdf (3933 Downloads) |
This contribution was helpful to
3 thankful Users |
Follow us on