Temperature measurement project

Thread Starter

BlackBox

Joined Apr 22, 2007
20
Hi,
I am working on a project involving a BD139 transistor heating up and a sensor measuring the temperature. I have to use a PIC18F452 to implement the control algorithm and the interface to a computer.

I built my circuit and i use a PWM port as an output to control the collector of the BD139. The sensor (an LM5DZ) is attached to the transistor with termal paste and it's output is read through the channel 1 A/D converter (PIN A2) on the PIC18. The control algorithm is a PID with antiwindup i wrote.

Now for some specs:
Supply voltage: 5VDC
A/D Converter: 10bit Sigma-Delta
PWM 20Mhz

My problem is that my measurements are really noisy as my 10bit A/D gives me a minimal resolution of 0.5°K with a max temp of 500°K witch is way too high for my requirements.

So i thought of using some kind of amplifyer to multiply the voltage from the sensor (10 mV/°K) by a factor 5, or 10 to achieve resolutions of 0.1 °K or 0.05°K.

My first idea was a Non-Inverting Op-Amp (with 2kOhm direct and 8kOhm feedback) cos it is simple to implement, but i know too little about electronics to figure out possible drawbacks.

How am i to highen the input voltage for the A/D Converter? Is a non inverting op amp Ok?

Thanks a lot
Bye
 

John Luciani

Joined Apr 3, 2007
477
I am not sure why you would need a PID algorithm to measure a temperature.
You should be able to let the BD139 reach equilibrium and then make your measurement.

For amplification I would look at instrumentation amplifiers. These are designed to perform
the exact function that you need. You can buy these with preset or programable gains. Check out Analog Devices and TI (Burr Brown).

I am not sure why you are measuring the case temperature of the BD139 but here
is idea for measuring the junction temperature of BD139 --- use the change in Vbe(sat)
of the BD139 to measure its own temperature. The Vbe(sat) at low collector currents
changes -2mV per DegC. There are ICs that perform diode junction temperature
measurements like the National Semi LM95231 - Precision Dual Remote Diode Temperature Sensor. I believe the Maxim and Analog Devices also make similar
devices.

(* jcl *)
 

Thread Starter

BlackBox

Joined Apr 22, 2007
20
Thanks a lot for the help,
I am a systems and automation engineering student so the important part of my project is the sensor adjustement and PID controller! The BD139 is just a representation of a thermal plant with an actuator.

Is an op-amp linear enough for my measurements, or does it have a stange gain curve?
 

Nomad

Joined Oct 21, 2007
43
Can't you just set a lower +voltage reference for the AD on the pic, and get the full 10 bit across the lower range?
 

Thread Starter

BlackBox

Joined Apr 22, 2007
20
hey that would be super fine, but i do not know how to set the Vref. For example, say i need to measure voltages between 0.0V and 2.5V, should i put 1.25V on the +vref? should i leave -vref disconnected or should i pull it to ground?
Do i have to check some fuses or programming issues in the PIC?

Thanks a lot for the advice Nomad
 

Thread Starter

BlackBox

Joined Apr 22, 2007
20
I know a little more about Vref now, but i am unsure about using a voltage divider to make the reference... is it safe or will my measurements be doomed by great noise?

thanks for the great help
 

John Luciani

Joined Apr 3, 2007
477
Is an op-amp linear enough for my measurements, or does it have a stange gain curve?
Using only resistors in the feedback loop the op-amp will be linear until you get close
to the power supply rails. With very small signals you need to be careful of the
input offset voltage. If the temperature of the op-amp is stable then you can
calibrate to remove the effect.

Unless the op-amp circuit design is a required part of your project you
should take a look at instrumentation amplifiers. Analog Devices and TI would
be more than happy to send a student a couple of free samples.

(* jcl *)
 

SgtWookie

Joined Jul 17, 2007
22,201
You might instead consider using 1-wire devices, or I2C devices.

