The XH-B310 is an inexpensive and wonderful temperature display. It can be powered from 12V or a 9V battery, and displays the K-type thermocouple temperature on a large LED display. The best part is that they can ready up to 800 degrees C! These are super useful for keeping an eye on a reflow oven temperature, or a distillation or liquid temperature during chemistry experiments and so on. The possibilities are really endless. It is also, oddly, cheaper than a thermocouple IC breakout board several times over.
Unfortunately the developers did not think to provide the temperature data to the user in any sort of easily digestible form. Using these to feed data into a smarter system is unfortunately not so easy. This is truly disheartening as the system uses an STM8 micro-controller, which could easily provide temperature data at 9600 baud on a spare pin.
It should be possible to piggy-back an arduino nano onto the analog signals output by the various sensors to the board's ADC. This is not as ideal as just getting the result from the micro for many reasons, but it does mean it is entirely possible, and indeed quite likely, that each board will display a slightly different reading. This will have to be acceptable...
The XH-B310 is a clever design and can be broken down into the following components:
- 5V Regulator - To provide a constant voltage to the LEDs
- 3.3V Regulator - Powers the rest of the board
- op-amp - 76x gain stage for thermocouple voltage
- analog mux - which switches between passing the + (for normal operation) and reading the - (for calibration)
- 2.5V precision reference for the ADC
- 10k thermistor to sense ambient temperature
- a diode for reverse polarity protection
- An stm8s003f3 microcontroller
To calibrate the offset voltage, the unit pulses the MUX every 67 seconds for a little over a second and reads the negative pin of the thermocouple.
The ambient temperature of the cold junction is measured using a 10k glass packaged thermistor. Since there is no part number on the thermistor, the beta value was determined experimentally and found to be ~4050.
The process junction is read through an analog MUX, and then multiplied by an op-amp with a gain of 1+66=67x.
Offset Voltage Cal
The solution here is to either discard point that differ greatly (or maybe just require several in a row to change the alert status of the setpoint being reached or reset) or even better would be to intercept the MUX control signal, and use it to our advantage.
An Arduino nano was used due to the low cost and high availability.
The source code can be found here: https://github.com/nebarnix/XH-B310_Backpack
The arduino only has a 10-bit ADC, which is not exactly ideal. As temperature signals are particularly slowly time varying, we can apply exponential filters to smooth out the data.
In addition, each 'sample' is in fact a burst of 10 samples averaged to help remove noise on a per-sample basis.
Exponential filters are applied to the offset voltage reading, to the thermistor temperature, and to the final temperature value. The order of the filters are not identical.
- define ALPHA_TREF 0.1
- define ALPHA_TC 0.05
- define ALPHA_CAL 0.5
Example of an exponential filter: Filtered_Value = ALPHA * Raw_Reading + (1.0 - ALPHA) * Previous_Filtered_Value where alpha is between 1 and 0 with 1 being unfiltered data and 0 being infinitely filtered data (a value of exactly 0 for alpha is clearly not acceptable).