Parameters of POINTER type in Siemens TIA Portal

Publisher:DreamySerenityLatest update time:2024-08-06 Source: elecfansKeywords:Siemens Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

illustrate

A POINTER type parameter is a pointer that can point to a specific variable. It occupies 6 bytes (48 bits) in memory and may contain the following variable information:


Data block number or 0 (if no data is stored in the data block)

Memory area in the CPU

Variable address

The following figure shows the structure of the POINTER parameter type:

37f92652-1ec5-11ee-962d-dac502259ad0.png

Pointer Types

According to the relevant information, the following four types of pointers can be declared using the POINTER parameter type:

Internal area pointer:

The internal area pointer stores the address information of the variable.

Cross-region pointers:

Cross-area pointers store the storage area and address information of variables.

DB pointer:

The DB pointer can be used to point to a data block variable. In addition to the variable's storage area and address information, the DB pointer also stores the data block number.

Zero pointer:

Using a zero pointer, you can indicate a missing value. A missing value can mean that the value does not exist, or that the value is unknown. A zero value indicates that a value is missing, but it is still a value.

The following table shows the format for declaring various pointer types:

P#ByteRepresentation Format Input value examples illustrate
symbol P#Byte.Bit "MyTag" Internal area pointer
P#OperandAreaByte.Bit "MyTag" Cross-region pointers
P#Data_block.Data_operand "MyDB"."MyTag" DB pointer
P# zero value - Zero Pointer
absolute P#Byte.Bit P#20.0 Internal area pointer
P#OperandAreaByte.Bit P#M20.0 Cross-region pointers
P#Data_block.Data_operand P#DB10.DBX20.0 DB pointer
P# zero value P#0.0, ZERO Zero Pointer


Prefix P#

In the block call, the actual value is entered without the P# prefix as a formal parameter of the POINTER data type. It is then automatically converted to the POINTER format.

When using the prefix P# in the STL programming language, the following precautions must be observed:

Block Type "Optimized" access mode "Standard" access mode
Function (FC) In program code, variables with the prefix P# cannot be used. In the program code, you can use the following variables with the prefix P#:
Structure variables that declare variables in the InOut area of ​​the block interface.
Variables that declare elementary data types cannot be declared with the prefix P#.
Function Block (FB) In program code, variables with the prefix P# cannot be used. In the program code, you can use the following variables with the prefix P#:
Variables declared in the Static, Input and Output areas of the block interface.
Variables of PLC data type (UDT) declared in the InOut area of ​​the block interface.

Storage Area

The following table lists the hexadecimal codes for the memory areas of the POINTER parameter type:

Hexadecimal code Storage Area illustrate
B#16#801) P Peripherals of CPU S7-300/400
16#1 P Peripheral inputs of CPU S7-1500
16#2 P Peripheral outputs of CPU S7-1500
B#16#81 I Input storage area
B#16#82 Q Output storage area
B#16#83 M Memory area for bit storage
B#16#84 DBX Data Block
B#16#85 DIX Instance data block
B#16#86 L Local Data
B#16#87 V Previous local data
1) These data types are only available for POINTER pointers on CPU S7-300/400.
The complete syntax for input constants is

Overview

Short form Long form
B# BYTE#
W# WORD#
DW# DWORD#
D# DATE#
T# TIME#
TOD# TIME_OF_DAY#
S5T# S5TIME#
DT# DATE_AND_TIME#
P# POINTER#

Indirect addressing using pointers

illustrate

For indirect addressing, a specific data format is required, which should contain the address or also the range and data type of the operand. This data format is called a pointer. The following types of pointers can be used:

Reference (S7-1500)

VARIANT (S7-1200/1500)

POINTER (S7-1500)

ANY (S7-1500, only for blocks with standard access)

For more information about pointer data types, refer to See Also.

Note
In SCL, POINTER can only be used with certain restrictions. It can only be forwarded to the called block.

Example

The following example illustrates indirect addressing using a region pointer.

Addressing in STL illustrate
LP#10.0 // Load pointer in accumulator 1 (P#10.0)
TMD20 // Pass the pointer to operand MD20
L MW [MD20] // Load MW10 in accumulator 1
.... // Any program
L MD [MD20] // Load MD10 in accumulator 1
.... // Any program
= M [MD20] // If RLO=1, set memory bit M10.0

The pointer P#10.0 is passed to operand MD20. If operand MD20 is enclosed in square brackets during programming, it will be replaced by the address contained in the pointer during runtime.

Indirect addressing via pointers

illustrate

For indirect addressing, a specific data format is required, which should contain the address or also the range and data type of the operand. This data format is called a pointer. The following are pointer types:

POINTER (S7-300/400)

ANY (S7-300/400)

VARIANT (S7-1200/1500)

For more information about pointer data types, see the See Also section.

Note
In SCL, the use of pointer data types is restricted. The only option is to forward them to the called block.

Example

The following example illustrates indirect addressing using intra-region pointers:

Addressing in STL illustrate
LP#10.0 // Load the pointer in accumulator 1 (P#10.0)
TMD20 // Pass the pointer to operand MD20
L MW [MD20] // Load MW10 in accumulator 1
.... // Any program
L MD [MD20] // Load MD10 in accumulator 1
.... // Any program
= M [MD20] // If RLO=1, set memory bit M10.0

The pointer P#10.0 is passed to operand MD20. If operand MD20 is enclosed in square brackets during programming, it will be replaced by the address contained in the pointer during runtime.

LAR1: Load into AR1 with double word or area pointer

illustrate

With the "Load AR1 with double word or area pointer" instruction, you load the contents of a double word or an area-internal pointer or cross-area pointer into address register 1 (AR1). The contents of the double word must therefore match the format of the area pointer.

Pointers and double words can be addressed in one of the following memory areas:

Bit memory (M)

Temporary local data (L)

Data block (DB, DI)

The CPU will execute this instruction regardless of the result of the logic operation and the status bits. This instruction does not affect either the result of the logic operation or the status bits.

This instruction does not change the contents of the accumulator.

parameter

The following table shows the parameters for the "Load AR1 with double word or area pointer" instruction:

parameter statement Data Types Storage Area illustrate

Input DWORD、POINTER D.M.L. The operand whose contents were loaded.


Example

The following example illustrates how this directive works:

STL illustrate
LAR1 P#10.0 // Load the content of the area internal pointer P#10.0 into address register 1.
L MW [AR1,P#4.0] // Load MW14 into accumulator 1.
L "Tag_Value" // Move the contents of accumulator 1 to accumulator 2.
// Load the contents of operand "Tag_Value" into accumulator 1.
>I // Compare the value of accumulator 2 to see if it is greater than the value of accumulator 1.
AI [AR1,P#2.1] // Check whether the signal state of bit I12.1 is "1" and AND it with the current RLO.
= "Tag_Output" // If the condition is met (RLO = "1"), set operand "Tag_Output" to "1".
LAR1 MD20 // Load address register 1 with the contents of MD20 (MD20 = P#30.0)
AI [AR1,P#2.1] // Check whether the signal state of bit I32.1 is "1" and AND it with the current RLO.


Keywords:Siemens Reference address:Parameters of POINTER type in Siemens TIA Portal

Previous article:How structured PLC variables work
Next article:An article analyzing the Modbus RTU communication of Siemens S7-1200

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号