How to obtain accurate depth maps using nodes and visualize them? I want to render depth maps and surface Normal maps of different 3D shapes using Cycles. 

To be able to get depth maps, I attempted the two used methods that includes creating nodes here and played around with the parameters to get depth maps. 

However, I run into the same problem that the question asker has run into (getting almost completely white images): I know accurate depth maps must only be stored in OpenEXR files but I also need to be able to view the depth maps for visualization purposes. 

I am pretty new to the concepts of node trees in Blender and would appreciate if someone can give me some step-by-step instructions on how I can create node trees that store the depth maps (with a black background) on disk in OpenEXR or .txt files and map the values to 0-255 so that I can have some visualization, although less accurate. 

Another thing: how can I avoid getting truncated depth maps?

Here is the best results I could get through trial and error:



And here is a .blend file which includes the 3D mesh I am trying to render depth maps for, in case you need.
To visualize the Z depth just use the Normalize node. Normalize will take the lowest and highest values of the image and scale them to be 0 (black) and 1 (white) respectively. All values in between will be scaled linearly as well.
And maybe also enable transparency...