Temperature measurement and PC data processing

Go To Last Post
26 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, new project time - this is a hobby project (not a uni project or the like). I've had a play with uC's and AVRs specifically before, but don't have in-depth knowledge or expertise, and I'm also only a novice at programming and electronics (which means I'm not in a good place, I know :-) ). I have thought that perhaps a commercial solution will be the best approach here, but then I also thought I have a Mega32 control board in the cupboard and perhaps I can build something with that..... So here goes, here's what I need and then you can tell me whether I'm wasting my time or not thinking about an AVR solution, and whether there are other approaches you can think of.....

I have a need to read multiple temperature sensors(currently thinking k-type thermocouples) to read temperatures up to probably 300deg C, in a coffee roasting scenario. There needs to be at least two temperature sensors, possibly three, low likelihood that I need 4, very unlikely to be 5 or more. One of them specifically is in an area where there is open flame, and it's goal is to make sure there's never a significant temperature decrease (ie the flame has gone out). If I could be bothered, later I might try to find some form of gas flow meter to measure the gas flow into the burner, but that's not likely. Things happen relatively slowly, so ultra-fast sampling is not necessary - probably once a second would suffice. Accuracy is not hyper-critical but good.

I'm not looking to control the temperature, but I do want to plot/record this info over time. And as I said I want one channel to report if there's a drop-off in temp. I am thinking that the alerting/recording/graphing may best be handled on a PC and feeding it data. If that's the approach then I'm thinking I'll need a program to handle that data and process it. I have an old laptop that will be part of a PC solution, so that isn't a consideration.

Solution 1 (commercial): buy a product that has thermocouple input (for instance, Advantech's USB-4718 or Data Acquisition's DT9805) and either use their library/software to pull the data into a custom app, or into Excel via VBA. Pros: pre-built, lowering time to deliver; commercial grade. Cons: cost of hardware may be prohibitive; may require their proprietary software as well, which may also be prohibitive; most likely will still require some form of custom coding at the PC end.

Solution 2 (DIY): Use a uC; use a set of MAX6675's and TCs to grab data. Have the uC output serial data (how formatted ?) and have a PC program read that data and deal with it. Pros: may have a lower initial cost - I say MAY deliberately, my expectation is that cost escalates over time :-) . Cons: may require a LONG time to do, may never achieve results, may cause divorce etc etc.

Solution 3 (DIY, in stages): use the uC as above but just display data on an LCD to start with and use the buzzer on my controller board as the alert for temperature decreases. Pros: this will give incremental results and provide usefulness in the short-term while the bigger project evolves (or dissolves as I decide it's too hard). Cons: introduces things not in end design (LCD) so adds to the cost.

The controller board I have is a ATMEGA32 board from Futurelec, from here http://www.futurlec.com.au/ATMegaControlBoard.jsp, reasonably old now but as I said it's what I have..... It has serial out capability, and an audible buzzer, so it seems an OK starting point and from a hardware perspective I think it'll do the job - but I will need to deal with LCD (don't have, haven't used before so may require play-time) and MAX6675 (same deal) and TC's (will be needed for any of the options anyhow). It's been a while since I originally played with AVRs so I'll have to re-learn a fair bit here!

If I'm to head down the DIY avenue I'm pretty sure I'd take option 3 first even though it introduces some additional overhead (LCD) but nothing that I think is not achievable. There are a number of "milestones" I can see, specifically the hardware aspect of first one SPI device to read the thermocouple temp via MAX6675, then expand that to multiple TC's/MAX6675's, as well as hardware for the LCD (the LCD part is probably pretty easy given what I've read here in the last day, except figuring out wiring requirements and given my controller has an LCD port but not much info available).

So what do you think? Has anyone attempted to interface an AVR in this way to a PC? Anyone with thoughts/suggestions/pointers on sending structured data like this via serial comms to a PC ? Anyone who thinks just give up and go commercial? Any and all assistance, guidance, pointers, references, thoughts gratefully received!

A fourth option has just sprung to mind:

Solution 4 (commercial and nasty): I have a commercial multimeter with a serial-out option and a thermocouple/temperature measurement mode, at about $40 per device perhaps I would be better off finding a way to interface multiple of these to a PC? (for the Aussies out there, it's a Jaycar QM1538 multimeter). Thoughts?

Thanks all
Brett

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

a few reads but no bites/feedback. Hmm, thought it might be too hard a task for a uC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, its not at all "too hard a task". However, it IS mostly hardware.

You have not asked about thermocouples, but in the US, you can get them, quite easily, in automotive parts stores. Mechanics use them a LOT for engine diagnosis.

For highest accuracy, you need a "cold junction circuit" at each thermocouple connector. At 300C, the 25C room temperature is just enough to add in some uncertainty. There are several cold junction compensation ICs out there. Analog Devices, for sure. Probably Linear Tech and Maxim. Most, if not all, are analog processors and the voltage still needs digitizing. A good example is AD595 (for type K) which produces 10mV/C output. At 300C, this would give you a nice signal that could be digitized with a standard AVR A/D converter.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, so that was slightly tongue in cheek way of bumping the post towards the top because of the holiday break.

K-type thermocouples are relatively easy to acquire in Australia as well, so they're not a concern (although I may have to look for supplies of more industrial ones with longer cable runs). If I go the self-build path, I would use a Maxim MAX6675 which is an amp and CJC in one, so only need to connect it to the AVR via SPI (and potentially I'd do software SPI on standard IO ports as I want multiple TCs and probably use individual CS lines). From a pure hardware perspective, I think I can sort most of that out, the software is the bit that worries me!

I'm concerned about the uC programming aspect, but given there's a lot of great assistance available here I reckon I can find my way thru some/most of this with only minor speedbumps. The part I have no idea about is the approach to interfacing with the PC, and while I have probably the same amount of skills/expertise and resources available to me, I suspect that this is actually the bigger part of the puzzle than the uC part ! Perhaps I'm totally wrong, and happy to be told that, but I'm still somewhat skeptical it'll work out in the end.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A while back, I had developed a 10 TC temperature recorder. In fact, it accepted up to 10 different and individually selectable inputs, that can be choosen among a set of TC, Pt1000, NTC, PTC, etc (two wires only). ATmega128/1281 based, and one AD7708 16 bit SPI ADC. The only added thing was a simple external NTC attached to one AVR ADC input for cold junction compensation.

With some math, it achieve 1 ºC of precission between -150 and 1200ºC (K type TC) after some calibration, with an external thermocouple simulator.

Relatively cheap, and not an effort for an AVR.

To calculate the compensation through the external NTC, I used something similar to the tutorial that I wrote about temperature measurement in the tutorial forum. For the TC, I also used a similar technique (interpolation through a LUT) applying the 16 bit readings from the external ADC. Shoud not be too difficult.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

(currently thinking k-type thermocouples)

As thermocouples can be "tricky" as has been discussed, have you considered other sensor types, and also mixing and matching?

"Less tricky" includes solid-state analog or digital (e.g., LM35) and thermistors. But can't get to your flame range generally. What is the upper end of measurement range for the other channels?

Perhaps a bit less tricky would be RTDs. With the proper constant-current drive distance isn't a problem.

Infrared for the flame?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The MAX6675 does function as a digitizer in addition to CJC and amplifier. You are still limited to about 1 meter between the micro and the interface and that link is somewhat noise sensitive (could be a problem if you have spark ignitors for the burner, for example).

Software SPI is not needed. You can use any set of select lines you want in conjunction with the hardware SPI interface. The hardware makes it easy. You probably can slow down the SPI clock to improve the noise immunity.

The PC interface will have two components. One is the transport of the data. The other is the interface and presentation software in the PC. For transport, your practical options are RS232 and USB. i would recommend USB with the FT232R from FTDI (available from Mouser and other sources); data between it and your micro uses the micro's U(S)ART. To the PC, it looks like a COM port so any software (or programming language) that is able to function with async serial data should be able to deal with it.

For the PC software, there are lots of options. What you use depends a lot on what you are familiar with. python is "free". RealBasic is great and provides a lot of gui power, but costs. There are others out there if you don't already have something in mind.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

newpoundy wrote:

Solution 4 (commercial and nasty): I have a commercial multimeter with a serial-out option and a thermocouple/temperature measurement mode, at about $40 per device perhaps I would be better off finding a way to interface multiple of these to a PC? (for the Aussies out there, it's a Jaycar QM1538 multimeter). Thoughts?

Thanks all
Brett

Hi Brett,

Unless I have misunderstood you, your main concern is getting the data into the PC. Is that correct? As you already have the multimeter with serial output, you could investigate the data format, speed, etc. They are likely to be send-only devices. Use one of the many terminal software packages to capture the data stream and see if you can decode the readings (pencil and paper). If that works (so far $0.00 cost), you could investigate one of those old automated serial data switches popular years ago (I might even have one hiding around here somewhere). Then you could use the PC software to select each channel in turn and log the data.

Just a $0.00 thought ... :lol:

Cheers,

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A commercial solution: google for AKO-15742. Now imagine who had developed it ;)

Serial (trhough RS-485/ModBus) comms with PC, so you can get recorded data from it. Thermal printer, temperature logging, graphics LCD, etc. Expensive. I can help you with PC software if needed.

Anyway, I would recommend you to use approach 3. It would be more funny, and is not too difficult.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guillem. I can't guess. I can only suspect that you're right about the "expensive" part, because I can't find anywhere online that actually lists the price. That's usually a good indicator of how expensive things are anyway :) I guess it'd be too cheeky to ask for source code? ;-)

