Modified calibration function

Add automatic detection of vinmax next