Temperature Measurement using Arduino and a Thermistor

17 07 2009

Components

  • Arduino Duemilanove Board, a USB cable and of course a PC/Mac
  • A 10kOhm thermistor
  • A 10kOhm resistor
  • A breadboard wires

Hot topic

It’g getting hotter and hotter. Is it due to global warming? Who knows, but in the meanwhile we can measure the temperature with our Arduino board and a thermistor. A thermistor is simply a type of resistor whose resistance varies with temperature. If we knew how it varies, we could extract the temperature from the measurement of the resistance (or, better, the voltage across its ends).

The Steinhart-Hart equation

In first approximation, the resistance is proportional to the temperature:

R = k(T-T0)

This can work for a narrow temperature range, but we can figure out something more accurate, up to the third order:

1/T = A + B logR + C ( logR )^3

The temperature T is expressed in Kelvin, the resistance R in Ohm and the parameters A, B and C must be determined experimentally, or taken from the datasheet.

If you want to be even more rigorous, you have to include a self-heating effect in the picture. I’ll give it as a black-box formula:

T = T(steinhart-hart) – V^2 / k*R

Where k is the dissipation constant, usually given in units of mW/degree C.

Setting things up

In this case the setup is really simple. First of all, connect the Arduino board to the computer (in my case, it’s a Mac) via the USB cable. Now, connect the GND terminal to the B line of the breadbord (use a black wire), and Arduino’s +5V output to the A line (use a red wire). Now, put the 10kOhm resistance between the (+) bus and a horizontal line. Now, connect the thermistor between the horizontal line you chose and the (-) bus, the common ground. Last but not least, connect Arduino’s Analog Input #0 to the horizontal line (X).

(+5V) —- R —- X —- Th — GND

Programme Arduino

Now, the geek part. We have to teach Arduino how to calculate the temperature and give us the answer.

#include <math.h>
#define READING_PIN 0

double R1 = 10000.0; //resistance put in parallel
double V_IN = 5.0;

double A = 1.129148e-3;
double B = 2.34125e-4;
double C = 8.76741e-8;
double K = 9.5; // mW/dec C – dissipation factor

double SteinhartHart(double R)
{
// calculate temperature
double logR  = log(R);
double logR3 = logR * logR * logR;

return 1.0 / (A + B * logR – C * logR3 );

}

void setup() {
Serial.begin(9600);
}

void loop() {
double adc_raw = analogRead(READING_PIN);
//Serial.println(adc_raw);
double V =  adc_raw / 1024 * V_IN;
Serial.print(“V =”);
Serial.print(V);

//calculate resistance
double R_th = (R1 * V ) / (V_IN – V);
Serial.print(“V   R_th = “);
Serial.print(R_th);

double kelvin = SteinhartHart(R_th) – V*V/(K * R_th);
double celsius = kelvin – 273.15;
Serial.print(“Ohm  —   T = “);
Serial.print(celsius);
Serial.print(“C\n”);
delay(1000);
}

Compile it and send it to Arduino. Open up the Serial Terminal, and enjoy the output stream.

Now it’s up to you

Probably, the temperature you’re measuring is quite unconvincing. You have to set up the coefficient according to you thermistor. This will be covered in a following post…





Solar-Powered Arduino Board

17 07 2009

Components

  • Arduino Duemilanove Board
  • 12V Solar Panel
  • 1N4007 Diode
  • 25V 100uF Capacitor
  • 9V Rechargeable Battery and connector
  • A breadboard and some wires (suggested red and black)
  • A multimeter to measure tensions

1) Green Power

Arduino datasheet suggests us to power it with 6-20V, being aware that the upper limit could be dangerous. It seems that 9V fits well, and it’s of course very easy to find a 9V battery in a shop. But if we really want to start our own little Green Revolution, we would like to get this electricity from some renewable source, e.g. the Sun, so we need a solar panel. It is a device made up of solar (or photovoltaic) cells, which convert light directly into electricity by the photovoltaic effect.

Now, one problem is that you can be sure that a solar panel will not provide a 9V tension constantly: As everybody know, the Sun walks through the sky during the day, and the energy that reach our panel (even given an ideal 100% conversion efficiency) changes according to the depth of air that the sun rays cross. As a matter of fact, at noon this depth is lower than at dawn or dusk. Moreover, during the night the solar panel is completely useless. So? If you’re smart enough (or if you google it), the solution is to use the solar panel to charge a 9V rechargeable battery, which in turn powers the Arduino board.

There are many solar panels on the market, so which one fits best with our Arduino board? My rule of thumb is to minimize the cost while maximizing the voltage. You can buy a 12V solar panel for ~20€, probably less. Just remember that we want to charge a 9V battery, so it’s better if our solar panel provides more than 9V.

2) Re-charging the battery

This part is the core of our little experiment. We want to wire up the board so that once the circuit is working fine, we just have to put the Arduino board in parallel to power it up.

2.1) Basic setup (wrong one)

In a circuit, electrical current (I) flows from the positive (+) outlet of the battery to the negative (-) one, just like a river flows from the mountain to the sea. Anyway, remember that in this case the charge carriers, the electrons, flows the other way around. Now, if you connect a battery to a load (e.g. a resistance), you basically deplete the battery extracting the accumulated charges. If you want to re-charge the battery, you have to push electrons inside the battery. Thus, the idea is to connect the same-sign sides of the solar panel and the battery, given that the solar panel is more positive (12V) than the battery (9V). This idea is good, but what happens during the night? The battery will send the electrons to the solar panel because now the battery (9V) is “more positive” than the panel (ideally 0V). We don’t really want that…

2.2) Basic setup (the right one)

We have to find a way to prevent this “night-effect”: The solution resides in the use of a diode. The most common function of a diode is in fact to allow an electric current in one direction (called the forward biased condition) and to block the current in the opposite direction (the reverse biased condition). Take a look at the 1N4007 diode: at one end (the cathode) there is a gray ring: The current can’t flow from this side (but you can check with a multimeter that there is a very small voltage anyway of about 0.6V). Now you are free to connect all the devices this way:

solar panel (+) —> (-) diode (+) –> (+) battery (-) –> (-) solar panel

you can convince yourself that during the night the current will not flow from the battery to the solar panel.

Circuit Schematics

Circuit Schematics

3) Connecting the Arduino board

Now that we are able to charge the battery with the solar panel, we can link the Arduino board to the whole circuit. The idea is simple: connect the (+)VIN terminal of Arduino to the (+) terminal of the battery/diode, and the (-) GND terminal to the common ground of the battery/solar panel. This way, Arduino will drain current from the “more positive” generator between the battery and the solar panel. As I said before, the problem is that the current generated by the panel is not constant. A trick to “smooth out” the voltage is to insert a capacitor between the (+) and (-) terminals of Arduino.

4) A few comments before I leave

You’ve probably seen around those fantastic devices that turns solar panels towards the Sun during the day in order to maximize the energy absorption. You could do that as well, but be aware of the fact that 12V are too much for the Arduino analog inputs! Maybe we will talk about that in next post.





ATLAS: Last detector connected

22 07 2008

The LUCID detector, which will measure the luminosity of the collisions occurring in the centre of ATLAS, was among the last pieces of the detector to get approval. In fact, the small collaboration, based in Bologna, Italy; Alberta, Canada; Lund, Sweden; and at CERN, didn’t even begin building until February of last year.

LUCID is composed of two detectors that surround the beampipe, one on each side of ATLAS, at 17 metres from the collision point. Its commissioning started June 9th and 16th, when the last two pieces of the beampipe entered the cavern with detectors attached.

Vincent Hedberg, LUCID technical coordinator, and Marco Bruschi, project leader, are quick to downplay the challenges of their commissioning tasks when their detector has 40 channels compared to the millions of channels in other subdetectors. “They’d laugh us out of the house!” says Vincent. However, accessing their detector, 15 metres above the floor, in between the outer endcap muon chambers and endcap toroid magnet, was a feat in itself. “Vincent exaggerates a bit about how easy it is,” says Marco, “since the problem was to fit all the work into a very narrow allotted time, like in a Formula 1 pit stop.”

A portion of the beam shielding block is already in place on the beamline, half a cylinder with a flat top, resembling a bridge between the big muon wheel and the endcap toroid magnet. They built a platform on top of this as a work area. Without access by ladder or stairs, they had to commute to and from LUCID on cherry-picker cranes.

Connecting LUCID to all its services took more time than expected because other activities, such as the beampipe installation, were competing for work space and access to the cherry-pickers. Even so, they successfully connected the copper pipes to carry gas for detecting particles and water for cooling. They also hooked up the cables that will transmit the detector signals as well as the high and low voltage electricity that makes it run.

The bulk of the cabling was completed in the first two weeks, finishing around June 23rd, but a few difficult areas took a bit more time. According to Vincent, in an interview on July 2nd: “We finished with the last problem cable yesterday at nine o’clock.”

Testing began as soon as the first services were connected. As of July 15th, the cooling and gas systems, and high voltage were all working. “The only thing remaining is a broken LED electronics card on one side,” says Marco, “but that we will fix in the next few days. We are now preparing the read-out so that we can be fully prepared to catch the very first collisions from the LHC machine and provide luminosity measurement from day one!”





[CERN] A word from the DG: LHC commissionning 
enters the home straight

25 10 2007

A word from the DG: LHC commissionning 
enters the home straight

 

In an age of blogs there are seemingly no secrets, so by the time Lyn Evans gave his talk on the status of LHC commissioning on 13 September, everyone seemed to know about plug-in modules, beam position monitors and transmitters embedded in ping-pong balls. All the on-line speculation made for interesting reading, and is a clear sign of the growing interest there is in CERN as we approach LHC start-up. We are now entering the final phase of commissioning, and things are going well given the unprecedented complexity of the task in hand.

Following the cool-down, powering and warm-up of Sector 7-8 earlier this year, we have learned a great deal about what it means to commission the LHC. There have inevitably been hitches, including the plug-in modules, or PIMs. When the LHC is cooled down, each sector shrinks by about 10 metres in length, and this has to be absorbed by bellows between components and a system of sliding copper fingers (PIM) that ensure electrical connectivity around the ring. When warming up Sector 7-8, a small number of fingers buckled as the machine expanded and are being repaired. The problem is understood, and concerns only a small percentage of the PIMs. To identify precisely where the problem occurs, an ingenious system involving blowing an object like a ping-pong ball with a 40 MHz transmitter (the frequency of the beam bunches seen by the position monitors) along the beam pipe has been devised.

Lessons learned from Sector 7-8 are being put into practice in other sectors. A second sector has been rapidly cooled to 80 degrees above absolute zero, a third is undergoing pressure tests, and testing of the remaining five sectors will now start at the rate of one every two weeks. In the sectors currently under test, vacuum leaks have been isolated and are also being repaired.

Meanwhile, the repair of the LHC’s inner triplet magnets is complete. A team from CERN, Fermilab, KEK and the Lawrence Berkeley National Laboratory has successfully completed the repairs. So far, three of the eight triplets have been installed and successfully pressure-tested in the tunnel. The remaining triplets are in the process of installation and pressure testing.

All of this is business as usual when bringing a new particle accelerator on-line. There are inevitably hurdles to be overcome, but so far there have been no show stoppers. We can all look forward to the LHC producing its first physics in 2008.

Robert Aymar