• No se han encontrado resultados

Esquema 5. Ejes temáticos de la ganadería para el análisis de las causas que afectan la adopción de tecnologías críticas

3.2.2.5. EJE REGISTROS

Definitions: Bit

A bit is the smallest unit of information on a machine. This term was first used in 1946 by John Tukey, a leading statistician and adviser to five presidents. A single bit can hold only one of two values: 0 or 1. More meaningful information is obtained by combining consecutive bits into larger units. For example, a byte is composed of 8 consecutive bits.

The Nibble

A nibble is a collection of bits on a 4-bit boundary. It wouldn't be a particularly interesting data structure except for two items: BCD (binary coded decimal) numbers and hexadecimal (base 16) numbers. It takes four bits to represent a single BCD or hexadecimal digit.

With a nibble, we can represent up to 16 distinct values. In the case of hexadecimal numbers, the values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F are represented with four bits. BCD uses ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) and requires four bits. In fact, any sixteen distinct values can be represented with a nibble, but hexadecimal and BCD digits are the primary items we can represent with a single nibble.

b3 b2 b1 b0

The Byte

The byte is a collection of 8 bits The Word

The word is a group of 16 bits. We will number the bits in a word starting from bit zero (b0) through fifteen (b15) as follows:

b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0

Like the byte, bit 0 is the LSB and bit 15 is the MSB. When referencing the other bits in a word use their bit position number.

Notice that a word contains exactly two bytes. Bits b0 through b7 form the low order byte, bits 8 through 15 form the high order byte. Naturally, a word may be further broken down into four nibbles. Nibble zero is the low order nibble in the word and nibble three is the high order nibble of the word. The other two nibbles are "nibble one" or "nibble two".

With 16 bits, you can represent 2^16 (65,536) different values. These could be the unsigned numeric values in the range of 0 => 65,535, signed numeric values in the range of -32,768 => +32,767 or any other data type with no more than 65,536 values. The three major uses for words are

1. 16-bit integer data values 2. 16-bit memory addresses

3. any number system requiring 16 bits or less The Double Word

A double word is exactly what its name implies, two words. Therefore, a double word quantity is 32 bits. Naturally, this double word can be divided into a high order word and a low order word, four bytes, or eight nibbles.

Double words can represent all kinds of different data. It may be 1. an unsigned double word in the range of 0 => 4,294,967,295, 2. a signed double word in the range -2,147,483,648 =>

2,147,483,647,

3. a 32-bit floating point value

4. any data that requires 32 bits or less

- can deal with LG MK PLC data registers as words or as bits - as we know the LG plc data memory is divided into the devices:

p ,m ,k ,l ,f ,t ,c ,s ,d. we can use(p , m, k , l) as bits or as word ,that’s mean that there are a word named m10 and there are a bit named m10 as appear in the figure

The word Mxx

Bit Mxx0 Bit Mxx1

I can deal with s, contacts of timers T, contacts of counters C and some of F device as bits.

I can deal with d and coil of timers, coil of timers and some of F devices as words only

Device D

There are 5000 word of d device from d0 to d4500 are read/write data registers. From d4501 to d5000 are special registers that user can read them only.

To study PLC you must know the memory mapping of the data memory of this PLC, the PLC data memory is divided into several parts , every part have a name & special specifications , these parts called devices .

ƒ D Æ DATA REGISTER

D

device refer to data register (i.e. the store which you can store data in) can be used with timers counters

NOTE:

No. of data register limited to PLC type for example there are 5000 data registers at master k 120s

ƒ M Æ AUXILIARY RELAY (MARKERS)

This device is not real input and not real outputs, you can only write in and read these bits using software instructions it is usually used to internal buffer bit calculation .

EXAMLPE:

M0

Æ internal imagine input or output in plc. NOTE:

no. of points (Mxx) limited to plc software point no.(s) for example for master k120s from M000 to M191F (191*16= 3056 marker)

ƒ P Æ INPUT & OUTPUT IMAGE

This device for real input and real outputs only, you can change this device status (write in these bits) using hardware, if you put 24v on p0 input, the bit of p0 get high (on)

EXAMLPE:

P0

- Æ input for point labeled 0 on plc.

P40

Æ output for point labeled 40 on plc. NOTE:

Let's now look at using some basic math functions on our data. Many times in our applications we must execute some type of mathematical formula on our data. It's a rare occurrence when our data is actually exactly what we needed.

As an example, let's say we are manufacturing widgets. We don't want to display the total number we've made today, but rather we want to display how many more we need to make today to meet our quota. Let's say our quota for today is 1000 pieces. We'll say X is our current production. Therefore, we can figure that 1000-

X=widgets left to make. To implement this formula we obviously need some math capability.

In general, MK PLCs almost always include these math functions:

• Addition- The capability to add one piece of data to another. It is

commonly called ADD.

• Subtraction- The capability to subtract one piece of data from

another. It is commonly called SUB.

• Multiplication- The capability to multiply one piece of data by

another. It is commonly called MUL.

• Division- The capability to divide one piece of data from another.

It is commonly called DIV.

LG MK PLC’s math instructions ask us for a few key pieces of information.

• Source A- This is the address of the first piece of data we will

use in our formula. In other words it's the location in memory of where the first "number" is that we use in the formula.

• Source B- This is the address of the second piece of data we will

use in our formula. In other words it's the location in memory of where the second "number" is that we use in the formula. -NOTE: typically we can only work with 2 pieces of data at a time. In other words we can't work directly with a formula like 1+2+3. We would have to break it up into pieces. Like 1+2=X then X+3= our result.

• Destination- This is the address where the result of our formula

will be put. For example, if 1+2=3, (I hope it still does!), the 3 would automatically be put into this destination memory location.

ADD symbol

The instructions above typically have a symbol that looks like that shown above. Of course, the word ADD would be replaced by SUB, MUL, DIV, etc. In this symbol, the source A is D30, the source B is constant (100) and the destination is d40.

Therefore, the formula is simply whatever value is in D30 + 1000 the result is automatically stored into D40.

Shown above is how to use math functions on a ladder diagram. Please note that once again we are using a one-shot instruction (D instruction). As we've seen before, this is because if we didn't use it we would execute the formula on every scan. Odds are good that we'd only want to execute the function one time when input P3 becomes true. If we had previously put the number 100 into D100 and 200 into D102, the number 300 would be stored in D110.(i.e. 100+200=300, right??)

What would happen if we had a result that was greater than the value that could be stored in a memory location?

Typically the memory locations are 16-bit locations. In plain words this means that if the number is greater than 65535 (2^16=65536) it is too big to fit. Then we get what's called an overflow. Typically the plc turns on an internal relay that tells us an overflow has happened. The result value will be more than 16 bit number this the plc will deal with this data as if it is 32 bit data, the low 16 bit will be stored into the destination address and the higher 16 bit will be stored in the data register after the destination data register for example if the destination is d110 then the lower 16 bit (word) will be stored in d110, the upper 16 bit (word) will be stored in d111,

Hint:

If the math operation result is less than 65536 then the result will be stored in the destination (d110 for example) and 0 will be stored in the data register after the destination (d111)

Math operations

1- Addition

The add instruction have the form Add oper1 oper2 oper3

As oper1: constant or word device oper2: constant or word device oper3: word device

This expression mean oper3 = oper1+oper2 Example

IF P0 pressed put in p5 the data in d30 plus 100 (P5=d30+100) If d30 has 200, then p5 equal 300.

2- Subtractions

The Subtractions have the form Sub oper1 oper2 oper3

As oper1: constant or word device oper2: constant or word device oper3: word device

This expression mean oper3 = oper1-oper2

3- multiplication

The mul instruction has the form mul oper1 oper2 oper3

As oper1: constant or word device oper2: constant or word device oper3: word device