Ross, thanks for that idea. Yeah, there's a possibility. I know (roughly) what the serial output is, and I am sure that it'd be reasonably easy to decode - the output is at something like 250ms intervals so it shouldn't be too challenging to deal with in any form. Automated serial switchers - mmm, can't say I remember them (and I'm not a whippersnapper so I kind of expect I should!). Perhaps though that means there's a different ATMEL project on the table now, a multi RS232 serial port input to USB output handler (I still think I'll approach it from the other end though)

I think I've found a collaborator to help with some of this, who has greater knowledge than I in several key areas - microcontrollers, electronics, and programming. So I agree, I think it's a worthy project and one that doesn't seem as drastic as I may have first thought, so perhaps it'll work out - time will tell I guess!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I can't give you any code about it. But I can help you to write code to acquire temperatures trhough AD7708 ADC and convert its inputs to temperature depending on the TC plugged to the input (quite simple schematic, BTW), and send all this data trhough Serial Port.

This way, with few IC's, you can get up to 10 TC to only one AVR, and send all this data trhough only one serial port.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk,

From what I know about SPI (which we all know isn't much!) I was thinking I'd be using multiple MAX6675's in a "single master, multiple slave" setup as shown in Illustration 3 on this page: http://www.mct.net/faq/spi.html, and I assume what you were speaking of was more the cascaded setup like Illustration 2? If I'm off-base there is there any pointer you can send that might enlighten me?

On the USB/RS232 options, my controller board is preconfigured with a MAX232 so I have the option of just going straight to RS232 reasonably simply, or if the PC I was targetting only had USB (which it isn't) I'd potentially take the easy way out and buy a module like one of these: http://www.elexol.com/USB_Modules/.

thanks again for your assistance

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

if you want to save the LCD you could output the temperature binary on LEDs. Not beautifull but easy like breathing.

I never wrote a PC programm which talks to a COM/RS232. But I read that there are librarys with functions for it. Shouldn't be THAT hard I guess.

Out of curiosity: What and why are you exactly going to meassure with the project?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh and I forgot to mention that I still think the biggest challenge I have is this: Writing an app for the PC that takes "data" in from COMn: and turns it into meaningful things - a graph in Excel for instance - in realtime. I am thinking this really needs some form of "protocol" to work effectively - I'm expecting I'll need to make a decision whether this is "close coupled" to the device or not: do I just make the device spew forth a stream of data like "Data 1:23;Data 2:45; Data 3: 209;\n" or should it be a pseudo terminal approach where the PC App requests "Data 1" and the uC responds.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nephazz,

yes, there's libraries for everything. The hard part is putting them all together :)

it's a coffee roaster - I bought it on ebay a few years ago and am now realising some of the benefits that I'd get with better temperature profiling, as well as wanting to avoid a singed eyebrows if the gas goes out and I don't notice and I re-light it (ask me how I know!). So I want to have at least 3 TC's, one in the firebox area to watch for temperature decreases that may mean the gas has run out or flamed out (plus I just found an LPG sensor that may also get a guernsey here), one more in the coffee bean mass to tell how the roast is going, and one in the exhaust gas to check how the overall heating is going. And we all know how important coffee is!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The easiest way to get data into your pc is to send asci values to the serial port, like:
value1,value2,value3 /n

You could then use Hyperterminal in Windows to write all this data to a file.
This text file can then be inported into Excel, which puts everything automatically in the right column, and allows you to make nice graphs.

For real time graphs on the computer you will need more work. Labview is one relatively quick solution to make nice real time graphs from serial port data.

Enjoy,
Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, *me love coffee* ^^

I'd go with the "avr sends every meassurement right away".
Pro:
- one way communication
- no "ISR__Find-and-send-requested-data" needed
- plug in PC and watch data flowing
- no extra EEPROM needed

Con:
- PC has to run all the time

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I'm not a coffee drinker, but:

How about a picture of the device?

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok so I've uploaded some simple pics of what this coffee roaster looks like, not very good pictures but it will give you an idea I hope. They're on my skydrive folder (which I hope this link will get you to):

http://cid-75f98776bcbd47fe.skyd...

IMG_0387 is the frontal view of the roaster. Needs a bit of a clean, sorry about that :) Shows you the current measurement equiment, a simple thermocouple into a digital multimeter (not a data logging/serial output device) and a simple digital timer that is used only for general timing. (there's also an older electronic temperature device that doesn't work). The round part facing the camera is the roasting drum, where the beans are roasted, and operates much like a front-loading washing machine. :) In the drum there are ramps that assist the beans to move randomly around the drum. The lower front part is a hinged door that allows the beans to be tipped out once they have reached the correct roast point.

IMG_0390 is the side view of the machine showing the firebox area, and I'll need to mount a TC in there (somewhere, somehow)

IMG_0391 shows the gas burner - two bars about 2" below the rotating drum.

IMG_396 is a close up of the front door area showing the current thermocouple hole and also some green coffee beans actually being roasted at this time. The beans sit mainly at the lower part of the drum, but move as it all operates.

There you go, hope it helps visualise this all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi... im using a termistor to control the temp.
have try the i2c temp chip, but the problem with this one is the cable, i2c dont like cable longer then some
meters...

Regards Christer / Sweden

$crystal = 8000000
$regfile = "m88def.dat"
$hwstack = 150
$swstack = 150
$framesize = 350

Config Portc.0 = Input ' AMP IN
Config Portc.1 = Input ' Temp 1
Config Portc.2 = Input ' Temp 2
Config Portc.3 = Input ' Temp 3
Config Portc.4 = Input ' Temp 4
Config Portc.5 = Input ' Temp 5

Config Adc = Single , Prescaler = Auto , Reference = Internal
Start Adc

Declare Function Adc_temperatur(byval _aadcport As Byte , Byval _aaresistor As Word , Byval _aarefa As Single , Byval _aarefb As Single , Byval _aarefc As Single , Byval _aarefd As Single) As Single

Dim Water As Single
Dim Temp1 As Single
Dim Temp2 As Single
Dim Temp3 As Single
Dim Temp4 As Single

'return a temperature in Celsius = Adc_temperatur(adc port number , this is the value on the termistor, im using a 5k termistor , 0.001279997391383 , 0.000238154860625 , -0.000000241469727 , 0.00000010216717)
'all the rest are value that i found from my termistor, but this value have workt fine for a lot of other termistors too... so jus test it...

Test:
Water = Adc_temperatur(1 , 5000 , 0.001279997391383 , 0.000238154860625 , -0.000000241469727 , 0.00000010216717)
Temp1 = Adc_temperatur(2 , 5000 , 0.001279997391383 , 0.000238154860625 , -0.000000241469727 , 0.00000010216717)
Temp2 = Adc_temperatur(3 , 5000 , 0.001279997391383 , 0.000238154860625 , -0.000000241469727 , 0.00000010216717)
Temp3 = Adc_temperatur(4 , 5000 , 0.001279997391383 , 0.000238154860625 , -0.000000241469727 , 0.00000010216717)
Temp4 = Adc_temperatur(5 , 5000 , 0.001279997391383 , 0.000238154860625 , -0.000000241469727 , 0.00000010216717)

' make some coffe...
Wait 1
Goto Test

Function Adc_temperatur(_aadcport As Byte , _aaresistor As Word , _aarefa As Single , _aarefb As Single , _aarefc As Single , _aarefd As Single) As Single
Local _temperatur1 As Single : Local _temperatur2 As Single : Local _temperatur3 As Single : Local _temperatur4 As Single
Local _temperatur_ln As Single : Local _jmf_temperatur As Word : Local _adsnurra As Byte : Local _adc_value As Word
Local _medeltemp As Single : Local _termistor_temperatur As Single : Local _prev_temperatur(4) As Single

_medeltemp = 0

'take 10 reading from the adc, just to make it a little more stable
For _adsnurra = 1 To 40
_adc_value = Getadc(_aadcport)
If _adc_value > 980 Then _adc_value = 980 ' dont let it go under -34.3
If _adc_value < 49 Then _adc_value = 49 ' and not more then +110.4 but this is just for my program, using this to control a heat pump in my house
_medeltemp = _medeltemp + _adc_value
Next _adsnurra

_adc_value = _medeltemp / 40

'Beräkna Resistans
_temperatur4 = _adc_value
_temperatur1 = _aaresistor * _temperatur4
_temperatur2 = 1022 - _temperatur4
_temperatur3 = _temperatur1 / _temperatur2
'Beräkna Temperatur

_temperatur_ln = Log(_temperatur3)
_temperatur1 = _temperatur_ln * _aarefb
_temperatur1 = _temperatur1 + _aarefa
_temperatur2 = _temperatur_ln ^ 2
_temperatur2 = _temperatur2 * _aarefc
_temperatur2 = _temperatur2 + _temperatur1
_temperatur3 = _temperatur_ln ^ 3
_temperatur3 = _temperatur3 * _aarefd
_temperatur3 = _temperatur3 + _temperatur2
_temperatur4 = 1 / _temperatur3
_temperatur1 = _temperatur4 - 273.15

'Ta bort en massa decimaler & avrunda
_temperatur1 = _temperatur1 * 10
_temperatur1 = Round(_temperatur1)
_temperatur1 = _temperatur1 / 10

'add 0.1 for the failsafe resistor...
_temperatur1 = _temperatur1 + 0.1

Adc_temperatur = _temperatur1
End Function

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Adding a $.25 multiplexer to the front of a single MAX6675 would save you some cash, and let you read as many TCs as you want.

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Things on the project are progressing. I've reinvigorated my coding skills, figured out some of the nuances of AVR Studio for debugging, and have some of the modules sorted (Serial, timers, LED program running indication). Starting to think about the MAX6675 as they should arrive in the post some time this week, and have yet to start thinking about debouncing a couple of push buttons (without doing their own spin loops). Have hit a bit of a hurdle with the LCD display - I've found the standard libraries that are out there expect a particular port connection that the controller board hardware I have doesn't meet - so I've got some (re) soldering to do and re-thinking of my port use. But all in all, as most people said, it looks achievable :)

Tom, suggestion on multiplexer to use? Are there any considerations around voltage loss etc on a low-voltage device like a thermocouple? That may well save me some ports on the uC too!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mapped my IO pin challenge. Ran into and resolved JTAGEN which I'd never come across before, so PORTC now working.

Serial in/out working.
LCD working.

Switch debounce next!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the photos, I've never seen a coffee bean roaster before.

It sounds like your project is coming along nicely!

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Tom, suggestion on multiplexer to use? Are there any considerations around voltage loss etc on a low-voltage device like a thermocouple? That may well save me some ports on the uC too!

My apologies for not catching your question earlier. A 74HC4051 style will work well. If you keep your actual thermocouples (the temp sensing end)insulated from ground you can use a single 4051. If any thermocouple must be grounded, like clamped under a screw or something, a second mux will be needed so that differential voltage measurements may be taken across the thermocouple leads. No big deal, but it is a consideration.

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you're still needing to sense a flame, you can use a flame sensor from a gas furnace. These can be picked up at. Talk to a local HVAC guy about getting you one or just go to an HVAC/appliance supply house.