An A/C Control System

An A/C Control System

This project is a combination of the tasks given in Units 7 and 8 assignments as well as what you have learned in Labs 5 and 6.

  1. Connect a temperature sensor to MSP430 using the scheme given in Lab 6 (you may change the pin though). Connect a 7-segment display to the pins of your choice (using what you have learned in Lab 5). The 7-segment display is used to display the temperature value measured by the temperature sensor in 0F. Connect an LED to mimic a fan. Connect a switch to MSP430 too. Write a program in C which achieves the following tasks:
  2. Initially the 7-segment digits are all off and the switch is at the off position. The system is in a low power mode (mode 3). (10%)
  3. When the switch is turned to the on position, the system leaves the low power mode. This step needs to be done using a Port I/O interrupt.(10%)
  4. For the first 10s, the last two digits of your z-number are shown in the 7-segment display You can realize 10 seconds by a delay routine. (10%)
  5. The program now enters the active mode, every second the program does an A/D conversion. You must use a Timer for the task. (5-7: 40%)
  6. Every 5 seconds an average value of the temperature samples is calculated.
  7. The digital value corresponding to the average temperature is displayed on the 7-segment display once the average temperature is calculated. It is assumed that you have calibrated the system in completing the Unit 8 assignment.
  8. Initially, there is no output to the LED. Assume that the initial room temperature is below 76 0F. (8-11: 30%)
  9. When the average temperature reading is at a level corresponding to 76 0F, a PWM signal (duty cycle = 0.1) is sent to the LED. (At this time, the LED is dim).
  10. The duty cycle changes proportionally to the temperature measured until it reaches 86 0F, at which time, a PWM signal with duty cycle = 0.95 is sent to the LED. Test your circuit using a heating tool to change temperature to above 86 0F. Observe if the system output is correct. (The LED changes its brightness until it reaches the brightest – 95% of the duty cycle). The duty cycle is fixed to 95% when the temperature is above 86 0F.
  11. When the temperature reading is back to below 86 0F and then below 76 0F, the PWM signal becomes smaller and smaller and then disappears. Again observe the corresponding output.

Note: If you complete1-7 you get 70%. If you complete 1-3, 5-6 and 8-11, you get 80%.

Instructions:

• You need to record test results with a video. In the video, you need to:
o Introduce yourself first;
o Explain in detail how the port interrupt is initialized, how Timer A is initialized, how A/D conversion is configured, how PWM is initialized;
o Run the programto show that the system is functional for all the steps described above.
• You need to submit your video link.
• You also need to submit your pin-configurations and code with a Wordpad file.
• You must give explanations for every line of the code you submit.
• YOU MUST DO THE PROJECT YOURSELF.THERE WILL BE NO EXTENSION TO THE FINAL PROJECT SUBMISSION DEADLINE AND NO PARTIAL CREDITS AFTER THE DUE DAY.
Hints:

• Use watch dog timer for display control
• Use Port I/O interrupt for switch input
• Use Timer A for A/D conversion sampling

The main program:

intmain(void)

//Port Initializations
//Port Interrupt for switch at P1.X
//Set edge transition pattern
//Reset port interrupt flags
//Initial setting for the Timer

//Enable interrupt system

//Enter low power mode

//configure ADC

while(1)


    //Set PWM duty cycle depending on the input temperature
    //insert code for PWM

Code for PWM:

P2SEL |= BIT1;
TA1CCR0 = period – 1; //Set PWM for LED at P1.X
TA1CCR1 = period * D;
TA1CCTL1 = OUTMOD_7;
TA1CTL = TASSEL_2|MC_1;

Configure ACD:

voidConfigureAdc(void)

//revise code from Lab 5, SINGLE CHANNEL SINGLE CONVERSION

Port I/O ISR (assume that a pin in port 1 is used):

pragma vector = PORT1_VECTOR

__interruptvoidPORT1_ISR(void)

//Leave low power mode

//Enable WDT for 7-seg display

//Timer_A for timing of A/D conversions; 1 second intervals

//A/D Conversion setup

//display z-number digits

//reset Port I/O interrupt flags

In Timer A interrupt:

pragma vector = TIMER0_A1_VECTOR

__interruptvoidTimer_A(void)

switch(TAIV)

case 0x02: break;
case 0x04: break;
case 0x0A:

    //if the input switch is on, do
     
        //Get an A/D sample, 
        //If 5 samples are collected, take an average and display it.               //Else keep looping for more samples
     
break;

Read AD Samples:
voidgetanalogvalues()

//modify code from Lab 5


Use Watchdog Timer Interrupt for display control:
// WDT interrupt service routine

pragma vector=WDT_VECTOR //define the watchdog timer interrupt vector

__interruptvoidWDT(void)

//modify code given in Lab 5.