Tuesday, November 01, 2011

Hot plate PI controller - Part 5: Boiling water and measuring with thermistor

I made a new mistake in my attempt to make a hot plate PI controller: The thermistor I selected from eBay was an unbranded China thermistor marked with "10k ohm 103 NTC Thermistor"with no datasheet. I thought it would be easy to obtain the datas for the thermistor, but so far I have not been able to find any other info than what the seller is saying:

Model: CP_RM_103 NTC Thermistor
Resistance: 10KΩ
Resistance tolerance: +/- 10%
Temperature: 30°C to +125°C

I have sent an email to the seller as a last effort to get a datasheet for the thermistor, but I have doubts that I will get it.

I wanted to set up a test to check the accuracy of the thermistor in combination with the pre set parameters in the arduino library for thermistors. I soldered a wire to the thermistor, filled a pot with 1 liter of spring water, submerged the thermistor and boiled the water. When boiling temperature 100°C is reached the chart for temperature with stabilize at 100 degrees as water is vaporized.

First some theory:
Thermodynamics has equations describing how a volume will be heated. When there is no flow in or out of the volume the heating equation reduce to:

Cp*ρ*V*dT/dt=P+h(T0-T)

Where
Cp is specific heat capacity. For water Cp=4181.3 J/(kg*K)
ρ is the density. For water ρ=1000 kg/m^3
V is the volume. For my experiment I use 1 liter=1e-3 m^3
T is the temperature in the volume.
T0 is the temperature of the neighboring. The air temperature is about 22°C
P is the power of the heating source. I use two different boiling plates with 1.4 and 1.5 kW
h is the heat conduction number

If no energy is transferred to the environment with no other losses whatsoever I get:
Δt=Cp*ρ*V*ΔT/P

I am using two different hot plates:
1. A 1.5 kW standard hot plate. Ideal time for boiling 1l water should be 262 seconds, about 4 minutes.
2. A 1.4 kW induction hot plate. Ideal time for boiling 1l water should be 281 seconds, about 4,5 minutes.

The ideal heating time is based on the tap water being 6°C.

After modifying the LabVIEW VIs used with the thermistor and servo to also save raw voltage data to disk and importing to excel I get these curves:





A couple of things can be observed from the charts:
  1. The heating curve for the induction hot plate is very erratic. This is likely because induction is basically fast alternating current through a coil. This creates a magnetic field that again induces current in the sensor wire. If better results are to be obtained with an induction cooker I need a shielded thermistor.
  2. Both measured heating curves for the induction and standard hot plate has a measured boiling temperature of about 110°C. This is probably due to wrong values for this sensor set for the Steinhart-Hart equation.
  3. The zero crossing with the y-axis is above the temperature of the tap water temperature. This is again probably due to wrong values in the Steinhart-Hart equation.
  4. Some drops are observed for the standard hot plate. This is due to different temperatures when the thermistor touched the pot and when it was only in contact with water.
  5. The slope for the induction cooker is very close to the ideal curve, thus the induction cooker is very efficient at transfering energy into cooking water.
  6. The induction hot plate and pot can be modeled as an integrator without time delay. The standard hot plate can probably be modeled as an integrator with a time delay included. When heating a larger amount of water I am expecting more energy to be transfered to the environment, and  the curves will probably take the shape of a "time-constant with time-delay" process.
Now I need to search a little more to try finding some information about the sensor specs. This in combination with the measured curves will probably give me everything I need to know to calibrate the thermistor.

Hot plate PI controller - Part 4: Playing with thermistor, RC servo and LabVIEW with arduino library


In my previous post I wrote that I wanted to use LabVIEW in combination with an additional Arduino library and the Arduino device to work as a controller. LabVIEW has library for both fuzzy and PID controllers.

