element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Blog NI Thermocouple Kit: Fan Heater Temperature Measurement with Python
  • Blog
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: neuromodulator
  • Date Created: 18 May 2022 6:42 AM Date Created
  • Views 2811 views
  • Likes 12 likes
  • Comments 6 comments
Related
Recommended

NI Thermocouple Kit: Fan Heater Temperature Measurement with Python

neuromodulator
neuromodulator
18 May 2022

Introduction

Fan heaters work by forcing ambient air through heating elements. Manufacturers usually warn about not putting anything too close to the front of heaters as it could burn or catch fire, but what is the temperature of air at different distances from the heater? This question is what I tried to answer by measuring the temperature at different distances from a fan heater using Python's NI-DAQmx library. 

Setup

To make the measurements I used 2 thermocouples, one to measure the ambient temperature and another to measure the air temperature at the exhaust of the heater at different distances from it.

image image

Distances where all measured at the floor level, but the probe was set at the height where the air was the hottest. Since the hot air flows in a roughly parabolic way, it was difficult to find hottest spot by hand. But my plan was not to be accurate, but to to get a rough approximation of how the temperature dropped as distance from the heater increased, and also at the same time show how easy it is to use the cDAQ from within Python.

Code

NI-DAQmx is not only available in LabVIEW, but also in C, and in Python. For this project I used Python to record the temperature at distances of 10, 20, 30, 40, and 50 cm away from the heater. At every distance I gave myself 90 s to record the temperature and manually move the thermocouple up and down until I could find the hottest spot.

Let’s look at the code:


import time
import numpy
import nidaqmx
import nidaqmx.constants as constants


# Settings

filename = '../Data/Heater.npy'

dx = 10
frequency = 4

repetitions = 5
iterations = 90 * frequency


# Code

T = numpy.zeros((2, iterations, repetitions))

with nidaqmx.Task() as task:
    task.ai_channels.add_ai_thrmcpl_chan('cDAQ1Mod1/ai0', thermocouple_type = constants.ThermocoupleType.K, cjc_source = constants.CJCSource.BUILT_IN)
    task.ai_channels.add_ai_thrmcpl_chan('cDAQ1Mod1/ai1', thermocouple_type = constants.ThermocoupleType.K, cjc_source = constants.CJCSource.BUILT_IN)

    task.timing.cfg_samp_clk_timing(4, active_edge = constants.Edge.RISING, sample_mode = constants.AcquisitionType.CONTINUOUS)

    for i in range(repetitions - 1, -1, -1):
        
        print('Press ENTER to measure at {:.0f} cm'.format(dx * (i + 1)))
        input()
        
        task.start()
        t0 = time.time()

        for j in range(iterations):
            data = task.read()
            T[0, j, i] = data[0]
            T[1, j, i] = data[1]
            print("[{:.1f} s] T0 = {:.1f} °C, T1 = {:.1f} °C".format(time.time() - t0, round(data[0], 1), round(data[1], 1)))

        print()
        
        task.stop()

    numpy.save(filename, T)

The first things one notices are the similarities between Python's NI-DAQmx code and LabVIEW's NI-DAQmx nodes. Let's review the NI-DAQmx code.

First a task is created. A task is a collection of channels with timing, triggering, and other properties.

with nidaqmx.Task() as task:

Next, two thermocouple channels are added to the task. Here I specified the name of the channel, the thermocouple type and the cold junction compensation setting. 

task.ai_channels.add_ai_thrmcpl_chan('cDAQ1Mod1/ai0', thermocouple_type = constants.ThermocoupleType.K, cjc_source = constants.CJCSource.BUILT_IN)
task.ai_channels.add_ai_thrmcpl_chan('cDAQ1Mod1/ai1', thermocouple_type = constants.ThermocoupleType.K, cjc_source = constants.CJCSource.BUILT_IN)

Then the sampling setting are configured to sample at 4 Hz, at the rising edge of the clock signal and to sample continuously.

