functional thermocouple amplifier code - messy