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.
- Source (xxxx)- This is where the data we want to move is located. We could write a constant here (2222 for example). This would mean our source data is the number 2222. We could also write a location or address of where the data we want to move is located. If we wrote DM100 this would move the data that is located in data memory 100.
- Destination (yyyy)- This is the location where the data will be moved to. We write an address here. For example if we write DM201 here the data would be moved into data memory 201. We could also write 0500 here. This would mean that the data would be moved to the physical outputs. 0500 would have the least significant bit, 0501 would have the next bit... 0515 would have the most significant bit. This would be useful if we had a binary display connected to the outputs and we wanted to display the value inside a counter for the machine operator at all times (for example).
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).
The 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.
Simple but effective. If, instead of DM200, we had written 2222 in the symbol we would have moved (written) the number (constant) 2222 into DM201.
Simple but effective. If, instead of DM200, we had written 2222 in the symbol we would have moved (written) the number (constant) 2222 into DM201.
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:
- LDA- this instruction is similar to the source of a MOV instruction. This is where the data we want to move is located. We could write a constant here (2222 for example). This would mean our source data is the number 2222. We could also write a location or address of where the data we want to move is located. If we wrote DM100 this would move the data that is located in data memory 100.
- STA- this instruction is similar to the destination of a MOV instruction. We write an address here. For example if we write DM201 here the data would be moved into data memory 201. We could also write 0500 here. This would mean that the data would be moved to the physical outputs. 0500 would have the least significant bit, 0501 would have the next bit... 0515 would have the most significant bit. This would be useful if we had a binary display connected to the outputs and we wanted to display the value inside a counter for the machine operator at all times (for example).
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.
No comments:
Post a Comment