For example, Dallas/Maxim has the DS1822 IC, which is a low-cost digital thermometer in a TO-92 case. It reports the temperature via 1-wire communication, resolution is 2ºC, 9 bits of data

The DS18B20 and DS18S20 are similar chips with approx. 0.5°C accuracy, programmable 9 to 12 bits of data.

Using these IC's, the temp conversion to digital is done directly on the chip, minimizing the possibility of noise interference.
 

Thread Starter

BlackBox

Joined Apr 22, 2007
20
I have set the voltage reference for the ADC to 1V with a voltage divider. It works fine for me... a bit noisy, but fine.

Instrumentation Amps are a little expensive for this project; how do you get samples of these? on their site?
 

SgtWookie

Joined Jul 17, 2007
22,201
I have set the voltage reference for the ADC to 1V with a voltage divider. It works fine for me... a bit noisy, but fine.

Instrumentation Amps are a little expensive for this project; how do you get samples of these? on their site?
Yes, go to their sites. Look at the "Samples" section. Of course, samples are not available for all items.

You might try using some 0.1 uF bypass capacitors across your resistor divider network; strange as it seems, resistors can be noisy.

You DO have a bypass capacitor on the PIC power pin to ground, right? 0.1uF, very short leads?
 

Thread Starter

BlackBox

Joined Apr 22, 2007
20
I have a protoboar from OLIMEX, that's what they provided for the project...
http://www.olimex.com/dev/pic-p40.html
It has two bypass capacitors (100nF and 100uF) but they are not very close, and 2 100nF surface mounted almost directly across the Vdd Vss pins, so yes, i have capacitors :p

I have checked the voltage on the Vref pin with a digital multimeter, it stays exactly between 1004 and 1005 mV all the time, they can't be the source af my noise can they?



the red line is the actual measurement, the green line is the filtered response (moving average filter [1/4 1/4 1/4 1/4]), the blue is the reconstructed response of the system.

the peaks are one °K above the actual temperature...
 

John Luciani

Joined Apr 3, 2007
477
Your filtered curve looks correct.

Noise is difficult to measure and you cannot measure noise with a multimeter.
If you do not connect your oscilloscope probe properly you will get an incorrect
measurement due to radiated noise induced onto the scope probe.

For some pictures of a properly connected oscilloscope probe see http://www.luciani.org/eng-notes/ee-notes/ee-notes-index.html

Without looking at the circuit and the circuit layout it is difficult to say where the source
of the noise is coming from. You could see if others that are doing the same
the same project are having the same problems. You could try a filter capacitor
on your reference divider as was previously suggested.

(* jcl *)
 

SgtWookie

Joined Jul 17, 2007
22,201
Try putting 0.1uF filter capacitors across the resistor divider network; between GND and Vref, and Vref and Vcc.

Even a little noise on your Vref will give you really noisy output.
 

Thread Starter

BlackBox

Joined Apr 22, 2007
20
It work super fine now!

Thanks a bunch!

Next time I will probably buy a LM317 and use that... will be much easier won't it?
 

SgtWookie

Joined Jul 17, 2007
22,201
It work super fine now!
Great news! :D

Next time I will probably buy a LM317 and use that... will be much easier won't it?
Well, with an LM317, you would still need filter capacitors at the input and the output, and so instead of just 2 resistors and 2 caps, you'd need the LM317 as well! You've increased your parts count by 1, and not really gained anything that you could've done using just the resistors and caps - because the Vref current is infintestimally small. On the other hand, if the load varied, you WOULD need a regulator.

Now that you have it working with the 2 resistors and 2 caps, try removing the cap that goes from the middle of the voltage divider to Vcc, and leave the cap from the middle of the divider to ground in place. You probably will not see much difference - if you do, that means that one of your other filter caps is bad or poorly connected (the 100nF cap from your PIC Vcc to ground, or the main filter cap.)
 
Top