|Try our online PLC Simulator- FREE. Click here now to try it.|
Learn quickly with our PLC Training DVD Series: on sale
Click here now for details!
Getting and Moving Data
Let's now start working with some data. This is what can be considered to be getting into the "advanced" functions of a plc. This is also the point where we'll see some marked differences between many of the manufacturers functionality and implementation. On the lines that follow we'll explore two of the most popular ways to get and manipulate data.
Why do we want to get or acquire data? The answer is simple. Let's say that we are using one of the manufacturers optional modules. Perhaps it's an A/D module. This module acquires Analog signals from the outside world (a varying voltage or current) and converts the signal to something the plc can understand (a digital signal i.e. 1's and 0's). Manufacturers automatically store this data into memory locations for us. However, we have to get the data out of there and move it some place else otherwise the next analog sample will replace the one we just took. In other words, move it or lose it! Something else we might want to do is store a constant (i.e. fancy word for a number), get some binary data off the input terminals ( maybe a thumbwheel switch is connected there, for example), do some math and store the result in a different location, etc...
As was stated before there are typically 2 common instruction "sets" to accomplish this. Some manufacturers use a single instruction to do the entire operation while others use two separate instructions. The two are used together to accomplish the final result. Let's now look briefly at each instruction.
The single instruction is commonly called MOV (move). Some vendors also include a MOVN (move not). It has the same function of MOV but it transfers the data in inverted form. (i.e. if the bit was a 1, a 0 is stored/moved or if the bit was a 0, a 1 is stored/moved). The MOV typically looks like that shown below.
MOV instruction symbol
The paired instruction typically is called LDA (LoaD Accumulator) and STA (STore Accumulator). The accumulator is simply a register inside the CPU where the plc stores data temporarily while its working. The LDA instruction typically looks like that shown below, while the STA instruction looks like that shown below to the right.
Regardless of whether we use the one symbol or two symbol instruction set (we have no choice as it depends on whose plc we use) they work the same way.
Let's see the single instruction first. The MOV instruction needs to know 2 things from us.
The ladder diagram to do this would look similar to that shown above.
Notice that we are also using a "difu" instruction here. The reason is simply because if we didn't the data would be moved during each and every scan. Sometimes this is a good thing (for example if we are acquiring data from an A/D module) but other times it's not (for example an external display would be unreadable because the data changes too much).
ladder shows that each time real world input 0000 becomes true, difu
will become true for only one scan. At this time LoaD 1000 will be true
and the plc will move the data from data memory 200 and put it into
data memory 201.
The two symbol instruction works in the same method but looks different. To use them we must also supply two things, one for each instruction:
The ladder diagram to do this would look similar to that shown above. Here again we notice that we are using a one-shot so that the move only occurs once for each time input 0000 becomes true. In this ladder we are moving the constant 2222 into data memory 200. The "#" is used by some manufactures to symbolize a decimal number. If we just used 2222 this plc would think it meant address 2222. PLCs are all the same... but they are all different.
We can think of this instruction as the gateway to advanced instructions. I'm sure you'll find it useful and invaluable as we'll see in future. Many advanced functions are impossible without this instruction!Learn quickly with our PLC Training DVD Series: on sale
Click here now for details!