Function to calibrate SPD