Why should you spend money for an electrohydraulic motion controller when you might be able to use a PLC instead? The answer is not simple. In general, it is a function of quantity, degree of difficulty, available time, production rates, required precision, and economics. The decision can be quite fuzzy. From experience, we know which types of applications can be done using PLCs and which ones cannot.

Cost usually comes to mind first for most control system designers. The simple route is to buy a PLC with an analog input and output for each axis, some digital I/O, then start programming. You usually start out with a simple proportional control; a PID block isn’t even required. This is how hydraulic servo control is done in much of the world, and people who are taught hydraulics are taught nothing more.

The analog feedback must be scaled into position units. However, I’m surprised to see how many people ask on PLC forums how to scale an analog input into millimeters or inches. If someone asks that, they shouldn’t be programming anything. After scaling the inputs, it is very simple to subtract the actual position from the command position, multiply the difference by the proportional gain, and write that to the analog output to the valve. That’s easy enough.

*1. This simulation shows what happens when the command position is changed instantly by 100 mm. The control output saturates at 100%, and the actuator accelerates rapidly with a jerk. The actual position still approaches the destination of 100 mm slowly.*

### Setting up a PLC for Analog Control

A challenge for PLC control occurs when the command and actual positions of a cylinder are far apart because the output to the valve may be very large. The result is that the hydraulic cylinder races at full speed to the command position. What happens at the command position depends upon the gain and load. Sometimes the cylinder will decelerate smoothly toward the command position, but a large load will probably cause overshoot, with decaying oscillations.

Different solutions to this problem have been suggested. A simple one is to limit the output at some value below 100%. A better solution is to make a crude target generator and increment the target position toward the command position. Then, instead of comparing the command position to the actual position, the actual position is compared to the next target position. The target position starts at the current actual position and is incremented at a desired rate until it reaches the command position. This avoids the initial jolt and shock when making a long move. This solution is also relatively simple to implement.

For example, synchronizing the position of two cylinders is relatively easy if both cylinders follow the same target position. If the loads on the two cylinders are fairly equal, the following error behind the target position should be equal so the actual position of the two cylinders should be about the same.

So what is the following error for proportional-only control?

The formula for the following error is:

*E _{f}* =

*v*/(

*K ∙ K*

_{p})

Where:

*E _{f } *is the following error, mm,

*v *is velocity, in mm/s,

*K* is the open-loop gain, in (mm/s)/%, and

*K _{p}* is the proportional gain, in %/mm.

*2. This plot shows the same scenario as above, but the command position is changed by only 10 mm. Notice it takes about the same amount of time. This is due to the move always taking five time constants. Five time constants take 0.358 sec. Even a 1-mm move will take 0.358 sec. to get within 1% of the destination.*

The units are important and should be consistent. The percentage represents the percent of control output. The percent of control output can be a percentage of ±10 V, ±20 mA, or whatever the control output units are. The following error is usually not important when using a PLC e cylinder only needs to get reasonably close to the command position. The above equation will be needed for applications requiring a limit on the following error. The user determines the velocity to meet the application requirements.

Calculating open-loop gain requires using the VCCM equation, which calculates the maximum steady-state velocity at 100% control output. This equation been discussed many times in this column. Click here for a detailed explanation.

Calculating the proportional gain is more difficult. You can use trial-and-error methods and settle for a value that appears to work. If the proportional gain is too low, the cylinder will respond sluggishly. If the proportional gain is too high, the actuator will tend to oscillate. However, the optimal proportional gain can be calculated:

*K _{p}* = (2 ∙ ζ∙ ω

*∙ (9 − 8 ∙ ζ*

_{n }^{2})/(27 ∙

*K*

*)*

Where:

*K _{p}* is the proportional gain, in % control/mm of error,

ζ is the damping factor (assume 0.3333 if unknown),

ω is the natural frequency, in radians per second, and

*K* is the open loop gain.

You won’t find the derivation of the formula for proportional gain in textbooks. It may be covered in a future installment of “Motion Control.” However, hydraulic system designers actually have control of what the optimal proportional gain will be because they have control of the damping factor, natural frequency, and open-loop gain. Normally, the natural frequency is calculated using the bulk modulus of oil, cylinder areas, volume of oil under compression, and mass. Because the following error depends on the open-loop gain and the proportional gain, the hydraulic designer has control of the following error.

*3. This simulation shows the benefit of adding a simple target generator that moves at a constant velocity. Notice that the control output does not saturate, and the actual position moves much more smoothly. The velocity approaches 250 mm/sec. as expected. (100 mm/0.4 sec.). The acceleration is much less. Notice that the velocity scales are much different between the first and third simulations.*

### Additional Concerns with Proportional-Only Control

So now the system is tuned and ready for a short move, and it appears to work. A slightly longer move is tried, and the two moves appear take about the same amount of time. The reason for this is that as the error decreases, the control output decreases, so the velocity decreases exponentially. It takes about five *time constants* for the actual position to reduce the error to less than 1% of the original error.

A time constant is the time a controlled object takes to reduce the error by about 63%. So, if the error instantly increased to 10 mm, and the time constant is 1 sec., the error would be reduced to 3.68 mm after 1 sec. After 2 sec. the error would be reduced to 1.35 mm. After five time constants (5 sec), the error would be reduced to 0.067 mm—less than 1% of the original error of 10 mm. The time constant determines how long the system will take to respond to disturbances.

The question then becomes, how do you calculate the time constant for a hydraulic cylinder using only a proportional gain? This formula isn’t too hard:

τ is the optimal time constant.

*τ* = 3/(2 ∙ ζ∙ *ω _{n }*

*)*

If the damping factor is 0.33333 and the natural frequency is 10 Hz, then the time constant is:

*τ* = 3/(2 ∙ 0.333 ∙ 2 ∙ *π* ∙ 10) = 0.072 sec.

Because it takes five time constants to reduce the error to 1%, the move would take 0.358 sec.

Notice, again, that the optimal time constant is completely determined by the mechanical (hydraulic system) designer. If the time for five time constants is too long, the hydraulic system designer needs to increase the natural frequency, or the damping factor by increasing the friction. Increasing friction wastes energy. Increasing the natural frequency requires increasing the cylinder diameter. Doing so requires also increasing the valve, accumulator, and pump sizes, raising component costs.

Implementing a simple proportionally controlled hydraulic system with a PLC is straightforward, but the PLC programmer has no control over many important parameters. This limitation is not related to the PLC programmer’s ability but, rather, by the hydraulic and mechanical design. Unfortunately, the PLC programmer usually gets access to a hydraulic system at the last minute and is expected to “fix it in software,” which, simply, will not happen. System behavior has already been “baked in” based on the design and manufacturing decisions.

Machine performance can be significantly improved with a sophisticated hydraulic servo control system. The initial cost of acquisition is higher, but it is offset by increased performance. The machine will also be easier to maintain and will require maintenance less frequently.

Below are three simulations of simple moves using proportional-only control. They are based on the standard linearized model used for simulating motion for servo hydraulic cylinders and load.

*H(s) = *(*K ∙ ω ^{2}_{n}*)

*/[s ∙ (s*]

^{2}+ 2 ∙ ζ ∙ ω_{n}∙ s + ω^{2}_{n)}*K*, the open-loop gain, is assumed to be 10 (mm/s)/% control output,

*s*, the Laplace operator, is a frequency, in radians per sec.,

ζ is the damping factor and is assumed to be 0.33333. It is dimensionless,

*ω _{n}* is the natural frequency, in radians per sec. The natural frequency in this case is 10 Hz.

These simulations are intended to raise some questions, but I’ll leave you with this one: How can the response time be improved? This question will be answered in a future edition of “Motion Control.”

*Peter Nachtwey is president of **Delta Computer Systems Inc.** and has more than 35 years of experience developing industrial control systems for hydraulic, electric, and pneumatic applications. In addition to leading Delta’s engineering and R&D programs, he contributes widely to the mathematical understanding of control theory, especially in fluid power systems.*