
Lesson 14
Controlling a VFD from a PLC: Control Word, Status Word and Faults
From contactor to drive, the drive's own state, the control word as bits in a number, faults that latch and clear on an edge, and the link that drops.
From Usta's field manual in Meridian Works, a story-driven PLC course: chapter 14, “Drives”. A motor you talk to with words, not wires: the control word, the status word and the link that drops.
From contactor to drive
A contactor knows two things: pulled in or dropped out. The motor either runs at full speed or stops. A frequency drive (frequency converter, VFD) changes the frequency of the voltage going to the motor. So the motor turns at the wanted speed, speeds up slowly and stops slowly.
Drives used to be wired too. One output said "run", and an analog output gave the speed. Today most drives are connected to the plant network. The program talks to the drive with words:
- From the program to the drive: the control word and the speed reference.
- From the drive to the program: the status word and the actual speed.
These four words travel over the network on every scan. There are no wires, but the logic is the same: one side gives a command, the other answers.
In this chapter you learn four things. How to change a single bit inside a word. How to read the drive's own state. How to clear the drive's fault. And what not to trust when the link drops.
You give a contactor an order. You talk to a drive. In a conversation you also have to listen to the other side.
The control word: bits in a number
The control word is a number, but nobody reads it as a number. Each bit is a separate command. On the drive in this simulator the bits are:
| Bit | Meaning | Mask |
|---|---|---|
| 0 | Run | 16#0001 |
| 1 | Reverse | 16#0002 |
| 2 | Fault reset | 16#0004 |
Real drives have more bits, and their positions vary by manufacturer. The right position is always written in the drive's own manual.
The mistake everybody makes once. Writing 1 to the word to start the drive and 0 to stop it. This sets bit 0 correctly. But it clears every other bit too. If reverse was selected, the drive starts turning forward.
The right way: masking. To set a bit you OR the word with itself and a mask:
Drive_CW := Drive_CW OR 16#0001
OR makes the bit that is 1 in the mask 1. The other bits stay as they are.
To clear a bit you AND the word with the inverse mask. In the inverse mask only the bit to be cleared is 0:
Drive_CW := Drive_CW AND 16#FFFE
AND makes the bit that is 0 in the mask 0. The other bits stay as they are.
In Siemens these boxes are called AND, OR and INVERT. In Rockwell, AND, OR and NOT. On both the work is the same.
Do not touch a bit that is not yours. A rung that writes the whole word writes somebody else's bit too.
The drive has its own state
When a contactor pulls in, the motor starts at once. A drive is not like that. A drive has its own state and its own decisions:
- When power comes on, it is not ready at once. It checks itself, then says ready.
- When it gets the "run" command, it does not jump to speed. It speeds up slowly on its own ramp.
- When it reaches the wanted speed, it says at speed.
The drive says these things in the status word. In this simulator the bits are:
| Bit | Meaning | Mask |
|---|---|---|
| 0 | Ready | 16#0001 |
| 1 | Running | 16#0002 |
| 2 | At speed | 16#0004 |
| 3 | Faulted | 16#0008 |
Reading one bit. You AND the status word with the bit's mask. Only that bit is left in the result. Then you ask whether the result is different from zero:
SW_Bits := Drive_SW AND 16#0004 → if SW_Bits <> 0, the drive is at speed.
A compare box asks this question: NEQ in Rockwell, CMP <> in Siemens. You write the answer to a BOOL, and the rest of the program reads that BOOL.
There are two wrong ideas. The first: "I gave the command, so it is running." A lamp must show the drive's answer, not the command. The second: "I will keep a START pressed before the drive was ready, and run when it is ready." The operator does not know that. A conveyor that starts by itself three seconds later is a conveyor nobody expects.
The answer does not arrive with the question. Wait for the answer from the drive.
A fault latches and clears on an edge
A drive protects its motor. If the motor is overloaded, draws too much current or overheats, the drive trips and stops the motor. In this simulator the drive trips if the frequency stays above a certain value for a certain time.
The fault latches. Even if the cause goes away, the fault bit stays at 1. It stays until somebody looks and clears it. This is deliberate: a fault that clears by itself is a fault nobody sees.
A reset is an edge. The drive clears the fault on the rising edge of the fault-reset bit. Holding the bit at 1 is not a reset. If you wire the reset button straight to this bit, the bit stays at 1 as long as the button is held. If the button sticks, the drive cannot clear the next fault.
The right way is to make a one-scan pulse from the button:
- In Rockwell, the ONS instruction: it passes for one scan on the rising edge of the power reaching it. It needs a storage bit.
- In Siemens, the P contact or R_TRIG: it does the same job.
You write the pulse bit to bit 2 of the control word with a mask, as in 14.1.
A reset is not a start. At the trip, the run command must drop. If the command stays at 1, the drive starts again the moment the fault clears. The operator pressed RESET to put out a lamp, not to run the machine. First the reset, then a separate START.
The fault is telling you something. A reset means "I heard you". It does not mean "carry on".
The link that lies
When a wire breaks, the input goes to 0. You see it. When a network link drops, that does not happen.
When the link drops, the words from the drive are not refreshed. The values in memory stay where they last arrived. The status word goes on saying "ready, running, at speed". The speed shows 40 Hz. Nothing in the watch table changes. Everything looks healthy, but none of it is true any more.
The other direction is the same. The words the program writes do not reach the drive. In this simulator the drive keeps running on the last command it heard. The operator presses STOP, the program clears the run bit, but the drive does not hear it. Most real drives have a setting for "what do I do if communication is lost": stop, carry on at the last speed, or trip. Check this setting at commissioning. But do not write your program relying on it.
The one sign: the link bit. The network scanner (master) keeps its own diagnostic information for each device. A bit that is 1 while the link is healthy and 0 when it drops. This bit comes from the scanner itself, not from the data. That is why it does not freeze.
Three jobs to do with the link bit:
- Raise an alarm. When the link drops, latch an alarm. The alarm must not clear by itself.
- Drop the command. Clear the run bit. The drive does not hear it now, but when the link returns the first thing it hears is "stop".
- Do not trust frozen data. Put the link bit on every rung that unpacks a status bit. With no link there is no "ready" and no "at speed".
When the link comes back, the machine must not carry on by itself. The operator sees the alarm, presses RESET, then presses START.
A frozen word looks the same as a healthy one. Look for the difference not in the data but in the link bit.