Monday, October 25, 2010

Fix A Tarnished Mirror

Thermoduino: the thermometer for Brewers!

This blog began to include topics pertaining to post a bit 'too "odd", and would definitely do so in the case of concentrating on one or two, perhaps with some random digression occasionally. In a decision a little 'markettara "the first subject on which I focus is certainly on the same focus as the most access, either directly or keywords: Arduino, and the meanders of a myriad of experiments always clearly incomplete I try to do something really useful with my beloved Arduino: the thermometer for Brewers!

The creation of craft beer is anticipated that during the two stages of fermentation the temperature of the must before and after quasi-beer does not exceed 24 degrees and does not fall under 18. Since the basic kit for Arduino is a temperature sensor and a buzzer at the various fairs and I have accumulated an embarrassing number of 7-segment display I got the ideuzza to build a "custom brewers thermometer," which in the vicinity of the fermenter monitors ambient temperature and alerts the brewer when the temperature range recommended by the bait.
As you know the appetite comes with eating and, though having recently passed the antipathy towards integrated "automatic-pilot led" I soon decided to replace the 7-segment display with an LCD 2 lines by 16 columns, with the intention to detect and also show the upper and lower peak temperature reached, more or less like this: ________________



T: 23.2 U: 120:00
MX: 25.8 MN: 20.2
________________


where T is the instantaneous temperature value, U elapsed time from power, MX and MN the minimum and maximum values \u200b\u200breached during the period of ignition.


The device is also equipped with a buzzer a (deactivated) when exceeding the upper threshold or lower. Initially I thought of managing the activation / deactivation via software, with a button and a debounce routine, but I folded on the most simple solution on the NEG-breaker in series with buzzer and LED control. The signal is also sent when the buzzer is turned off, but the software component has been slimmed down a bit '.


First question: the temperature-dependent components in the examples I've seen around the net have 3-pin: POS, NEG and analog output. What in the kit based Arduino has only two, and bears a very beautiful written 4.7 that clarifies the nature ....
The mystery has lasted very little: in the first case it is a 'sensor temperature "once in power provides the output value in tenths of temperature, while in the second we are facing as expected for a resistance thermometer, which changes its value depending on the temperature. It 'clear that changing the resistance value of the voltage output is mathematically dependent on that input, and if he is not a value defined within the function software that will perform the conversion, the end result will be very difficult to accurately .


Let's step back: Arduino accepts a wide variety of input power and has a output 5v "nominal." Since the RTD work function of the voltage input is essential to check precisely the variation of the pin 5v Arduino as a function of supply voltage. connected to the USB notebook meter output signal v 5.05, while the powered USB hub with 5.07 marks. 4 x 1.5 with a little 'flat the result is 4.61 while with 9V battery (charged or discharged tested) the value of 4.95 is fairly stable voltage.

I was going to say "Go for the Brick 9V" when I had a fit of caution, and I preferred as a first experiment, a buy online LM35, whose operation is described in some Arduino PDF officers, suggests that it is distributed with some basic kit, probably abroad.
sensor
The sensor is very simple: +, - and out, going straight into a pin analog. Everything else is done by software, but first let's look to get the hardware as a whole:




The device visa front (note the control cables of the display)
A detail of "shield" made from a normal spacers


The back with the card installed Arduino
Regarding the software deserve a moment's attention functions that allow you to use the sensor. First to be set via the command analogReference (INTERNAL) the voltage reference for analog ports, in this case 1.1volt. To avoid too rapid oscillations the program performs a cycle of 20 sensor readings, and media passes to the function Next, in charge of transforming volt read from the pin in temperature, multiplied by 100 (read-cent value) to 1.1 (voltage reference) and 1024 (as required by the analog / digital converter), then multiplying the result further to 10 in order to pass to the next display the detail of tenths of a degree. The function is described more clearly in the 'Arduino Starter Kit Manual of Earthshine Design: a document that every Arduinica should have!


the firmware there are still some small details:
- Saving to EPROM of the minimum and maximum values \u200b\u200b
- The reset button and the routine of the latter
- The part of the management software actually buzzer


before making the device with these features I wanted to close the section on temperature measurement, but honestly, these values \u200b\u200bdo not appear accurate, but overestimated by at least 1-2 degrees while precision would be 0.5.
I realized, the final installation, the sensor could be affected by excessive proximity to the display. I will try to desolder and then resolder on extensions. At the same time I do a comparative test between the sensor is currently mounted (LM35DZ), and "one wire" (DS18B20) and the resistance thermometer supplied with the kit based arduino that, to my surprise, it seems the device with greater precision, except for having accurate values \u200b\u200bof input voltage.
Beyond these further developments it was an interesting experiment, especially for a first step towards the safe handling of strings in the language of Arduino that I will certainly be useful in the interpretation of GPS signals for the project OpenNav!


is the "Thermoduino in function:




And here is the source of the firmware (is kept writing to serial port for debugging purposes): # include
potPin int = 0;
float temperature = 0;
maxtemp float = 0;
float mintemp = 1000;
upSec int = 0;
LCDOUT char [32];
/ / initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Thermoduino");
  lcd.setCursor(0,1);
  lcd.print("Vers. 0.1");
  delay(1000);
  lcd.clear(); 
  Serial.begin(9600);
Serial.println("LM35 Thermometer ");
analogReference(INTERNAL);
}

void printTenths(int value) {
// prints a value of 123 as 12.3
Serial.print(value / 10);
Serial.print(".");
Serial.println(value % 10);
}

void printFloat( float val, unsigned int precision){
// prints val with number of decimal places determine by precision
// NOTE: precision is 1 followed by the number of zeros for the desired number of decimial places
// example: printDouble( 3.1415, 100); // prints 3.14 (two decimal places)
    lcd.print(int(val));  //prints the int part
    lcd.print("."); // print the decimal point
    unsigned int frac;
    if(val >= 0)
 frac = (val - int(val)) * precision;
    else
 frac = (int(val)- val ) * precision;
    lcd.print(frac,DEC) ;
}

void loop() {
int span = 20;
int aRead = 0;
for (int i = 0; i < span; i++) {
aRead = aRead+analogRead(potPin);
}
aRead = aRead / 20;
temperature = ((100*1.1*aRead)/1024)*10;

// convert voltage to temperature
Serial.print("Analog in reading: ");
Serial.print(long(aRead));
// print temperature value on serial monitor
Serial.print(" - Calculated Temp: ");
printTenths(long(temperature));
lcd.clear();
lcd.setCursor(0,0);
lcd.print("T=");
printFloat(temperature/10,10);
upSec=upSec+1;
lcd.print(" U=");
lcd.print((int)(upSec/60));
lcd.print(":");
lcd.print((int)(upSec % 60));  
if (temperature > maxtemp) maxtemp = temperature;
if (temperature < mintemp) mintemp = temperature;
lcd.setCursor(0,1);
lcd.print("MN=");
printFloat(mintemp/10,10);
lcd.print(" MX=");
printFloat(maxtemp/10,10);
delay(1000);
}

0 comments:

Post a Comment