Sunday, 17 March 2013

FYP 2 Week 8

I still cannot come up with the code that works for my project. I try to combine the circuits and the coding but the results always not as what I expected. Because of this, I done some researching of the limitation of this project.

This project, if modified to be a cooling system for human can only work effectively in a small room. This is because the temperature in one room could change easily and the heat sensor could not pick up the sudden change of temperature thus making the fan speed remain the same. The temperature change and the area of the room is the factors here in making the automatic temperature controlled fan speed working effectively. It is also work best for cooling the electrical equipment or machines since it has a more efficient power consumption compared to air conditioner.

Saturday, 9 March 2013

FYP 2 Week 7

I still struggling to find functional code that works for my project. In the meantime, I was studying the PWM function with Arduino again.



Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.


In the graphic below, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.






I also learned how to combine together the code for temperature sensor and the code for PWM. For example:






Code for temperature sensor:






#include <LiquidCrystal.h>

float tempC;

float tempF;

float voltage;

int reading;

int tempPin=0; //analog channel

int interval = 50; //in ms (how often screen reprints

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {

// set up the LCD’s number of rows and columns:

lcd.begin(20,4);

// Print a message to the LCD.

lcd.setCursor(0,1);

lcd.print("Cabinet Temperature:");

}

void loop() {

//TMP36 voltage at the output varies linearly with ambient temperature.

//As a result,it can be used as a thermometer according to the equation:

// ᵒC = (Vout(V) - .5)*100

//To find Vout in V, we use the following equation for a 5V input

// Vout(V) = AnalogReading*(5/1024)

reading = analogRead(tempPin); //read the value from the sensor

voltage = reading*(5.0/1024); //convert reading to voltage (in V), for 5V input

tempC = (voltage-0.5)*100; //convert voltage to temperature

tempF = ((tempC*9/5)+32); //convert C temperature to F

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 2);// set the cursor to column 0, line 1

lcd.print(tempF); //Print Fahrenheit temperature to LCD

lcd.print((char)223); // degree symbol

lcd.print("F ");

lcd.setCursor(0,3); //print set temp to lcd

lcd.print("Set Temp: 80 ");

lcd.print((char)223);

lcd.print("F");


}






Code for PWM fan:






// Define which pin to be used to communicate with Base pin of TIP120 transistor

int TIP120pin = 3; //for this project, I pick Arduino's PMW pin 3

void setup()

{

pinMode(TIP120pin, OUTPUT); // Set pin for output to control TIP120 Base pin

analogWrite(TIP120pin, 255); // By changing values from 0 to 255 you can control motor speed

}


void loop()

{

}





Code for combined circuit:



#include <LiquidCrystal.h>

float tempC;

float tempF;

float voltage;

int reading;

const int tempPin = 0; //analog channel

const int TIP120pin = 3; //for this project, I pick Arduino's PMW pin 3

const int interval = 50; //in ms (how often screen reprints

const int setPointF = 80;


// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);


void setup() {

// set up the LCD’s number of rows and columns:

lcd.begin(20,4);

// Print a message to the LCD.

lcd.setCursor(0,1);

lcd.print("Cabinet Temperature:");

pinMode(TIP120pin, OUTPUT); // Set pin for output to control TIP120 Base pin

}

void loop() {

//TMP36 voltage at the output varies linearly with ambient temperature.

//As a result,it can be used as a thermometer according to the equation:

// ᵒC = (Vout(V) - .5)*100

//To find Vout in V, we use the following equation for a 5V input

// Vout(V) = AnalogReading*(5/1024)

reading = analogRead(tempPin); //read the value from the sensor

voltage = reading*(5.0/1024); //convert reading to voltage (in V), for 5V input

tempC = (voltage-0.5)*100; //convert voltage to temperature

tempF = ((tempC*9/5)+32); //convert C temperature to F

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 2);// set the cursor to column 0, line 1

lcd.print(tempF); //Print Fahrenheit temperature to LCD

lcd.print((char)223); // degree symbol

lcd.print("F ");

lcd.setCursor(0,3); //print set temp to lcd

lcd.print("Set Temp: 80 ");

lcd.print((char)223);

lcd.print("F");


// If the temperature is highher than the set point, run the fans.

// Fans reach full speed then temperature is more than 10°F above setpoint.

