{"id":2180,"date":"2015-03-04T06:23:27","date_gmt":"2015-03-04T09:23:27","guid":{"rendered":"http:\/\/tangopardo.com.ar\/2cf7\/?p=2180"},"modified":"2015-04-05T22:08:22","modified_gmt":"2015-04-06T01:08:22","slug":"trying-to-measure-temperature","status":"publish","type":"post","link":"https:\/\/tangopardo.com.ar\/2cf7\/2015\/03\/04\/trying-to-measure-temperature","title":{"rendered":"(trying to) Measure temperature"},"content":{"rendered":"<p>In a while I&#8217;ll need to characterize an oven and perhaps build a new one.<br \/>\nJust to start I have to apply a power step and measure how the internal temperature evolves.<\/p>\n<p>In order to save time I searched my local distributors and bought a K type thermocouple with amplifier and cold junction compensation. It is not the most accurate but it is more than enough for now. There are a couple of ics available that give a direct digital output but the work needed to breadboard them and have a meaningful reading is beyond the scope at this stage.<\/p>\n<p>This is what I bought:<\/p>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 100%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div data-carousel-extra='{\"blog_id\":1,\"permalink\":\"https:\\\/\\\/tangopardo.com.ar\\\/2cf7\\\/2015\\\/03\\\/04\\\/trying-to-measure-temperature\"}' id='gallery-1' class='gallery galleryid-2180 gallery-columns-1 gallery-size-medium'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top.png'><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"225\" src=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top-300x225.png\" class=\"attachment-medium size-medium\" alt=\"\" aria-describedby=\"gallery-1-2182\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top-300x225.png 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" data-attachment-id=\"2182\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2015\/03\/04\/trying-to-measure-temperature\/themocouple_amplifier_top\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top.png\" data-orig-size=\"800,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"themocouple_amplifier_top\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Thermocouple amplifier as it originally was.&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top-300x225.png\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_top.png\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-2182'>\n\t\t\t\tThermocouple amplifier as it originally was.\n\t\t\t\t<\/dd><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n<p>Appears on many places as a &#8220;Grove High Temperature Sensor&#8221;. It sports an <a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/opa333.pdf\">OPA333<\/a> precision opamp and a <a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/cj432.pdf\">CJ432<\/a> adjusted to provide a 1.5V reference. The rest of the circuit is nothing special, except that the manufacturer called the thermistor &#8220;light&#8221;. It can be consulted <a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/High_Temperature_Sensor_v1.0.pdf\">here.<\/a><\/p>\n<h3>First ligths<\/h3>\n<p>While I have more capable hardware at hand I grabbed an Arduino Nano and the official library from <a href=\"https:\/\/github.com\/Seeed-Studio\/Grove_HighTemp_Sensor\">https:\/\/github.com\/Seeed-Studio\/Grove_HighTemp_Sensor<\/a> and lo and behold I had it streaming temperature to my terminal.<\/p>\n<h3>Let&#8217;s get graphical<\/h3>\n<p>I cooked a simple gui on python using <a href=\"http:\/\/qt-project.org\/\">Qt<\/a> and <a title=\" Qwt - Qt Widgets for Technical Applications\" href=\"http:\/\/qwt.sourceforge.net\/\">Qwt<\/a> while listening to Olivia Newton.<br \/>\nIt is pretty barebones, only has facilities to export into csv, a couple of tracking cursors and gracefully handles device disconnections (say, I yank the cable). I expect to post process the data using <a href=\"http:\/\/www.qtiplot.com\/\" title=\"QtiPlot - Data Analysis and Scientific Visualisation\">QtiPlot<\/a> or <a href=\"https:\/\/kst-plot.kde.org\/\">Kst.<\/a><\/p>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-2 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-2 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 100%;\n\t\t\t}\n\t\t\t#gallery-2 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-2 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div data-carousel-extra='{\"blog_id\":1,\"permalink\":\"https:\\\/\\\/tangopardo.com.ar\\\/2cf7\\\/2015\\\/03\\\/04\\\/trying-to-measure-temperature\"}' id='gallery-2' class='gallery galleryid-2180 gallery-columns-1 gallery-size-medium'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui.png'><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"251\" src=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui-300x251.png\" class=\"attachment-medium size-medium\" alt=\"\" aria-describedby=\"gallery-2-2190\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui-300x251.png 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui.png 830w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" data-attachment-id=\"2190\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2015\/03\/04\/trying-to-measure-temperature\/captura_gui\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui.png\" data-orig-size=\"830,694\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"captura_gui\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Basic datalogger made with Qt and Qwt&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui-300x251.png\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/captura_gui.png\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-2-2190'>\n\t\t\t\tBasic datalogger made with Qt and Qwt\n\t\t\t\t<\/dd><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n<h3>Tweaking<\/h3>\n<p>One of the first things I noted was that the measured temperature jumped in big steps of about 2\u00b0C.<br \/>\nUsing the default setup with a 5V &#8220;reference&#8221; and considering the amplifier gain every adc bit amounts to:<\/p>\n<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=+Vbit+%3D+%5Cfrac%7B5000mV%7D%7B1023%2A54.16%7D+%3D+0.09024+mV+&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\" Vbit = &#92;frac{5000mV}{1023*54.16} = 0.09024 mV \" class=\"latex\" \/>\n<p>Looking at the polynomial coefficients used by the library (ITS90) and taking a first order approximation one bit corresponds to a 2.26\u00b0C step and it grows bigger with the measured temperature as other terms start to influence the result. Even tough the output is low pass filtered at about 1.6KHz and it is averaged over 32 points there&#8217;s still noise. <\/p>\n<p>Changing the reference to use the regulated 3.3V makes it about 1.5\u00b0C but even if it is more than enough for what I need it can be better.<\/p>\n<p>With a couple of bits more I can achieve better resolution. Instead of using an external adc I took advantage of the inherent noise on the reference and output and chose to apply a 16 times oversample in order to have 12 bits out of the 10 bit adc. Application note <a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/doc8003.pdf\">AVR121<\/a> explains that nicely. Now I am limited (in theory&#8230;) to 0.37\u00b0C steps and I can average on top of that to further reduce variations.<\/p>\n<p>The last source of error (besides not knowing for sure the &#8220;real&#8221; value of the references) is that the library assumes a fixed 350mV output, the circuit ideally floats the amplified thermocouple voltage around that. In order to measure it I added a small relay from my stash (<a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/TQ2SA-5V-Panasonic-datasheet-110367.pdf\">TQ2SA-5V<\/a>) to short the input. It is not meant to be used as a dry relay but does fine so far.<br \/>\nUpon startup it reads 348 mV; while a 2mV difference may not seem that big it turns out to be at least 185m\u00b0C. Anyway the main sources of error now are the thermocouple and adc reference.<\/p>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-3 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-3 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 100%;\n\t\t\t}\n\t\t\t#gallery-3 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-3 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div data-carousel-extra='{\"blog_id\":1,\"permalink\":\"https:\\\/\\\/tangopardo.com.ar\\\/2cf7\\\/2015\\\/03\\\/04\\\/trying-to-measure-temperature\"}' id='gallery-3' class='gallery galleryid-2180 gallery-columns-1 gallery-size-medium'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay.png'><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"225\" src=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay-300x225.png\" class=\"attachment-medium size-medium\" alt=\"\" aria-describedby=\"gallery-3-2181\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay-300x225.png 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay.png 437w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" data-attachment-id=\"2181\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2015\/03\/04\/trying-to-measure-temperature\/themocouple_amplifier_deadbug_relay\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay.png\" data-orig-size=\"437,328\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"themocouple_amplifier_deadbug_relay\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Thermocouple amplifier with deadbugged relay to measure offset.&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay-300x225.png\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2015\/03\/themocouple_amplifier_deadbug_relay.png\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-3-2181'>\n\t\t\t\tThermocouple amplifier with deadbugged relay to measure offset.\n\t\t\t\t<\/dd><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>In a while I&#8217;ll need to characterize an oven and perhaps build a new one. Just to start I have to apply a power step and measure how the internal temperature evolves. In order to save time I searched my local distributors and bought a K type thermocouple with amplifier and cold junction compensation. It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[32,13,37,24,4,62],"tags":[64],"class_list":["post-2180","post","type-post","status-publish","format-standard","hentry","category-dumpster-diving","category-electronica","category-facultad","category-hacks","category-python","category-tf","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pmnbC-za","_links":{"self":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts\/2180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/comments?post=2180"}],"version-history":[{"count":12,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts\/2180\/revisions"}],"predecessor-version":[{"id":2202,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts\/2180\/revisions\/2202"}],"wp:attachment":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/media?parent=2180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/categories?post=2180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/tags?post=2180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}