Data Types and addressing methods of memory in PLC
Source: Internet
Author: User
I. Storage Methods of data in memory
1. Data Format and requirements
A> data format: the Data Length and representation. B> requirement: the S7-200 has certain requirements on the data format, the format between the command and the data is consistent in order to work normally.
2. A binary number is used to represent the switch quantity.
A> one-bit binary number: one-bit binary number has two different values: 0 (off) and 1 (on), which correspond to the switch quantity (or number) respectively). B> data type of BIT data: boolean type. C> bit address: it consists of a memory identifier, a byte address, and a bit number, such as i3.4. D> address format of other CPU storage areas: the address format consists of the memory identifier and the starting byte number (usually take the root byte), such as v B 100, V W 100, and V D 100.
3. Multi-bit binary (8421 yards)
A> number and number system: number indicates the specific size of a volume. Different counting methods are supported, such as decimal (D), binary (B), hexadecimal (H), and octal. B> representation of binary numbers: 2 # is used in the S7-200 to represent binary constants, for example, "2 #10111010 ". C> size of the binary number: multiply the bitwise (x 2n-1) of the binary number (from right to left) by the corresponding bitwise ), sum the result to get the size. Example: 2 #10111010 = 1x27 + 0x26 + 1x25 + 1x24 + 1x23 + 0x22 + 1x21 + 0x20 = 186
4. hexadecimal number
A> introduction of hexadecimal numbers: A hexadecimal number is used to represent the number of binary data from right to left. This allows you to quickly and accurately read and write multiple binary data. B> representation of different hexadecimal numbers: (Table 3-2-1 represents different hexadecimal numbers) C> representation of hexadecimal numbers: 16 # is used in the S7-200 to represent the hexadecimal constant, for example, "2 #1010 1110 0111 0101 can be converted to 16 # aef7 ". D> hexadecimal number size: multiply the hexadecimal number (N digits from right to left) by the corresponding bitwise (× 16n-1 ), sum the result to get the size. Example: 16 # 2f = 2x161 + 15x160 = 47
5. Data Length: byte, word, and doubleword)
A> byte (B): the continuous 8-bit binary number starting from 0 is called a byte. B> word (W): two adjacent bytes constitute the length of a word. C> double-character (DW): the adjacent four bytes constitute the length of a double-character. D> storage features of long and double-character data: high storage is low in bytes, and its position is high in bytes.
6. Negative (signed number) Representation
A> negative expression: PLC generally uses a binary complement to represent the number of symbols, and its highest bit is the sign bit (0 -- positive number, 1 -- negative number ). B> relationship between positive and negative signs with equal absolute values: the positive complement is itself. C> value range of different data: (Table 3-2-2 Data digits and value range)
7. BCD code
A> BCD code meaning: BCD code represents a one-digit decimal number by a combination of four-digit binary numbers, which is abbreviated as binary coded decimal number. For example, the BCD code of decimal number 23 is 2 #0010 0011 or 16 #23, but its 8421 code is 2 #00010111. B> application of BCD code: BCD code is often used in input and output devices. For example, the dial switch inputs BCD code, and the number sent to the seven-segment display is also BCD code.
Ii. CPU storage Zone
1. input process image register (I)
A> input process image register (I): At the beginning of each scan cycle, the CPU samples physical Input Points and writes the sampled values to the input process image register. B> features of the input process image register (I): ① It can only be driven by external sources, and its use of normally open and normally closed contacts is not limited; ② the data in the input process image register can be accessed by bit, byte, word, or double word: bit: I [byte address]. [bit address] such as i0.1 byte, word, or dual-word: I [length] [Starting byte address] such as ib4
2. output process image register (q)
A> output process image register (q): at the end of each scan cycle, the CPU copies the values in the output process image register to the physical output point. B> features of the output process image register (q): ① The use of normally open and normally closed contacts is not limited; ② The output process image register can be accessed by bit, byte, word or dual word: bit: Q [byte address]. [bit address] such as q1.1 byte, word, or dual-word: Q [length] [Starting byte address] such as qb5
3. global variable storage zone (V)
A> variable storage zone (V): used for storage Program The intermediate results of logical operations can be controlled during execution, or other data related to processes or tasks can be stored. B> features of the variable storage area (V): ① The variable storage is globally valid and can be accessed by all Pou; ② data in the V Storage zone can be accessed by bit, byte, word, or double character: bit: V [byte address]. [bit address] such as v10.2 bytes, word, or dual-character: V [length] [Starting byte address] such as vw100
4. Local Memory (l)
A> the role of local memory (l): S7-200 has 64 bytes of local memory, 60 of which can be used as temporary memory or to pass parameters to subroutines. B> features of local memory (l): ① The S7--200 assigns 64 local memory to each Pou (program organization unit); ② local memory is only valid in the Program unit that creates it, each program cannot access the local variable memory of another program. ③ Local memory does not pass a value during parameter transfer and is not initialized during allocation. It may contain any value. Bit: L [byte address]. [bit address] such as l0.0 byte, word, or dual word: L [length] [Starting byte address] such as lb33
5. analog input (AI)
A> the role of analog input (AI): The S7-200 converts the input analog value (such as temperature or voltage) into a character-length (16-bit) number, and save it to an address with a long character in the (AI) area. B> Functions of analog input (AI): ① you can use the region identifier (AI), Data Length (w), and the starting address of the byte (which must be an even byte address such as aiw0, aiw2, aiw4) to access these values. ② The input value of analog quantity is read-only data. Format: aiw [Starting byte address] For example, aiw4
6. analog output (aq)
A> Functions of analog output (aq): The S7-200 converts a 4-character long (16-bit) digital value to a proportional current or voltage output of the corresponding size. B> features of analog output (aq): ① you can use the region identifier (aq), Data Length (w), and the starting address of the byte (such as aqw0, aqw2, aqw4) to change these values. ② The analog output value is to write data only. Format: aqw [Starting byte address] such as aqw4
7. Timer storage zone (t)
A> timer function: timer can be used for time accumulation, S7-200 CPU, there are 256 timer, the resolution (Time Base incremental) is divided into 1 ms, 10 ms and Ms. B> the timer has two variables: ① the current value is a 16-bit signed integer, which stores the accumulated time of the timer. ② Timer bit -- set or reset the timer bit based on the comparison result between the current value and the preset value. C> features of the timer storage area (t): ① you can use the timer address (t + timer number, such as t37 and t3) to access the current value and timer BIT data. The second-bit operation command is the access timer bit. If the word operation command is used, the current value of the access timer is used. Format: T [Timer number] For example, T24
8. Counter storage area (c)
A> counter function: the counter can be used to accumulate the number of times the input pulse level is from low to high. In the S7-200 CPU, there are 256 counters, divided into three types-increase count; decrease count; increase/decrease count. B> the counter has two variables: ① the current value is a 16-bit signed integer that stores the cumulative value. ② Counter bit -- set or reset the counter bit based on the comparison result between the current value and the preset value. C> features of the counter storage area (c): ① you can use the counter address (C + counter number) to access the current value and counter BIT data of the counter; ② The bit operation command is the access counter bit. If the word operation command is used, it is the current value of the access counter. Format: C [counter number] such as C24
9. High-speed counter (HC)
A> high speed counter (HC) function: used for high speed event count; S7-200 cpu222 and above provides 6 High Speed counters (hc0 ~ Hc5. B> features of the high-speed counter (HC): ① It is independent of the CPU scanning cycle; ② the current Count value of the high-speed counter (32-bit signed integer) is read-only data, it can only be used as double-character (32-bit) Addressing. ③ it can be used to access values in High-Speed Counters by specifying the memory type (HC) and counter number (such as hc0) Addressing. format: HC [High-speed counter number] such as HC1
10. accumulators (AC)
A> The Role Of The accumulators (AC): The accumulators are read and write devices that can be used as memory. For example, you can use it to pass parameters to the subroutine, return parameters from the subroutine, and store intermediate results of calculation. S7--200 provides 4 32-bit accumulators (ac0, AC1, ac2 and Ac3 ). B> Features of The accumulators (AC): ① values in the accumulators can be accessed in byte, word, or double-Word format; ② The length of the accessed data depends on the instruction used to access the accumulators. Format: AC [accumulators] such as ac0
11. Special Storage (SM)
A> special memory (SM): Sm bit provides a means to transmit information between CPU and user programs. You can use these bits to select and control some special features of the S7-200 CPU. B> special memory (SM) features: it can be accessed by bit, byte, word or double word:
Bit: Sm [byte address]. [bit address] such as sm0.1 byte, word, or dual word: Sm [length] [Starting byte address] such as smb86
12. Bit storage zone (m)
A> role of bit storage (m): The bit storage zone can be used as the control relay to store intermediate operation status and control information. B> features of bit storage (m): Bit storage can be accessed by bit, byte, word or double word: bit: M [byte address]. [bits] such as m26.7 bytes, word, or dual-character: M [length] [Starting byte address] such as md20
13. Series control relay memory (s)
A> downstream relays (SCR): SCR provides logical segments of control programs for organizing the sequential operation of devices. B> series control relay memory (s) features: ① It can be used as a series control programming element in combination with sequence control relay commands; ② it can be used as an auxiliary relay, s-bit can be accessed by bit, byte, word, or dual-word. Bit: s [byte address]. [bit address] such as s3.1 byte, word, or dual word: s [length] [Starting byte address] such as sb4
14. Real Number Format
A> real number and its application: the real number (floating point number) can be expressed as 1. m × 2e (in the formula, m -- tail number, e -- Index) is represented by 32-Bit Single-precision numbers. The highest bit is the symbol bit, which is accessed according to the double-character length. With floating point numbers, the S7-200 can be expressed in the range of ± 1. 175495X10-38 ~ Any number in ± 3. 402823 × 10 + 38. B> calculation precision of the real number: For the S7--200, the floating point number is precise to the sixth digit after the decimal point.
15. string format
A string refers to a series of characters, each of which is stored in bytes. The first byte of a string defines the length of the string, that is, the number of characters. The length of a string can be 0 to 254 characters, plus the length bytes. the maximum length of a string is 255 bytes. The maximum length of a String constant is 126 bytes.
16. constant expression and Range
Constant values can be used in many instructions of the S7--200. A constant value can be a byte, word, or double character. The S7--200 stores constants in the form of binary numbers, which can also be expressed in decimal, hexadecimal, ASCII, or real (floating point number. (Table 3-2-3 constant Notation)
17. CPU memory range and features
A> S7-200 CPU memory range: (Table 3-2-4 S7-200 CPU memory range and characteristics) B> S7-200 operand range: (Table 3-2-5 S7-200 CPU operand range)
Iii. Direct addressing and indirect addressing
1. Addressing Concept
In a PLC, addresses are the basis for data access. The process of accessing data through addresses is called addressing ". Almost all commands and functions are related to various forms of addressing.
2. Direct addressing
Direct addressing is an addressing method that specifies the region, length, and location of the memory. It is used in programming of a General Digital Volume Control System. For example, vw100 indicates two words including vb100 and vb101.
3. Indirect addressing of S7-200 storage area with pointer
A> indirect addressing: ① the concept of indirect addressing refers to the use of pointers to access data in the storage area. ② Pointer function and its features: the pointer stores the addresses of other storage areas in the form of dual words, and the pointer can also be passed to the subroutine as a parameter. Only V memory, l memory, or accumulators (AC1, ac2, and Ac3) can be used as pointers. The S7-200 allows pointers to the following storage areas: I, Q, V, M, S, AI, AQ, SMT (current value only) and C (current value only ); however, you cannot access a single bit, or access the HC or l storage zone. B> establish an indirect addressing pointer: to create a pointer, you must move the memory address to be indirectly addressable to the pointer in the form of dual words; the specific method is to create a pointer by adding the "&" symbol and the address of the bucket to be accessed. ("&" Indicates that the instruction operand is the address of the storage area, rather than the content .) C> use a pointer to access data: When the operand in the instruction is a pointer, add the "*" sign before the operand. D> modify the pointer: Because the pointer is a 32-bit data, you must use dual-word commands to change the value of the pointer. Simple mathematical operations, such as addition commands or adding commands, it can be used to change the pointer value. E> application example -- [Example 3-1]: The data in the table used for Nonlinear Correction is stored in 100 words starting with vw0, And the offset of the table (the number of words in the table, in vd200, on the rising edge of i0.0, the data value in the table relative to the offset is transmitted to vw210 using indirect addressing. [Note]: use different commands based on the length of the accessed data: when accessing bytes, use the Add command to add 1 to the pointer value; when accessing the current value of a word, counter, or timer, add 2 to the pointer value by using addition or adding instructions. when accessing a double word, add 4 to the pointer value by using addition or adding instructions.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.