NPEDUCATIONS, Electronic circuits development, electronics tutorials, microcontroller tutorials and projects, advanced microcontroller (ARM) based tutorials and projects, Embedded c development, Embedded c for ARM cortex M, Intel IoT based projects, IoT projects, CC3200 launch pad projects, MSP430 Launchpad tutorials and projects, Tiva C launch pad tutorials and projects, 8051 tutorials and projects, sensor interfacing with microcontroller tutorials, data communications and networking tutorials, peripheral interfacing with microcontroller, led message scrolling display, arduino based tutorials and projects, intel galileo based tutorials and project, ADC interfacing tutorials, LED Blinking, LCD interfacing, Embedded System tutorials and projects, B.tech projects, M.tech projects, online Embedded C training

Automatic FAN control system based on room temperature using MSP430 – Project


Introduction:
In this project, a FAN (12V DC motor in this context) speed can be controlled based on the room temperature. If the room temperature increases, then the fan speed automatically increases. Similarly, if the room temperature decreases, then the fan speed automatically decreases.


To sense the room temperature, we require a temperature sensor LM35 which is readily available in the market. But here I was developed the project by using MSP430G2553 Microcontroller from Texas Instrument Company. The MSP430G2553 is a wonderful 16-bit microcontroller which comes with a lot of features like USCI (Universal Serial Communication Interface: UART, SPI, I2C protocols), in-built multi channel ADC, Low Operating Voltage (3.3V), Low power operation with lower power modes, in-built configurable clock circuit, in-built temperature sensor. Especially, the last feature in-built temperature sensor makes me to use this microcontroller in this project, because MSP430G2553 comes with low cost with all these built-in features. If I go for regular 8051 microcontroller or any other, I have to buy ADC and external temperature sensor (LM35) which will increase my project cost. 

Circuit Diagram:
Circuit Diagram Automatic FAN control system based on room temperature using MSP430 – Project
Circuit Explanation:
In the above circuit, the 3.3V supply can be achieved by connecting simple 3.3V Zener diode between the Vcc and Gnd lines of MSP430. Don’t touch the zener diode when the power supply is switch ON, because the zener get heated up.  Connect a 47k ohm resistor and 1nf capacitor serially between the Vcc and Gnd lines, connect the node at which capacitor and resistor joined to the reset pin of the MSP430 MCU and the switch S1 is the reset switch connected across the capacitor.
The Port pin P1.6 connected to the ULN2803 input and its corresponding output is connected to the one end of the DC motor. The other end of the DC motor is connected to the 12V power supply.
When the state of P1.6 pin is High, the ULN2803 input pin also high, then the corresponding output of the ULN2803 is connected to ground via 500mA fuse. Now the current entering into the motor from source 12V supply will finds a path to sink into the ground via ULN2803 output line (500mA) and the motor start rotating proportional to the current flowing through it.
Don’t worry about the clock circuit, MSP430 itself contain clock circuit internally. I encouraged you to read the article “Understanding the basic clock system inMSP430

Operation:
With the help of in-built temperature sensor, the circuit can sense the room temperature. The analog temperature variation is converted to digital by using in-built ADC10 mechanism of MSP430.
          TEMP_in_Deg = ((ADCDATA * 1500)/1024 - 986)/3.55;

Use the above formula in your firmware, to convert the raw ADC temperature variation values into degrees centigrade.
For more detail regarding these Temperature conversion – read “TI MSP430g2553 ADC tutorial -Part1

Now generate a PWM signal on P1.6 pin of MSP430 to drive the DC motor via ULN2803 High current sinker (~ 500mA). Because we know the fact that “The DC motor speed is directly proportional to the width of the PWM signal”. Means if the ON duration (duty cycle = Ton/(Ton + Toff)) of PWM signal is more, current flowing through the motor winding is more and reaches the maximum value. Hence the speed of the motor will increase. Similarly, if the ON duration is less, motor speed will decrease.

Now add each and every ‘TEMP_in_Deg’ value to the ON period of the PWM signal in your firmware code. Automatically the DC motor increases the speed w.r.t to the increase in temperature. Similarly, it will decrease the speed if the temperature decreases.

Program Code Explanation:

Up on reset, the DCO clock source with 1.2MHz frequency acts as default source for MCLK and SMCLK clock signals. Here ACLK is not applicable because we haven't initialized the clock settings of MSP430 using Basic control control registers(BCSCTLx). So you people won’t find any MSP430 basic clock settings in this program expect at time of PWM initialization.

1. ADC initialization:

ADC10CTL0 = ADC10SHT_3 + SREF_1 + REFON + ADC10ON;

For commercial range of temperature, the Voltage across the temperature sensor will not exceed 1.4V. Hence a reference of 1.5V is choosen. Choosing 1.5V reference voltage for the internal temperature sensor by using the bit REFON = 1, SREF = 1 and REF2_5V = 0.The internal ADC10 will get enabled only when ADC10ON bit is chosen. The ADC10SHT_3 is used to select sample and hold time for the ADC10 which is 64XADC10CLKs.

