<p>I have a weird problem with my old 3D printer, it is a Prusa/Mendel type.
When I print a 20&nbsp;mm cube, X and Y are correct, Z is resulting 16 to 17&nbsp;mm.
I have checked the correctness of the movement on Z using the manual controls and there are no issues.</p>

<p>I played a bit with the layer thickness, I have a 0.4&nbsp;mm nozzle, setting the layer height to 0.12&nbsp;mm (normally is on 0.16&nbsp;mm) but no changes in the result.
I am printing PLA on a cold bed at 180&nbsp;&deg;C without any other particular defect.</p>

<p>I would appreciate some direction on how to solve such problem.</p>

You should check that the steps per mm for your Z-axis are set correctly. This depends on the pitch of the leadscrews/threaded rods driving the axis and parameters of your steppers (microstepping and raw steps/revolution).
This Calculator
.
Make sure that your layer height is a multiple of a full step of the Z-stepper. The Z-stepper may be disabled intermittently, and when re-enabled it may "snap" to the nearest full step position. If your layer height requires microstepping, you may notice it getting rounded down or up due to this.
For instance, if a full step were 0.08 mm, then 0.16 mm layers would require 2 full steps, printing fine. 0.12 mm layers would require 1 full step and a half microstep. Due to rounding, some layers might be reduced to 0.08 mm instead. This might account for the height discrepancy you're seeing (though 0.08 mm is quite a high, unrealistic amount for a full-step).