Printer homes to Z stop-switch, but presses on heat bed during printing I have a Prusa i3 that homes properly when you use the menu. After adjusting the bed and homing several times, it keeps the head at a reliable distance. However, when I try to print from an SD card, the printer buries the hot end in the heat bed.
What needs to be adjusted to fix this issue?
G-code from one of the 2 files
M190 S50.000000
M109 S200.000000
;Sliced at: Mon 13-06-2016 15:39:25
;Basic settings: Layer height: 0.2 Walls: 1.2 Fill: 20
;Print time: 3 hours 47 minutes
;Filament used: 11.435m 34.0g
;Filament cost: None
;M190 S50 ;Uncomment to add your own bed temperature line
;M109 S200 ;Uncomment to add your own temperature line
G21        ;metric values
G90        ;absolute positioning
M82        ;set extruder to absolute mode
M107       ;start with the fan off
G28 X0 Y0  ;move X/Y to min endstops
G28 Z0     ;move Z to min endstops
G1 Z15.0 F3000 ;move the platform down 15mm
G92 E0                  ;zero the extruded length
G1 F200 E3              ;extrude 3mm of feed stock
G92 E0                  ;zero the extruded length again
G1 F3000
;Put printing message on LCD screen
M117 Printing...

;Layer count: 446
;LAYER:0
M107
;LAYER:1
M106 S127
G1 F2400 E-4.50000
G0 F3000 X81.474 Y58.603 Z0.300
;TYPE:WALL-INNER
G1 F2400 E0.00000
G1 F2220 X83.063 Y56.456 E0.06663
G1 X84.277 Y55.080 E0.11240
G1 X84.836 Y54.444 E0.13353
G1 X85.799 Y53.476 E0.16759
G1 X86.755 Y52.587 E0.20015
G1 X87.179 Y52.244 E0.21376
G1 X88.836 Y50.911 E0.26680
G1 X89.285 Y50.610 E0.28029
The correlation between the endstop switch  -- or sensor -- and the surface of the bed is not known a priori .  In your case, there are two possibilities.  I'd say the more likely is that your g-code generator is not setting the Z-height offset from the bed correctly.   The other is that your bed is tilted, so proper Z-home at one corner does not match the entire bed.

Try this:  first manually move the extruder head to all four corners and adjust the bed screws until the separation is identical at all times.   Then let your gcode start up -- and don't worry if the extruder depresses the bed during homing, as that doesn't matter.  See where the extruder is once the print starts.  Adjust the endstop switch up or down to compensate until the print head when printing is just off the surface and the first layer adheres well.  

If all that doesn't work, then you may have the wrong printer profile settings in your slicing softwqre.