USB Based – 8 Channel Thermocouple Data Logger

About this Project

             The idea to build this Thermocouple Data Logger came to life in the early days when I worked as an R&D Engineer for Invertek Drives. In order to get to know the drives capabilities and to improve drive performance, I was carrying out different tests at that time.

             One of the most boring tests was the heat run test in which I had to measure and record temperatures from the different points of the drive at a given time interval. Also, when the test had to be carried out at high ambient temperature I had to manually turn on and off a small heater to heat up the cabinet in which the drive was mounted. In my case was almost impossible not to think at a system which would do all these repetitive tasks for me. I feel that these are common thoughts for an Engineer when he needs to do robotic tasks.

Description

             This project is about an USB Based – 8 Channel Thermocouple Data Logger.

             The temperatures are measured by K Type thermocouples. The thermocouple signal is amplified by AD8495C which is a precision thermocouple amplifier with cold junction compensation produced by Analog Devices. Microchip PIC18F4550 microcontroller is used to read the thermocouple amplifiers output and to send the data over USB to a PC. The PIC18F4550 microcontroller also performs Modbus communication in order to exchange data with the drive. PLC functionality is provided in order to control a relay which in turn is controlling a small heater. The heater it’s used to regulate the temperature of a small chamber.

             The bloc diagram of the Data Logger is presented below


USB Based – 8 Channel Thermocouple Data Logger Block Diagram

Project details

The project is mainly divided in three parts:

            1 – Schematic Design – Layout Design – PCB Manufacture

            2 – uC firmware development

            3 – PC Software development

1 – Schematic Design – Layout Design – PCB Manufacture

a)    Schematic Design

             The schematic design was mainly driven by the basic idea of constructing a temperature data logger.

             I remember that I started with readings about thermocouples. I found out that there are different types of thermocouple, but I noticed that I was using only K type thermocouple. I learned that the voltage generated by the thermocouple itself is too small to be read by an analogic input of a uC. At that point I was searching for a solution to amplify the thermocouple signal. I also found out that regular op amplifiers are not recommended for this job and I should use dedicated thermocouple amplifiers with cold junction compensation. Why? As you my know a thermocouple is basically a junction of two wires made up from two different metals and when that junction is heated up, a voltage potential which depends on the junction temperature is generated between the other ends of the wire. So far so god, but you will notice that in the moment when you will connect the measurement device in the circuit, at the connection points between the thermocouple wires and the measurement device wires you will create another two junctions (=thermocouples) in series with your main thermocouple. These junctions, most probably will be at room temperature. At that point you will have already noticed that your measurement device will be inevitably measuring the voltage generated by three different thermocouples.

             In order to get accurate temperature reading, which was the goal of this project, I learned that I need to use a dedicated thermocouple amplifier which incorporates a so called cold junction compensation mechanism. What this means? Basically the dedicated temperature amplifier subtracts the voltage given by the two parasite thermocouple from the total voltage measured. How? The dedicated thermocouple amplifier assumes that the two new junctions inevitably introduced in the circuit have the same temperature as the thermocouple amplifier IC itself. That’s why it is really important to make the connection as close as possible to the IC.

             At that point I was searching for the ideal circuit to do this job. I found out from the Analog Device support team that they had developed an IC special design for this propose. The AD8495C is a low cost and easy to use precision thermocouple amplifier with cold junction compensation pretrimmed for K type thermocouple – as described in AD8495 datasheet.

             At that point I had already had a solution to accurately measure the temperature. The following task was to pick a uC. That task was quite easy for me as all my projects are built around Microchip microcontrollers. Basically I needed a uC with an incorporated USB peripheral and at least 8 ADC channels to build the data logger; but at that moment I also thought that maybe at one moment in time I will (would) need to add Modbus functionality. That’s why I thought that an incorporated USART module would be handy. I knew that Microchip has the PIC18F4550 uC which was suitable for my requirements. Anyway, if you need to select a Microchip microcontroller for your application, there is a nice microcontroller selection tool on the Microchip web site.

             Because the Modbus communication of the drive was implemented on the RS485 layer I had to adapt the microcontroller serial output from TTL logic to Modbus differential logic. For that task I used the SN65176B IC.

             At that point the data logger schematic was mainly designed; adding some resistors and capacitors as specified in the used components datasheet was all that I had to do.

             The schematic is produced below:

USB Temperature data logger schematics

            The schematic is also available for download in pdf format here.

b)  Layout design

             I decided that I will design the circuit with SM (surface mount) components. From my previous experience I knew that I will need at least a two layers board. With all the design restrictions in mind I started to design the PCB Layout.

             You can see the results in the following pictures:

Bottom Layer + Top Layer + SST

SST

Top Layer

Bottom Layer

             A last check before the PCB production:

USB termo board being checked before production

c)  PCB production

             As I had recently moved to UK that phase of the project was quite unclear for me. I started by checking the prices for producing my board at one of the board manufacturers – the conclusion was simple and quite quick: “Too expensive!”, but I couldn’t abandon my project!

             I had been using some UV exposure techniques in the past with pretty good results, but I knew that the quality isn’t good enough for producing SM boards. I had to improve the technique. At that moment I was basically guessing what would improve the board quality. Anyway, first of all I needed a UV exposure unit but because the UV exposure units on the market were far too expensive for my budget I decided to build my own UV exposure unit. I ordered some cheap UV LEDs from ebay and I partially built a UV exposure unit just to carry on with my USB data logger project.

The partially built UV exposure unit

            Building the exposure unit will consist another topic. After the unit will be fully built I will post all the information required to build your own one and I will let you know all the details and problems that I had to solve and how I solved them.

             Till then here is a picture with my board being exposed with my partially built UV exposure unit.

USB data logger being exposed

            As you can see in the above picture a sandwich was made in order to expose the board. The sandwich was formed by the following layers: Plexiglas sheet + transparent foil with top layer printed + UV sensitive PCB board + transparent foil with bottom layer printed + Plexiglas sheet.

             Detailed pictures with the layers:

Top Plexiglas sheet

            Plexiglas was used because it’s transparent for UV light. The bottom Plexiglas sheet is identical.

Top and bottom layers printed on the transparent foil

            Transparent foil was used because high contrast can be achieved, which is essential for high precision PCB board production.

UV sensitive PCB

            For this project I used Bungard PCBs.

             After the exposure and development phase is completed, the board looks like in the following picture.

USB Temperature data logger board exposed and developed

            The developing is done by immersing the board in a NaOH solution.

             The next step is the chemical etching. I etched the board using ferric chloride solution.

USB Temperature data logger board during etching

USB Temperature data logger board after etching

PCB board quality

            Finally the board was done! Just some drilling and I could start to solder the components. The soldering process isn’t a quite easy task when you have to deal with MSOP Packages (0.65mm pitch) and SM components. As you can see in the following image I was using a microscope and some additional light to carry on this task.

That’s just me soldering the USB Temperature data logger board

            After few hours (and quite late in the evening because that day was a working day) the result looked like this:

All the components soldered on the USB termo PCB

A closure look showing the components being soldered

USB termo board ready for testing

            Finally the construction of USB temperature data logger board was finished. I found out later during the testing phase that there were two errors on the board and I had to swap around two pairs of tracks. I learned over time that two errors on a first issue board is a quite good result.

2 – uC firmware development

             I wrote the uC firmware in C programming language. I used MPLAB IDE platform to write the code. The code was compiled with HI-TECH C compiler. To flash the hex file in the uC I used usbpicprog programmer and software. Documentation about the usbpicprog hardware and software is available on www.usbpicprog.org website.

            I started by writing some simple codes just to configure the microcontroller and to turn on the LEDs in order to check that the USB data logger board was working indeed. I was lucky, I managed to flash the uC firmware from the first time and the LEDs came on. I was so excited, I couldn’t believe that there were no errors and that the board was working straight away (or at least that was what I believed at that time).

USB termo board during first tests

            After the first power up I quickly noticed that the uC was getting seriously hot and I was wandering why. After a while I figured out that I got the USB connector footprint wrong. I remembered that during the USB connector footprint design it just happened that I looked on Wikipedia for the connector terminals meaning and somehow instead of looking at the male connector, by mistake, I looked at the female connector and the result was that I got the electrical connections mirrored. This is the explanation for the moulding next to the USB connector in the above picture.

             As the board was working, it was the time to proceed further. I had to set up the USB communication. The USB communication seamed for me the most complicated part as I had never used it before. Of course that I had a lot of reading about how USB communication works and I understood a part of it, but as you know, from understanding a little bit to making it to work is a huge step. I also knew that microchip offers a USB Firmware Framework for their microcontrollers which you can directly integrate in your firmware, but I needed a fast solution. That’s why I said to myself: “let’s have a quick look on the web and see if there is some code out there which would fit my project and I could quickly test and modify it”. I was lucky; I found an application in which a USB communication was set up between a PIC microcontroller and PC. It was exactly what I needed. I was happy.

             I modified that application on both sides (uC and PC) and I managed to turn on and off the LEDs on my board by clicking on some buttons in the PC side application. For me was already a real success; I said: “from now on I can see the end of the project”.

             I carried on by implementing the AD input channels’ reading in the uC firmware and sent the values over USB to the PC. I had done some scaling in the PC software side and I had the temperature measurements measured by my USB termo board displayed on my laptop screen.

             As you can imagine I couldn’t wait to see if my measurements were as good as the ones taken with a genuine temperature meter. I thought:” let’s boil some water and measure its temperature”. As I learned in the Physics classes I expected to see 100 degrees Celsius.

Testing the temperature measurement software

             Zooming up the above picture and reading the temperature we can see 94.4°C. When I was reading it for the first time I remember that I was confused (was the altitude the reason? –but I didn’t live in the mountains; was the water impurity? – but I used tap water). I compared that temperature reading with temperature readings taken with two other temperature meters as you can see in the following pictures.

Temperature reading with RS

Temperature reading with UNI-T

             I was still confuses. Anyway, I decided to move on to icy water.

Icy water temperature measured by USB temperature data logger board

            The icy water was a much better approach, first of all because allowed me to move out of the kitchen and second because the icy water temperature was more stable. I concluded that the measurements taken by my USB temperature data logger board were accurate enough and I continued by developing the PC side software.

            After a while I decided that Modbus functionality would be handy in order to control the drive directly from the PC and later I did further modifications to the uC firmware to handle Modbus communication between the drive and the PC side software.

3 – PC Software development

             I wrote the PC software in C language using the Microsoft Visual C++ 2010 Express software platform. Microsoft Visual Studio 2010 Express is a free product and you can download it from Microsoft webpage.

             The PC software features the following functions:

    • Displays temperatures measured with USB termo board;
    • Moving average filtering to filter the temperatures measurements;              
    • Automatically creates a file on the hard drive; 
    • Stores the measured temperatures, at an user selectable time interval, in the previously created text file;
    • Drive control capability over Modbus protocol;
    • Heater control capability in order to regulate a temperature measured by a thermocouple (user selectable) (this functionality isn’t implemented at the moment when this text is created).

I still develop this software these days. The main reason for this is that every time when I use the software I found that new functionalities would be handy and I try to implement them.

 I will carry on describing the PC software as it was developed

             The PC software without the Drive control capabilities looks like in the following image.

USB data logger PC side software

            As can be seen from the above picture the used thermocouples are user selectable. Also a short label for each temperature can be introduced. The software displays the starting time, current time, number of temperature measurements taken, the interval in which the temperatures are recorded, time to the next measurement, the total number of temperature measurements recorded manually or automatically, etc.

             The store button is used to manually store the actual temperature readings. After the stop button is pressed the info label will display the path to the fail, containing the recorded measurements.

The file generated by the USB termo PC software

             The file containing the measurements is automatically generated when the start button is pressed. The name of the file is automatically created and consists of the date and time when the measurements are recorded.

             Because I was measuring the drive temperatures, I felt like it was a must to store the drive parameters together with the temperatures. That’s why I continued with the Modbus communication implementation.

             The PC software after the Modbus communication was implemented looks like this:

 USB data logger PC side software with drive control capabilities added

            The picture with the PC software is just informative, doesn’t contain real data.

             The file generated with this version of software contains the drive parameters which are retrieved from the drive over Modbus.

The file generated by the USB termo PC software containing the drive parameters

            As the above file was generated during development testes, the contained data are not real.

             In the Modbus communication between USB termo board and the drive, the USB termo board is the master device and the drive is the slave device.

             As I did the PC software development at home I had to simulate the slave device. I was simulating the slave device using a PC software and a piece of hardware, USB to RS485 converter. An image with the setup is provided below.

Setup used to develop the PC software and the uC firmware

            To simulate the drive responses and actions over Modbus, I used the ModBusView software. ModBusView can be used to simulate a slave device in a Modbus network.

             That’s all! We are now up to date with the status of this project. But there is still plenty of work to be carried on. This project exceeded the limits of what I thought it will be. This is the main reason why I decided to publish this project in this stage.

             I will mention a few of the things that still need to be done and then we are done with this project for now.

             One of the main disadvantages of this USB data logger is that the measurement (the thermocouple) side is not electrically isolated from the rest of the circuit. Therefore I am planning to redesign the electrical schematic and find a method of introducing electrical insulation. I am thinking to insulate the analogic signal between the uC and the AD8495C using analogue optocouplers. I have already found a solution for this using the HCNR201 IC. To implement this solution I will need 8 insulated power supplies. This is the part on which I am currently working. I believe that the best way to create 8 insulated power supplies is to design a flay-back converter. I am currently designing the flay-back converter but as I said before, from design to practice is a huge step.

This is the end for now! Thanks for reading!

Advertisements