ADC10CTL1 = INCH_10 + ADC10DIV_3;

      The internal temperature channel can be selected by using INCH_10 option and the ADC10DIV_3 will divide the default ADC clock by 8.

            _delay_cycles(30);
A delay of 30 microseconds will require by the reference voltage to settle

2. PWM Initialization

TACTL = TASSEL_1 + MC_1;                

The default clock for timer is TACLK, if TASSEL_1 option is selected in the (Timer A control register) TACTL then TACLK is driven by ACLK (TACLK = ACLK (12000hz)). And the timer mode is set to up mode, means the timer values automatically incremented until it reaches capture register value. After it immediately falls to zero. Here I encouraged you to read article Understanding Timers in MSP430 Launch pad

TACCR0 = 1000-1;                        

PWM Period (total PWM period = 12000 clock cycles of VLO), each clock cycle takes 1/12Khz. Therefore PWM period is 1 second -- TACCR0 is used to load PWM period.

           TACCTL1 = OUTMOD_7;
     OUTMOD_7 option is used to make the output automatic set and reset.
    
                TACCR1 = 500-1;
     Setting the Duty cycle to 50% -- Ton/(Ton+Toff) = Clock freq/count = 1000/500 = 1/2 = 50.
    
Note: Every time when the temperature is increases come value is added to this TACCR1 in the infinite loop, so that the duty cycle may increase or decrease in turn control the speed of the DC motor.

3.   Infinite Loop:
    
                   if(currTemp > prevTemp + 2)
                    {
                    TACCR1 = tempInDeg*20 -1;
                          prevTemp = currTemp;
                    }
                    if(currTemp < prevTemp + 2)
                    {
                    TACCR1 = tempInDeg*20 -1;
                        prevTemp = currTemp;
                    }
In the infinite while loop, after ADC conversion, the raw ADC sample is converted in degree centi-grades. Now this value multiplied with some number (20 in this case) and then added to the TACCR1 register to change the duty cycle.
For more detail about the ADC sampling and conversion go to the articles









<>

/*************************************************WELCOME TO NPEDUCATIONS ****************************************************
 * Author : kiranvarma
 * http://www.npeducations.com
 * http://www.npprogrammers.com
 * http://www.npfoods.com
 ******************************************************************************************************************************/

#include
long tempInDeg;
long prevTemp = 0;
long currTemp = 0;

//MAIN PROGRAM
void main(void)
{
	// Stop Watch Dog Timer
 		  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

 	// select the P1.6 as the PWM output
		  P1DIR |= BIT6 ;
		  P1SEL |= BIT6 ;
		  P1OUT = 0x00;


	// ADC initialization

		  ADC10CTL0 = ADC10SHT_3 + SREF_1  + REFON + ADC10ON;

	 	  ADC10CTL1 = INCH_10 + ADC10DIV_3;

	 	  _delay_cycles(30);

	// PWM initialization
		  TACTL = TASSEL_1 + MC_1 ;
		  TACCR0 = 1000-1;
		  TACCTL1 = OUTMOD_7;
		  TACCR1 = 500-1;

			while(1)
			{
			    ADC10CTL0 |= ENC + ADC10SC;             // Sampling and conversion start
			    while (ADC10CTL1 & ADC10BUSY);          // check for ADC conversion is completed

			    tempInDeg = (((ADC10MEM - 673) * 423) / 1024) - 10;
			    currTemp = tempInDeg;
			    if(currTemp > prevTemp + 2)
			    {
			    	TACCR1 = tempInDeg*20 -1;
	                prevTemp = currTemp;
			    }
			    if(currTemp < prevTemp + 2)
			    {
			    	TACCR1 = tempInDeg*20 -1;
			        prevTemp = currTemp;

			    }

			    _delay_cycles(1000);

		  }

}

2 comments :

  1. how to DISPLAY TEMPERATURE IN LCD ...IN ABOVE PROGRAM?...PLEASE HELP ME WITH PROGRAM

    ReplyDelete
  2. if(currTemp > prevTemp + 2)
    {
    TACCR1 = tempInDeg*20 -1;
    prevTemp = currTemp;
    }
    if(currTemp < prevTemp + 2)
    {
    TACCR1 = tempInDeg*20 -1;
    prevTemp = currTemp;

    }

    _delay_cycles(1000);


    for temperature higher and temperature lower than....
    you hacve used the same set of codes can you help me understand what you did in that part?

    ReplyDelete

Thanks for visiting NPEDUCATIONS. We will contact you soon

2 comments :

Nagaraju Mandru said...

how to DISPLAY TEMPERATURE IN LCD ...IN ABOVE PROGRAM?...PLEASE HELP ME WITH PROGRAM

Aashrai Puthran said...

if(currTemp > prevTemp + 2)
{
TACCR1 = tempInDeg*20 -1;
prevTemp = currTemp;
}
if(currTemp < prevTemp + 2)
{
TACCR1 = tempInDeg*20 -1;
prevTemp = currTemp;

}

_delay_cycles(1000);


for temperature higher and temperature lower than....
you hacve used the same set of codes can you help me understand what you did in that part?

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.
Related Posts Plugin for WordPress, Blogger...

 
Powered by Blogger