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:
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.
|
Previous article:How structured PLC variables work
Next article:An article analyzing the Modbus RTU communication of Siemens S7-1200
- Popular Resources
- Popular amplifiers
- Red Hat announces definitive agreement to acquire Neural Magic
- 5G network speed is faster than 4G, but the perception is poor! Wu Hequan: 6G standard formulation should focus on user needs
- SEMI report: Global silicon wafer shipments increased by 6% in the third quarter of 2024
- OpenAI calls for a "North American Artificial Intelligence Alliance" to compete with China
- OpenAI is rumored to be launching a new intelligent body that can automatically perform tasks for users
- Arm: Focusing on efficient computing platforms, we work together to build a sustainable future
- AMD to cut 4% of its workforce to gain a stronger position in artificial intelligence chips
- NEC receives new supercomputer orders: Intel CPU + AMD accelerator + Nvidia switch
- RW61X: Wi-Fi 6 tri-band device in a secure i.MX RT MCU
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Instrumentation Amplifiers: CMRR, You Stole My Precision
- Refuse to get something for free. The author of the open source project deleted the library and ran away. Thousands of applications output garbled characters endlessly.
- DSP Flash API Steps
- The physical meaning of FFT results
- MSP430 - Timer_A timer interrupt program
- Buck switching power supply MOS tube gate has pwm signal, but cannot conduct normally
- Motor Driver
- Sharing on the serious problem of LM2611 output voltage heating
- How much do you know about the "ADI Inside" behind these popular healthcare products?
- About ARM's interrupt service routine