analogWrite(TIP120pin, constrain( (tempF - setPointF) * 25, 0, 255));

}




With this examples I will try to come up with new code that can work for my project.

Sunday, 3 March 2013

FYP 2 Week 6

This week I was attempting to combine the codes of temperature sensor and PWM so that the fan will move according to temperature. Unfortunately, I can't find the code that is functional for my project. Here is the example of the code I was using:


#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int inPin = 0;
int pwmPin = 9;      //digital pin 9
int pwmVal   = 10;

void setup()
{
  lcd.begin(16, 2);
  pinMode(pwmPin, OUTPUT);   // sets the pin as output
  Serial.begin(9600);
}

void loop()
{
  int value = analogRead(inPin);
  lcd.setCursor(0, 1);
  float milivolts = (value/1024.0)*5000;
  float celsius = milivolts/10;
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(celsius);
  lcd.print("Celsius");
  lcd.setCursor(0, 1);
  lcd.print((celsius*9)/5 + 32);
  lcd.print("Fahrenheit");
  delay(10000);

  if (pwmVal != 255) {
         analogWrite(pwmPin, pwmVal);
         //pwmVal += 10;
         Serial.print(pwmVal);  // Print red value
         Serial.print("\n");    // Print a tab
  } else {
         Serial.print('at max high');  // Print red value
         Serial.print("\n");    // Print a tab
  }
  delay(1000);
}


When I used this code, only the temperature sensor part work, the fan doesn't move. I still need to understand how to code in Arduino better to make sure my project functions as I desired.

Sunday, 24 February 2013

FYP 2 Week 5

For this week, I was researching what fan should I use for my project. I plan to use DC Fan that is small and portable so that it won't be cumbersome to present on the presentation day. DC fan also easier to be programmed with Arduino compared to AC fan. I decided to use 12V DC Fan. I will be using 9V battery as the power supply and the transistor I use will amplify the power and can make the fan move even the power supply is not 12V.

Saturday, 16 February 2013

Mid semester break

Although it is semester break, I still attempting to test the pulse-width modulation (PWM) function of Arduino. This part is needed to move the fan with a variable speed in my project. After I search the internet, I found the simple code to test PWM with a DC motor. The DC motor speed can be manipulated with the variable resistor. This is the code:


int motor = 9;
int potenciometer = 5;

void setup(){
  pinMode(9,OUTPUT);
  pinMode(5,INPUT);

  Serial.begin(9600);
}

void loop(){
  int value = analogRead(potenciometer);
                     //read input value: range between (0,1023)
  int motor_speed = value/4;
                    //PWM can only ouput 255 different values

  analogWrite(motor,motor_speed);

  Serial.println(motor_speed);//for testing purposes
}


This is the connection I use to construct on breadboard.

Fortunately, the code works when I tested on breadboard and the results were true as what was expected.
This is before I tune the variable resistor. As you can see, the motor doesn't move.

In this picture, the motor move after I tune the variable resistor. If I tune it all the way, the motor will move to its maximum speed.

For this testing, I used the components DC motor 3V, Variable Resistor 10kΩ, Transistor TIP120, Diode 1N4001, resistor 330Ω and the Arduino microcontroller.

Sunday, 10 February 2013

FYP 2 Week 4

Now that I learned about the temperature sensor LM 35, it's time to test it on breadboard.  Since I use Arduino microcontroller, I learn how to use LM 35 with Arduino from the internet so that I can understand how does it function. To test it, we also need LCD display to show the temperature values. Below is the connection of Arduino and temperature sensor and the code I used to test the temperature sensor


This is on my own breadboard. It seems the temperature sensor functions as supposed to be.


Saturday, 2 February 2013

FYP 2 Week 3

LM 35 Temperature Sensor



The LM35 is an integrated circuit sensor that can be used to measure temperature with an electrical output proportional to the temperature (in oC)


  • Why Use LM35s To Measure Temperature?
    • You can measure temperature more accurately than a using a thermistor.
    • The sensor circuitry is sealed and not subject to oxidation, etc.
    • The LM35 generates a higher output voltage than thermocouples and may not require that the output voltage be amplified.
Below is the typical performance characteristics of LM35 Temperature Sensor:


So based on the performance characteristic of this temperature sensor, I am confident to choose it since it has good sensitivity and it is also very affordable.