I have been testing the LabVIEW PID library in combination with the Arduino library while waiting for my thermistors to arrive. My first test was to use a potmeter as an input for a PID controller setpoint and use a simulated plant to test the PID functionality. I tested the PID relay autotuner, which is a tuner that uses on/off signals to test the plant response. I have previously used relay autotuners successfully to set PID controllers with microcontrollers. The autotuner function in the LabVIEW PID library seems to be more sensitive to having a working PID controller before trying to excite the plant with on/off signals. My experience with the library is that this results in a poorly tuned controller. My plan is to use the step response for the plant to set the controller or make a relay based controller from scratch from my previous knowledge of the problem.

A few days back I finally got my 10k thermistors from eBay. The 10kohm value seems to be rather flexible with the LabVIEW Arduino library, and I cannot really understand why. I thought that the equation used, the Steinhart-Hart thermistor equation, needs three parameters A, B and C set that is allready fixed in the Arduino thermistor read function.



I hooked up the thermistor as shown in the library included thermistor example and one servo as shown in the servo example. Pretty simple:




Next I mixed the two examples together so that the temperature from the thermistor would set the output for the servo. I multiply the temperature with 1.8 so that when I have 100 degrees C input I get a 180 degrees rotation of the servo. I also tested with different delays in the loop to remove some of the "spastic" behaviour you can get when the realtime signal is used.


I experienced a bit with moving the thermistor over a candle to check the system. Below is a video of the system in action:

Here is the output in LabVIEW with and without delay:

I am quite happy with setting this system up so quickly and with both input and output working as planned on the first run.

One thing I experience is that when I stop the LabVIEW program and restart it i get erratic behaviour of the servo. Perhaps because of the PWM output from the Arduino being out of sync with the servo. I need to pull out the USB plug from the computer a couple of times in order to make it work again. This all might have to do with me having an old Arduino or that I got black smoke coming out of it the last time I used it.

Coming up I will be soldering a wire to the thermistor, put it in boiling water and see if I get a reading of 100 degrees celcius. Otherwise I need to get better parameters for the thermistor function.

Hot plate PI controller - Part 3: Arduino and LabVIEW


It's been about three years since I last used the Arduino in any project. The reason for this is that I usually find it equally easy to implement simple things in the AVR microcontroller, rather than spending more money on the arduino. The second reason is that I have usually been working on projects requiring faster throughput time for realtime control of fast acting systems (sound/vibration).

When I now came back to look at the arduino I see that a lot has changed since the last time I used it. The obvious thing being that more modern arduinos and shields for all different kinds of purposes have come to life. The community for Arduino has grown exponentially fast and Arduino is now probably the number one gadget for electronic hobbyists. Software for Arduino has become even more easy to use and make it possible to test arduino code without a physical arduino attached with VirtualBreadboard. National Instruments has recently made it possible to include Arduino in LabVIEW with an additional library, which I will come back to later in the post.

The book "making things talk" learned me a lesson in how to work with microcontroller projects, or any other problem. Rather than trying to attack the complete problem in one chunk I now try to break down the problem in small problems that can be tested one at a time. Some things that you take for granted are usually missed if you try to include the complete set of functionality at once, and even the best debugger/emulator cannot test for every kind of outcome. This is why it is critical to test each problem one at a time.

To test the reading of a sensor, in this project a thermistor, you need a system able to show the input from the sensor to the user. With early versions of the arduino this was best done by using the programming language processing and displaying the input to the computer screen. The only difficulty with this solution was that a fraction of the code you wrote was reusable and you thus needed to write routines each time you had a new kind of problem.

Now LabVIEW, the measurement system that I as a programmer loved to hate, has come up with a complete range of pre built modules to comunicate with the arduino. So you can put all the logics in labVIEW and the input/output can be handled by arduino. This makes everything even more simple. The only problem I see with this solution is that you need a computer with LabVIEW or the labview built application to run the algorithms. I will start working with the labview modules, and later see if I want to move the whole controller and logics to the arduino.

Setting up Arduino with LabVIEW was done in a breeze. The examples and ready made functions for sensors are absolutely amazing.

Full instructions for installing Arduino with LabVIEW can be found here.
National Instruments web page for LabVIEW with Arduino

Here is even a geeky video of what the combo can be used for: