Siemens step 7 write to string
The result must be cast to ushort to get the correct 16-bit format in C. Example: This reads the variable DB1.DBW0. Reads 64 characters from register 32 (of DB6). public object Read(string variable) public ErrorCode Write(string variable, object value) variable: specify the variable to read by using strings like DB1.DBW20, T45, C21, DB1.DBD400, etc. Parameters: read_db_nr: Source DB number (DInt) read_db_offset: Offset in DB in bytes (DInt) fill_char: „empty” („00”) bytes replaced with this Char (Char) textOut: output (String) \\ The PLC can stop due to bad parameterization!īlock tested with TIA 15.1. Attention! The program does not contain internal DB check (is there DB or DB length). The string is assembled from the Modbus registers. The purpose of the program is to read the text (string) from the Modbus communication. Parameters: text: input (string) write_db_nr: Target DB number (DInt) write_db_offset: Offset in DB in bytes (DInt) fill_char : fill additional text area with this char (char) The string is written to the target DB character by character. The purpose of the program is to prepare the text (string) for Modbus communication. PLC data type ( UDT), Anonymous structures ( STRUCT), ARRAY, Parameter types ( TIMER, COUNTER.), System data types ( IEC_TIMER, IEC_SCOUNTER.)Ĭonvert up to 16 bits to word and bytes (HI and LO)įor WORD to BYTE conversion use only the first eight bits and set the rest to (fix) 0. 1 byte - total length, 2nd byte - no of characters in the string. String format, the forst two bytes contains the information related to the string. You can also use the notation c#0 through C#999 for a positive three-decade decimal number. You can move the set of characters to string. For a BCD number, use the data type WORD or DWORD and enter only the digits 0 to 9 and 0 or F for the sign in the format in hex W#16#xxxx or W#16#xxxx_xxxx.
![siemens step 7 write to string siemens step 7 write to string](https://i.ytimg.com/vi/qQH6NiS6Ins/maxresdefault.jpg)
![siemens step 7 write to string siemens step 7 write to string](http://www.plcdev.com/files/plcdev/images/s7-lite-editor.png)
BCD numbers do not have their own data type. What is not included in the table: BCD numbers, BCD16 and BCD32. STRING → DB REGS DB REGS → STRING STRING → REAL/LINT DT → STRING 16 BOOL → WORD and BYTE WORD → 16 BOOL BYTE → 8 BOOLġ6 BOOL → WORD und BYTE BYTE → 8 BOOL DT → WORD/BYTEġ6 BOOL → WORD and BYTE WORD → 16 BOOL STRING → DB REGS DB REGS → STRING DT → WORD/BYTE WORD → REAL REAL → WORD