task.timing.cfg_samp_clk_timing(4, active_edge = constants.Edge.RISING, sample_mode = constants.AcquisitionType.CONTINUOUS)

At this point everything is set to begin sampling. This is done starting the task.

task.start()

At this moment data can be read, and the function returns a list with 2 values, the samples captured from each of the previously added channels.

data = task.read()

When no more samples need be captured the task must be stopped.

task.stop()

 

As it can be seen, the library is easy to use and requires few lines of code to configure the hardware and begin capturing data.

Results

As I had to manually find the height where I would get the highest temperature reading, and also considering that the temperature reading does not change instantly, and that the hot air flow is likely turbulent, finding the hottest spot was very hard. For the same reason the results might not be very reliable, but still good enough as a rough approximation.

The first thing that I did was to plot the complete 5 time series to see how much temperature varied as I probed different heights.

image

It definitely does not look great (and it was not even my first attempt). I took the maximum value at each distance and made a new plot.

image

It's hard to know how close I was to the true values, but the results may still be minimally useful to roughly estimate how to position the heater so that it does not damage or burn anything in the room.

Conclusions

I initially though that finding the hottest spot in front of the heater would be a relatively simple, but it ended up being very difficult. The huge temperature oscillations while looking for the hottest spot, as seen in the plot, show how much trouble I had find the spot. 

More interesting than the experiment itself is how the NI-DAQmx library can be used to make measurements. The shown Python library is a wrapper of the NI-DAQmx C library. There are other Python NI-DAQmx wrapper, but the one shown here is the one supported by NI. The library is as simple to use as LabVIEW's library. This is not very surprising considering that both rely on the NI-DAQmx driver, and for the same reason they are more or less equivalent. For the same reason, the capabilities, features or difficulty of using the data acquisition library is the one factor that will not be relevant when deciding what programming environment to use when building a data acquisition system.

  • Sign in to reply
  • neuromodulator
    neuromodulator over 3 years ago in reply to mp2100

    I suspect that with a hair drier it would have been easier because air flows at a much higher speed and the flow would bend much less in the first half meter. The heater that I used does not accelerate air much, so at 0.5 m I would say the hottest spot was around 0.6 m above the floor.
    The tube diagrams shows the average velocity, but the flow is still quite chaotic. This link shows some nice experiments to visualize the turbulent flow of hot air from different sources.

    https://www.youtube.com/watch?v=4tgOyU34D44

    I expect the heater to generate something similar, but I haven't tried to visualize the air flow

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mp2100
    mp2100 over 3 years ago

    Good example of the features of the python library.  Your example python is so short, everything gets done auto-magically inside the "task".

    Having done gas flow calculations in my youth, (but in pipes, not open air, so there's that), I want to mention that laminar flow is parabolic.  As you state, your flow is likely turbulent, so it will have a rounded-rectangle shape, and it will have a lot of temperature mixing going on.

    image

    I grabbed that picture from

    https://engineeringlibrary.org/reference/laminar-and-turbulent-fluid-flow-doe-handbook

    Also, in the open air, hot air rises, so I'd expect your maximum temperature would move higher as you got further away from the heater.  Doing it by hand must be rather difficult to do in 90 seconds.

    Allen

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neuromodulator
    neuromodulator over 3 years ago in reply to DAB

    Yes, you are right. I just wanted to keep everything simple and focused on showing how to control the kit from Python.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neuromodulator
    neuromodulator over 3 years ago in reply to shabaz

    Python is slowly getting more adopted in science and engineering, but it will take time to catch MATLAB. (a) is also on my TODO list, and I suspect its not even difficult at all. Now about web I don't know much, but I think I saw some time ago that it was possible to run Python locally in the browser. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 3 years ago

    You might want to include a humidity sensor for your testing.

    The more water in the air increases the heat delivery capability for the same volume of air being moved.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube