Pages: 1 [2] 3   Go Down
Author Topic: Temeratures control with outputs  (Read 1548 times)
0 Members and 1 Guest are viewing this topic.
Lake District, UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Electronics needs smoke to work, if it escapes its broken
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look up arduino reflow oven.
there are loads of people building PID controlled ovens for SMD electronics soldering and other are using the arduino to control cooking.
the same principle can be adopted for heating liquids.
you will need to download the PID library, but any of the available sketches will provide what you desire.

im currently working on a test oven at work which is using a sketch i found through adafruits site.

you will need heavy relays/SCRs or even contactors to control your heating elements, look at connecting relays to arduinos.
you might want to consider stirring the liquid to get an even heat, this is normal in industrial applications

the rest should be childs play
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I add another ds18B20 and I can display temperature correctly, but the output "tank3" is not working with tank3temp. He is only reacting if tank2temp reaches that temperature.
What I did wrong in the code?

Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int tank1BLED = 37;
int tank1GLED = 39;
int tank1RLED = 41;
int tank2BLED = 43;
int tank2GLED = 45;
int tank2RLED = 47;

// Data wire is plugged into pin 8 on the Arduino
#define ONE_WIRE_BUS 8

// Setup a oneWire instance to
//communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.

DeviceAddress tank1Thermometer = { 0x28, 0x87, 0x57, 0xDB, 0x02, 0x00, 0x00, 0x6F };
DeviceAddress tank2Thermometer = { 0x28, 0x12, 0xB8, 0x5F, 0x04, 0x00, 0x00, 0x86 };
DeviceAddress tank3Thermometer = { 0x28, 0x6A, 0xBD, 0x60, 0x03, 0x00, 0x00, 0xC5 };

int tank1 = 31; // pump control pins
int tank2 = 33; // pump control pins
int tank3 = 35; // pump control pins

float tank1temp = 0;
float tank2temp = 0;
float tank3temp = 0;

void setup(void)
{
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(tank1Thermometer, 10);
  sensors.setResolution(tank2Thermometer, 10);
  sensors.setResolution(tank3Thermometer, 10);
 
 
  pinMode(tank1BLED, OUTPUT); // Tank LED's
  pinMode(tank1GLED, OUTPUT);
  pinMode(tank1RLED, OUTPUT);
  pinMode(tank2BLED, OUTPUT);
  pinMode(tank2GLED, OUTPUT);
  pinMode(tank2RLED, OUTPUT);
   
  digitalWrite(tank1BLED, HIGH); // set Tank LED's off
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
 

lcd.begin(20,4);
// columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear();
// start with a blank screen

pinMode(tank1, OUTPUT); // Tank heaters
pinMode(tank2, OUTPUT);
pinMode(tank3, OUTPUT);

}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  float t1tempC = sensors.getTempC(tank1Thermometer);
  float t2tempC = sensors.getTempC(tank2Thermometer);
  float t3tempC = sensors.getTempC(tank2Thermometer);
  if (tempC == -127.00) {
lcd.print("Err");
} else {
// lcd.print(tempC);
// lcd.print("/");
tank1temp = t1tempC;
tank2temp = t2tempC;
tank3temp = t3tempC;
lcd.print(tempC);
  }
}

void loop(void)
{
  delay(2000);

  sensors.requestTemperatures();
 
lcd.setCursor(0,0);
lcd.print("T1:");

printTemperature(tank1Thermometer);

lcd.setCursor(8,0);
lcd.print("T2:");

printTemperature(tank2Thermometer);

lcd.setCursor(0,1);
lcd.print("T3:");

printTemperature(tank3Thermometer);


if (tank1temp <= 25)
{
  digitalWrite(tank1, LOW); // pump1 ON
  digitalWrite(tank1RLED, HIGH); // read led OFF
  digitalWrite(tank1GLED, HIGH); // green led OFF
  digitalWrite(tank1BLED, HIGH); // blue led ON
}

if (tank1temp >= 26.5 && tank1temp <= 28)

{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}

if (tank1temp >= 28)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}


if (tank2temp <= 25)
{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank2BLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
}

if (tank2temp >= 24 && tank2temp <= 26)

{
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}

if (tank2temp >= 25)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank2, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}


if (tank3temp >= 26 && tank3temp <= 28)
{
  digitalWrite(tank3, HIGH);
}


}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The printTemperature() function is passed an address. Why is it reading that address and all 3 global addresses?

Code:
if (tank1temp <= 25)
if (tank1temp >= 26.5 && tank1temp <= 28)
if (tank1temp >= 28)

if (tank2temp <= 25)
if (tank2temp >= 24 && tank2temp <= 26)
if (tank2temp >= 25)

if (tank3temp >= 26 && tank3temp <= 28)
Your ranges are not exclusive. Is that intentional?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I dont understand what you mean. I need 3 DS18B20 sensors to control three outputs tank1,2 and 3 and leds to.
On outputs I add 5V relays with transistors BC547 and diodes 1N4007. That three relays with switch my contactors for pumps and heaters.

This is working OK:
Code:
if (tank1temp <= 25)
if (tank1temp >= 26.5 && tank1temp <= 28)
if (tank1temp >= 28)

if (tank2temp <= 25)
if (tank2temp >= 24 && tank2temp <= 26)
if (tank2temp >= 25)

But his is not working:
Code:
if (tank3temp >= 26 && tank3temp <= 28)
« Last Edit: January 27, 2013, 03:53:41 pm by kikitron » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I dont understand what you mean. I need 3 DS18B20 sensors to control three outputs tank1,2 and 3 and leds to.
Yes, but each time you call printTemperature() for a specific address, you do not need to read all three sensors. If you are going to read all three each time, then calling the function three times does not make sense.

The function should return a value that the caller stores. There should be no references to global variables in the function.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is working OK:
So, the temperature in tank 1 will never be between 25 and 26.5?

In tank 2, the ranges overlap. Stuff happens in the first block if the temperature is between 24 and 25. Stuff happens in the second block for temperatures in that same range. Is that OK? Stuff happens in the 2nd and 3rd block for temperatures in the range 25 to 26. Is that OK?

Adding a Serial.print() statement just before the tank3temp stuff would confirm the temperature in tank 3. A Serial.print() would confirm whether or not the statement evaluated to true.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Than I have to write a new code?
I dont know how can I read tank1temp, tank2temp and tank3temp differently like i wrote.

I need to write : if (tank1temp >= 25) than power on pump1 and grean led....
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Than I have to write a new code?
To some extent, yes. That's not the end of the world.
void float pringetTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  float t1tempC = sensors.getTempC(tank1Thermometer);
  float t2tempC = sensors.getTempC(tank2Thermometer);
  float t3tempC = sensors.getTempC(tank2Thermometer);
  if (tempC == -127.00) {
lcd.print("Err");
} else {
// lcd.print(tempC);
// lcd.print("/");
tank1temp = t1tempC;
tank2temp = t2tempC;
tank3temp = t3tempC;

lcd.print(tempC);
  }
  return tempC;
}

Then, change printTemperature to getTemperature() in loop, and store the returned value in the appropriate variable.

tank1temp = getTemperature(tank1Thermometer);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will have different temperatures at the end. Now I have lower temerature so I can test it in the room.

At the and should be like that:
Code:
if (tank1temp <= 59)
{
  digitalWrite(tank1, LOW); // pump1 ON
  digitalWrite(tank1RLED, HIGH); // read led OFF
  digitalWrite(tank1GLED, HIGH); // green led OFF
  digitalWrite(tank1BLED, HIGH); // blue led ON
}

if (tank1temp >= 60 && tank1temp <= 62)

{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}

if (tank1temp >= 65)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
}


if (tank2temp <= 35)
{
  digitalWrite(tank1, HIGH);
  digitalWrite(tank2BLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
}

if (tank2temp >= 36 && tank2temp <= 38)

{
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}

if (tank2temp >= 40)
{
  digitalWrite(tank1, LOW);
  digitalWrite(tank2, LOW);
  digitalWrite(tank1RLED, HIGH);
  digitalWrite(tank1GLED, HIGH);
  digitalWrite(tank1BLED, HIGH);
  digitalWrite(tank2RLED, HIGH);
  digitalWrite(tank2GLED, HIGH);
  digitalWrite(tank2BLED, HIGH);
}


if (tank3temp >= 70)
{
  digitalWrite(tank3, HIGH);
}
Logged

NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have another question about LCD that I have it 1602.
The text on it is realy hard to see (very dark), I can see it only from upper angle and on the front you cant see it. Backlight is working ok but text is realy bad.
Do I have to change something in the program that the text will be lighter?

I have QUAPASS 1602A bluescreen and I think that text should be white.

How do you have it wired? Are you using a potentiometer for the contrast like this:
http://arduino.cc/en/Tutorial/LiquidCrystal
« Last Edit: January 27, 2013, 04:40:03 pm by Quick5pnt0 » Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No i didnt use potentiometer. I wired like this:

LCD pin 1 (VSS) -> Arduion pin GND
LCD pin 2 (VDD) -> Arduion pin +5V
LCD pin 3 (VO) -> Arduion pin GND throo 270ohm resistor
LCD pin 4 (RS) -> Arduion pin 12
LCD pin 5 (RW) -> Arduion pin 11
LCD pin 6 (E) -> Arduion pin 10
LCD pin 11 (D4) -> Arduion pin 5
LCD pin 12 (D5) -> Arduion pin 4
LCD pin 13 (D6) -> Arduion pin 3
LCD pin 14 (D7) -> Arduion pin 2
LCD pin 15 (A) -> Arduion pin +5V throo 270ohm resistor
LCD pin 16 (K) -> Arduion pin GND
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanke you @Quick5pnt0 I fixed lcd with potentiometer  smiley-cool

@PaulS I changed the lines that you wrote me but now I dont get temperatures reading on LCD, I see only T1,2 and 3 without temperatures.
« Last Edit: January 27, 2013, 05:03:06 pm by kikitron » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
@PaulS I changed the lines that you wrote me but now I dont get temperatures reading on LCD, I see only T1,2 and 3 without temperatures.
Because I don't think functions should do two things. I renamed the function to getTemperature(). I expect that if you want to print the temperature after you get it, you do that in the function where you call getTemperature(), not in the getTemperature() function. (And, yes, the code you started from was crap.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@PaulS thanke you for all your help.
I was trying to add different codes and I didnt manage to work so I give up  smiley-sad
I think it is too difficult project for me, because Im pure beginner with arduino and certainly code looks crap as my knowledge about programming.

Regards
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was trying to add different codes and I didnt manage to work so I give up
The getTemperature() method, when it was called printTemperature(), used to write the temperature to the LCD. Now, it no longer does. It should be relatively simple to look at the old function, and see where it is writing the temperature to the LCD. Add that function call to loop(), after each call to getTemperature().

Quote
I think it is too difficult project for me, because Im pure beginner with arduino and certainly code looks crap as my knowledge about programming.
I think you choose a project that was too ambitious, and failed to focus on small parts of the project. Reading a temperature is easy. Printing a value on the LCD is easy. Turning pins on and off based on the temperature is easy.

What is hard is trying to do the entire project without understanding anything about programming. I'm sure that if you printed out the code that you have now, and wrote all over the paper, describing what each block of code/function is doing, that you'd see that you have code that does all the "easy" stuff I listed above.

All that is left to do is organize the code in the proper order. I think that giving up at the 99% point is a mistake.
Logged

Pages: 1 [2] 3   Go Up
Jump to: