MSP 430 Microprocessor Project LaRonda Jones Justin Kopp Benjamin Martin Xu Wang Objectives Our main goals for this project are: • Gain experience in circuit design and development. • Understand the basic procedure for building a simple electronics project. • Learn how to solder fine-pitch circuit elements. • Experience the basics of circuit troubleshooting. • Become familiar with the tools that are used to program a microprocessor. • Be able to make informed decisions when choosing circuit components. • Bring together many of the aspects of Engineering that we have learned so far in order to accomplish a goal. Procedure Our basic procedure for completing the project consisted of the following steps: 1. Purchase a lab kit, and order the parts that are required to complete the project. 2. Determine the order in which the components should be soldered to the board. 3. Complete the soldering on the board. 4. Test the board to make sure that the solder joints are good. 5. Plan the layout of the sensor circuits and build them. 6. Plan how the sensor programs are to function. 7. Complete the sensor programs and calibrate input readings. 8. Write an informative presentation. Difficulties We had some the difficulties that we encountered during this project, but we were able to develop solutions in order to overcome them. • Problem: It was hard to get LCD screen leads into the holes of the circuit board. Solution: Patience, patience, patience…. • Problem: Positioning the microprocessor on the board was a little difficult. It seemed that every time we got it positioned, someone would bump the table. Solution: DON’T BREATHE!!! • Problem: Our AD590 sensor was an 8-pin package. It could not be inserted into a breadboard. Solution: We soldered wires to the sensor and then used the wires to connect the sensor to the board. Team Member Contributions We all helped with the soldering of the board. Each team member at least soldered one side of the microprocessor and a few capacitors. This is the procedure that was given in the project instructions. Aside from the soldering, we each made a contribution to either the program or the presentation: • LaRonda worked on the presentation. • Justin proofread the presentation. • Benjamin wrote the software for the board. • Xu is giving the presentation. Microprocessor The processor that we used was the MSP430 from Texas Instruments. This is a very versatile, lowpower microprocessor. It has an A/D converter that is used to record the output of the temperature sensor. Here are some of the features of the features of the microprocessor: • Ultra low-power architecture. • High-performance 12-bit or 10-bit A/D Converter. • Supply voltage supervisor. • 16-bit RISC CPU. • Compact core design reduces power consumption and cost. • Optimizations for modern high-level programming. • In-system programmable flash memory that allows flexible code changes and data logging. Temperature Sensors We tested two different types of temperature sensors for our project – the AD590 and the AD22103. There are distinct differences between the two sensors, and they each have their benefits and drawbacks • The AD22103 has on-chip signal conditioning. • The AD590 does not have this feature, and a rather complex circuit is required to calibrate the sensor. On the other hand, • The AD22103 only has a measurement range from 0° C to 100° C. • The AD590 has a wider measurement range of -55° C to 150° C. AD590 Temperature Sensor • Two lead sensor that can measure temperatures ranging from -55° C to 150° C. • A temperature-dependent current regulator. • It needs to be calibrated to provide an accurate reading for the A/D Converter on the microprocessor. •An op-amp is needed to amplify the output signal of the sensor so it can be easily read by the A/D Converter. • The AD590 package that we used was an 8-pin package. AD590 Sensor Circuit • The circuit uses potentiometers to calibrate the output of the temperature sensor. • It also uses an op-amp to amplify the output of the temperature sensor so it can be read by the A/D input of the microprocessor. • The presence of the op-amp requires that a scaling factor be used in the program. • Two 9-volt batteries supply power to the op-amp and the temperature sensor. • The circuit is very modular and could in theory be used with another microprocessor. AD590 Sensor Circuit Schematic Modifications of Code for Use with the AD590 Sensor We made a small modification to the sensor code in order to read the temperatures from the AD590 sensor, filter, and display the temperatures. Here are a few of the features of the program: • We implemented a 7 element running-average filter. • The filter uses an array to store the data. This makes the program very efficient. • The program arbitrarily makes the starting temperature 23° C. • A scaling factor is used to compensate for the gain provided by the op-amp. AD590 Sensor Code Part 1 of 3 This section of our code defines the variables and the array that will be used by the interrupt routine of the program. ///////////////////////////////////////////////////////// // // // Filename: Sensor.c (AD590 Version) // // // // Modified by ECE 300 Team #6. // // // // Description: This program controls the sensor // // functions for our MSP430 circuit. It takes // // measurements in Kelvin from the AD590 sensor and // // converts the readings to Celsius and Fahrenheit // // temperatures. The temperature is then displayed // // on the LCD screen. An 7-element array is used to // // filter the incoming measurements, and provide the // // most accurate reading possible. // // // ///////////////////////////////////////////////////////// #include <msp430x44x.h> #include "lcd.h" #include "delay.h" const float A = 0.7099; const float B = 0.2; // Calibration factor. // Amplification correction factor. float total; float CTEMP; float FTEMP; float KTEMP; float temps[7]; float reading; int i; int flag = 0; // // // // // // // // Total of last 7 A to D readings. Temperature in degrees Celsius. Temperature in degrees Fahrenheit. Temperature in Kelvins. Temporary storage for filter. Temporary storage for A to D reading. Counter. Initialization flag. <Begin Code Segment Provided in the Original Sensor.h File> AD590 Sensor Code Part 2 of 3 This part of the code initializes the array for the temperatures and calculates the average of all of the temperatures that have been read so far. <End Code Segment Provided in the Original Sensor.h File> interrupt[ADC_VECTOR] void adc(void) // ADC interrupt service routine { // Initialize the array to store temperatures. if( flag == 0 ) { for( i = 0; i < 7; i++ ) { temps[i] = 296.2; // Set temperatures to a starting point of 23 Deg. C. } flag = 1; total = 2073.4; // Set temperature total to a starting point of 23 Deg. C. } // Check counter and adjust if necessary. if( i == 7 ) { i = 0; } else { i++; } reading = ADC12MEM6 * A * B; // Read in and scale temperature. // Keep a running average of last 7 Kelvin readings. total -= temps[i]; total += reading; temps[i] = reading; KTEMP = total / 7; AD590 Sensor Code Part 3 of 3 After a definite Kelvin reading has been made, this code converts the temperatures and displays them on the LCD screen. // Convert Kelvin temperature to Deg. C and display on LCD Screen. CTEMP = KTEMP - 273.2; lcd_word( 100 * CTEMP, 2 ); lcd_char( 0, 'C' ); wait_ms( 2000 ); // Convert Deg. C to Deg. F and display on LCD screen. FTEMP = ( 1.8 * CTEMP ) + 32.0; lcd_word( 100 * FTEMP, 2); lcd_char( 0, 'F' ); wait_ms( 2000 ); } AD22103 Temperature Sensor • The AD22103 is basically the same as the AD590 sensor, and it has a range of 0° C to 100° C and uses an output voltage. • It has most of the filtering circuit built into the actual sensor. • The code for the circuit board was simplified too. AD22103 Sensor Circuit • The circuit for the AD22103 was much more compact than the one for the AD590 because of the built-in filtering circuit. • In fact, the circuit was small enough to be built directly on the circuit board. • A 1 μF capacitor was added to the circuit in order to provide a little more buffering to the circuit readings. • A wire connects the temperature sensor circuit to the microprocessor. This wire can be disconnected in order to allow the AD590 circuit to be used. AD22103 Sensor Circuit Schematic Modifications of Code for Use with the AD22103 Sensor • Due to the simplicity of the AD22103 sensor circuit, there were not many changes that we needed to make to the code in order for it to work. • Our program just reads the output of the sensor and displays the results. • A scaling equation is given in the data sheet, but we had to tweak it a little in order to get it to work properly. • This code is designed to work with at least 3.3 V as the input voltage. If another voltage is used, the temperature sensor will have trouble reading the correct temperature. AD22103 Sensor Code Part 1 of 2 This part of the code defines all of the variables and scaling factors for the program. ///////////////////////////////////////////////////////// // // // Filename: Sensor.c (AD22103 Version) // // // // Modified by ECE 300 Team #6. // // // // Description: This program controls the sensor // // functions for our MSP430 circuit. It takes // // measurements in Celsius from the AD22103 sensor // // and converts the readings to degrees Fahrenheit. // // The temperature is then displayed on the LCD // // screen. No filter is needed for this program // // because there is already a signal conditioning // // circuit in the sensor. // // // ///////////////////////////////////////////////////////// #include <msp430x44x.h> #include "lcd.h" #include "delay.h" float CTEMP; float FTEMP; // Temperature in degrees Celsius. // Temperature in degrees Fahrenheit. <Begin Code Segment Provided in the Original Sensor.h File> AD22103 Sensor Code Part 2 of 2 This part of the code reads in the output of the sensor and displays it on the screen. Note that there is not a filter in this code. <End Code Segment Provided in the Original Sensor.h File> // ADC interrupt service routine interrupt[ADC_VECTOR] void adc(void) { // Read in and scale temperature. CTEMP = ( ( ( ADC12MEM6 * ( 2500.0 / 4096.0 ) ) – 250.0 ) / 28.0 ) – 0.25; // Display Celsius temperature on LCD Screen. lcd_word( 100 * CTEMP, 2 ); lcd_char( 0, 'C' ); wait_ms( 2000 ); // Convert Deg. C to Deg. F and display on LCD screen. FTEMP = ( 1.8 * CTEMP ) + 32.0; lcd_word( 100 * FTEMP, 2); lcd_char( 0, 'F' ); wait_ms( 2000 ); } The Completed Circuit Board Conclusion • This project was very enjoyable, and we all learned a lot from it. • We were able to complete all of our objectives, and the results of the project were very good. • The skills that we gained from this project will help us throughout the rest of our professional careers. Most Importantly WE ALL HAD FUN! Questions?