sparkfun / SparkFun_MCP9600_Arduino_Library

An Arduino library to configure and control the MCP9600 Thermocouple Amplifier.
Other
5 stars 4 forks source link

Thermocouple Type seems to get set to "K" by"setFilterCoefficient(coefficient)" #5

Open rwischinski opened 2 years ago

rwischinski commented 2 years ago

Subject of the issue

Thermocouple Type seems to get set to "K" when "setFilterCoefficient(coefficient)" is executed.

Potential Cause

setFilterCoefficient lib code does not seem to read correct Thermocouple Type Select bits:

uint8_t MCP9600::setFilterCoefficient(uint8_t coefficient) { if (coefficient > 7) return 3; //return immediately if the value is too big

uint8_t config = readSingleRegister(THERMO_SENSOR_CONFIG); // Current code //bitWrite(coefficient, 3, bitRead(config, 3)); //bitWrite(coefficient, 4, bitRead(config, 3)); //bitWrite(coefficient, 5, bitRead(config, 3)); //bitWrite(coefficient, 6, bitRead(config, 3)); //bitWrite(coefficient, 7, bitRead(config, 3));

// Should be ? bitWrite(coefficient, 3, bitRead(config, 3)); bitWrite(coefficient, 4, bitRead(config, 4)); bitWrite(coefficient, 5, bitRead(config, 5)); bitWrite(coefficient, 6, bitRead(config, 6)); bitWrite(coefficient, 7, bitRead(config, 7));

return writeSingleRegister(THERMO_SENSOR_CONFIG, coefficient); }

paulvha commented 2 years ago

recently bought this sensor and I agree with your findings. This should be changed and I think this is also the root cause for an older problem https://github.com/sparkfun/SparkFun_MCP9600_Arduino_Library/issues/1

Regards, Paulvha