Upload
vudieu
View
216
Download
2
Embed Size (px)
Citation preview
Mobile power station --- Phase IIDesign Document
Project Team:Mengqian DingDixiao JiangVermaAvinav
Faculty Advisor:
Dr. Ayman Fayed
Client:
PowerFilm, Inc.
Dec./3/2011
Iowa State University
College of Engineering
1
Index1. Introduction of Background........................................................................................................................3
2. Problem Statements...................................................................................................................................3
3. Functional requirements............................................................................................................................4
4. Non- functional requirements....................................................................................................................4
5. Previous Concept diagram..........................................................................................................................5
6. Li ion Battery charging cycle.......................................................................................................................5
7. Theflow chart of the project.......................................................................................................................6
8. The major problems we going to deal are as following:..............................................................................7
a. Better and cheaper microprocessor...........................................................................................................7
b.Better MPPT (Maximum Power Point) algorithm...........................................................................................8
c. Better high side current sensor document.................................................................................................9
9. Buck Converter.........................................................................................................................................12
10. Communication board............................................................................................................................12
11. Circuit design and PCB layout.................................................................................................................14
Microcontroller mapping................................................................................................................................15
The schematic of our PCB board..................................................................................................................... 16
PCB Board picture1..........................................................................................................................................17
PCB board with components value..................................................................................................................18
12. Solar cell................................................................................................................................................19
13. Battery and Battery Monitor...................................................................................................................19
14. Implement and Test...............................................................................................................................20
Buck_Control and MPPT test...........................................................................................................................20
Transmit data test........................................................................................................................................... 21
Final circuit test:.............................................................................................................................................. 22
15. Microcontroller Code:............................................................................................................................23
Main function:................................................................................................................................................. 23
MPPT function................................................................................................................................................. 26
Buck control function...................................................................................................................................... 27
ADC Function................................................................................................................................................... 27
PWM function................................................................................................................................................. 29
Display data function.......................................................................................................................................30
transmit in function.........................................................................................................................................32
16. Components list we have buy:................................................................................................................34
17. Cost estimate.........................................................................................................................................35
2
18. Project schedule.....................................................................................................................................35
19. Reference...............................................................................................................................................36
1. Introduction of BackgroundThis is a continuous project of previous one, and the previous project about mobile power station has finished successfully.
We need more and more mobile power nowadays since the improvement of mobile technology that makes it surrounding us in every single aspect of our lives. Flexible solar panels are lightweight and can offer ultimate portability; however, there is a significant problem while charging mobile devices directly from flexible solar panels. Most portable electronics are very sensitive to fluctuations in voltage and current and will cease charging if either is sensed, which is likely to happen with a variable power source such as a solar panel. To solve this problem, previous senior design team is designing a Mobile Power Station (MPS) that will essentially be the missing link between the flexible solar panel and mobile electronic devices. The MPS will supply a constant source of power in order to charge mobile electronics, and it will charge from a solar panel or constant power source, offering maximum flexibility. Cutting edge circuitry and algorithms will maximize MPS efficiency.
2. Problem Statements
Our task in this project is to do some improvements in the previous project’s final result, and makes the result more efficiency and in lower cost.
The major things we need to improve are:a. The current microprocessor used in the previous project is MSP430f2013,
which runs at 13MHz with 2kB of flash memory and 12-bit ADCs, and our job is to use a more powerful processor that will have a higher operating frequency, more flash memory, and more integrated ADCs to enable sensing more signals in the system.
b. The overall cost of the implementation needs to be reduced by using cheaper components, which could be used to replace the previous ones.
c. The MPPT (Maximum power point tracking) algorithm needs to be improved to avoid being stuck in local maxima.
d. Using Li-Ion Phosphate battery instead of traditional Li-Ione. An additional buck converter to produce 5V-USB power, and here is one extra
task for this project.
3
3. Functional requirementsFR 01 Optimized for standard solar panel input – 4A @ 15V (60W) Amorphous Silicon Panel.FR 02 Processor MSP430F5152 with 25MHz processor speed and 16KB flash memoryFR 03 100W minimum (Li-In-F-P-O-4) battery capacityFR 04 12V DC input (with AC-DC Adapter)FR 05 5V DC input (micro-USB)FR 06 5V USB output (Fulfilling Standard for USB 2.0 output)FR 07 12V DC outputFR 08 120V AC output with switch to be able to turn off inverter when not in useFR 09 Circuitry must be able to function in a temperature range of -20° C and 60°CFR 10 Charging LED Indicators/state of charge indicatorsFR 11 MPPT Charge controller with rating of up to 200W (12A @ 15V – PowerFilm Solar Quad)FR 12 Charge Balancing Circuitry to keep Li-Ion Batteries balanced to prevent over or under chargingFR 13 Temperature sensor for batteries with alarm LEDFR 14 Achieve 90% or greater efficiency on all outputsFR 15 Safety fuses or circuits breakers on all outputs
4. Non- functional requirementsNFR 01 The MPS shall be designed mainly for military soldier and commercial use.
NFR 02 Unit should be manufactured as cheap as possible for each unit.
NFR 03 The unit should easily fit inside a military backpack.
4
5. Previous Concept diagram
Figure1. MPS block diagram
6. Li ion Battery charging cycle
Figure2. Li-ion charging cycle
To charge the battery, there is battery cycle. First implement constant current charging; then implement constant voltage charging.
5
7. The flow chart of the projectUsing low side current and battery sensor, we can read current and voltage from battery. With these data, we can decide charging stage. Then we use PWM wave and buck converter to implement constant current charging or constant voltage charging (depend on charging stage)
Using high side current and voltage senor, we can get the current and voltage data from solar panel.We need Max Point Power Algorithm (MPPT) and PWM wave and buck converter to tracking the point that solar voltage * solar current (power supplied by solar panel) reach maximum.
Figure3. Project Flow Chart
6
8. The major problems we going to deal are as following:1. The current microprocessor used is MSP430f2013, which runs at 13MHz with 2kB of flash memory and 12-bit ADCs (Not sure how many). We would like to upgrade it to a more powerful processor that will have a higher operating frequency, more flash memory, and more integrated ADCs to enable sensing more signals in the system.
Possible solution: We go to search for Internet to find more powerful processor and consider the cost. We will anticipate in the TI circuit competition, it’s possible for us to get some free chip. For the programming, we any have basic still on embed system. So we need to independent study more about C program, ask some CprE peers to help us and search on Internet to find certain solution.
2. The other thing we need to consider is track the max point voltage accurately. The MPPT algorithm needs to be improved to avoid being stuck in local maxima.
Possible solution: We are going to search for some IEEE paper about the algorithm of tracking the max power point.
3. Using Li-Ion Phosphate battery instead of traditional Li-Ion
Solution: that can be provided by our costumer, Solar Film.
4. Make high side current sensor more accurate
Solution: we are going to do some research to find out why the high side current sensor is inaccurate.
a. Better and cheaper microprocessorAccording to the previous project, the MSP430f2013 MCU, which runs at 16MHz with 2kB of flash memory and 4 -16bit ADCs has good performance, however, we want a higher performance microprocessor in our project. The requirements of new microprocessor are:
higher operating frequency more flash memory more integrated ADCs to enable sensing more signals
7
Figure4. Compare MCUs
To program the microcontroller on computer, we use the Code Composer Studio (CCS), which is a special software to program microcontroller provided by TI.
Figure5. CCS programming environment
b.Better MPPT (Maximum Power Point) algorithm Maximum power point tracking is a system that tries to modify the electrical operation point of a solar energy to make shore it generates the maximum power. This operation involves finding the current and voltage of the solar panel at which maximum power can generate. The system can improve the overall performance of the electrical efficiency of a solar energy system, for example reducing the number of solar panels or arrays required to generate a desired output. In the MPPT there are many kinds of algorithm which people have made and the performance depends on the cost , convergent speed and what kind of the sensor are used. Making these things in consideration, we have decided to use the dP-P&O Algorithm for our project.
8
Figure6. MPPT algorithm
Figure7. dP-P&O Algorithm
dP-P&O method is an improvement of P&O algorithm and it can prevent it from tracking wrong direction in rapidly change irradiance. To avoid doing that this method tries to measure additional MPPT sampling period in the middle which is shown above without any perturbation. The value of Px and Pk+1 only reflect the change in power due to the environmental changes. For difference between px and k contains the change in the power caused by the perturbation of the MPPT plus the irradiation change. So basically we can derive the equation of dP = dP1 – dP2 = (Px – Pk) – (Pk+1 – Px) = 2Px – Pk+1 – Pk. The dP equation shows the reflect change in the due to the perturbation of the MPPT algorithm and it is used in the top of the block diagram for the modified method of P&O. The rest of the block diagram is same concept as P&O method. This is the method we are going to program in the processor.
c. Better high side current sensor documentCurrent sensor analysis:
9
Figure8. Current senseThis circuit is a variation on the “classic” high-side cir-cuit, but takes advantage of Over-the-Top input capability to separately supply the IC from a low-voltage rail. This provides a measure of fault protection to downstream circuitry by virtue of the limited output swing set by the low-voltage supply. The disadvantage is VOS in the Over-the-Top mode is generally inferior to other modes, thus less accurate. The finite current gain of the bipolar tran-sistor is a source of small gain error.
Simulation of Rs from 0.01 to 0.2 ohms >> RS=[0.01: 0.01: 0.2];
>>Iactual = (2.4/3.6 + 1.8*10^-3)./RS
>>Ical = (2.4/3.6)./RS
plot(RS,(Iload - Ical)*1000)
10
Include consideration of resistance variation: R_V = [-0.1: 0.01 : 0.1];
RA = 200.*[1+R_V];
RB = 20.*[1+R_V];
RS = 0.2.*[1+R_V];
Iload = (1./(RA./RB) + 1.8*10^-3)./RS;
Ical = (1./(RA./RB))./RS;
error = (Iload - Ical)*1000;
plot(R_V, error)
Including the variance of resistance ( from -10% to 10%)
Rs = 0.04 ohm: Rs = 0.08 ohm:
Rs = 0.1 ohm: Rs = 0.2 ohm
So we choose Rs = 0.06 ohm. We think this resistor can solve the problem of inaccurate high side current sensor.
11
9. Buck ConverterThe buck converter is a step down DC to DC convertor which is mostly used in the power electronics. In this project we are going to use buck converter as a controlling voltage from solar cell and sent it to a battery with specified constant voltage. To get the specific voltage from the solar cell, we are using PWM signal to match the voltage with Vref voltage. Once (Vin = Vref) then it will try to charge it to the battery. To make the PWM signal those two switches Q1 and Q4 in the figure tries to create duty cycle for the circuit and to control the PWM signal we are using microprocessor. Figure:
To maximize efficiency we used the following equations to calculate ripple current and ripple voltage.
T sw = switching period Ripple Current: ∆ I=(V ¿−V out)∗dT sw
L
d = duty cycle Ripple Voltage:∆ V = (1−d )∗Vo8∗C∗L∗f sw
2
10. Communication boardWe want to send data from MSP430 Target board to computer, so we can reflect our microcontroller’s data on GUI. With this data, we can check our C code program and monitor our circuit.
After doing some research on websites, we find our way to that. It needs a FT232 chip to connect to USB on computer.
RS232 is a common connection between PC and devices, and it can be easily converted to RS232 using a level converter. Another popular solution is to connect the UART of the MSP430 to a USB to UART converter such as the FT232RL and FT2232 from FTDICHIP. These ICs creates a virtual COM port on the host machine that allows you to seamlessly transfer bytes between the host machine and the MSP430.
12
The MSP430F1611 includes two USART modules, USART0 and USART1. Both are capable of using UART independently of each other.
The UB232R requires USB drivers, available free from http://www.ftdichip.com, which are used to make the FT232R on the UB232R appear as a virtual COM port (VCP). This then allows the user to communicate with the USB interface via a standard PC serial emulation port (TTY). Another FTDI USB driver, the D2XX driver, can also be used with application software to directly access the FT232R on the UB232R though a DLL. This is illustrated in the Figure 1.1
13
11. Circuit design and PCB layoutMajority parts of the circuit is same as previous one, but we change different kind of microcontroller MSP430f5152, which has much more pins that MSP430f2013. This makes the connection so complicated and it takes us a lot of effort to do that. Besides, we can’t find some components in CSG and DigKey web sites, so we change a lot of components on it.
14
Microcontroller mapping
Figure9. MCU mapping
We set:pin1 LED controlpin2 solar current sensorpin3 solar voltage sensorpin4 battery current sensorpin5 battery voltage sensorpin6 load current sensor
pin26 VSS DC groundpin27 VDD DC VCCpin35 generate PWM signal
15
The schematic of our PCB board
Figure10. Schematic of PCB
16
PCB Board picture1
Figure11. PCB board
17
PCB board with components value
Figur12. PCB board component value
18
12. Solar cellFor solar cell, we used what the costumer provided: 20 watt foldable solar charger.
Ficur13. A 20 watt foldable solar charger
This charger cost around 80 $.
13. Battery and Battery MonitorTo test the circuit, we use Tenergy high discharge Li polymer battery as the target battery to charge. We use TI bq20Z70 with EV2300 to monitor the battery charging.
Figure14. Battery and EVM
19
Figure15. The interface of BQ20z70
14. Implement and Test
Buck_Control and MPPT testThe major part of the code should implement the function that read value (voltage or current) from input pin to ADC; then according to the value we get, microcontroller will generate different PWM wave form to control buck converter.
Notice that when the input voltage is low, the PWM wave form is “thin”; when the input voltage is high, the PWM wave form is “wide”. So the changing of PWM form will follow the change of the input signal.
20
Transmit data testWe want to transmit the data that microcontroller read (such as solar voltage, solar current, battery voltage, battery current) to computer, so we can monitor the charging stage.We need use BR232 to transmit data and software Putty to read data.
Connect evaluation board and BR232, Can transmit data from microcontroller to computer.
Then set the controlling local serial lines, the port information is in the device manager. The baud rate, data bits, stop bits and parity set can be found in the MSP430 manual. We choose the baud rate to be 9600.
21
Original data transmit edited data transmit
Then we can see data transmit from microcontroller to computer. However, after some good data, there is some garbage signal. We think that’s due to the noise of the MSP430. So we decide to close the pin after the data transmitted. If we want to transmit again, then reopen the pin. In this way, the noise is significant reduced.
Final circuit test:After we build the staff above, we connect them trying to test integrated circuit. However, we can’t saw the response of the bq20z40 (the battery charging control interface). We think that’s due to the PCB or the connection between the EVM and computer. We don’t have time to rebuild a PCB board. We would try to rebuild it when this semester is finished.
22
15. Microcontroller Code:
Main function: #include "msp430f5172.h"
#include "ADC.h"#include "PWM.h"#include "buck_control.h"#include "mppt.h"
void transmit_int(unsigned int number);void display_data(void);
//#define PWM_MIN 48 //20% duty cycle//#define PWM_MAX 228 //95% duty cycle#define A_100MAbat 1261 //100mA, tuned for PCB#define A_100MAload 2506 //100mA, tuned for PCB#define V_126V 9542 //12.6V, tuned for PCB#define V_125V 9465 //12.5V, tuned for PCB#define V_9V 6757 //9V, tuned for PCB
char charging_state =0; //0:trickle; 1:mppt; 2:constant voltage 3: shutdown//char ADC_complete =0;//char pwm_limit=0;signed int state_advance =0; // state advance counter//char pwm_up=1; //direction of pwm, use for mppt
unsigned int bat_voltage=0; //voltage of battery packunsigned int bat_current=0; //current through battery packunsigned int load_current =0; //current through loadunsigned int solar_voltage=0; //voltage of solar cellunsigned int solar_current =0; //current through solar cell
//unsigned power_0 =0; //previous power
//UART variblesunsigned int data = 0; // Variable for transmitted USART datachar usart_state = 0; // State variable for USARTchar i = 0; // Bit counter for USARTchar delay = 0; // Delay counter for USARTchar totaldelay = 33; // Sets baud rate of 9680
//int i;int flag;int Sensor[2];
unsigned int ADC_Result;#define Num_of_Results 8volatile unsigned int results[Num_of_Results];
void main(void){volatile unsigned int i; WDTCTL = WDTPW+WDTHOLD; // Stop WDT P1DIR |= BIT0; // Set P1.0/LED to output direction
P1DIR &= ~BIT1; //Set P1.1 to input direction solar voltage P1DIR &= ~BIT2; //Set P1.2 to input direction solar current
23
P1DIR &= ~BIT3; //Set P1.3 to input direction bat voltage P1DIR &= ~BIT4; //Set P1.4 to input direction bat current P1DIR &= ~BIT5; //Set P1.5 to input direction load current
P3DIR |= BIT6; // P3.6 and P3.5 output PWM!! P3SEL |= BIT6; // P3.6 and P3.5 options select
TA0CCR0 = 240; // PWM frequency = 12M/240 = 50kHz TA0CCTL1 = OUTMOD_7; // CCR1 reset/set TA0CCR1 = 0; TA0CCTL2 = OUTMOD_7; // CCR2 reset/set TA0CCR2 = 0; // CCR2 PWM duty cycle TA0CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, up mode, clear TAR
//UART setup chapter 35 P3SEL = BIT3+BIT4; // P3.3,4 = USCI_A0 TXD/RXD P3.3 sent out data, p3.4 recieve UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL1 |= UCSSEL_1; // ACLK mode, PWM choose SMCLK, avoid conflict with it; UCA0BR0 = 6; // Bit clock prescaler setting. 1MHz 9600 (see User's Guide) UCA0BR1 = 0; // 1MHz 9600 UCA0MCTL = UCBRS_0 + UCBRF_13 + UCOS16; // Modln UCBRSx=0, Second modulation stage select. //UCBRFx=0 First modulation stage select., //UCOS16 over sampling enable UCA0CTL1 &= ~UCSWRST; // Software reset enable. 0 Disabled.USCI reset released for operation. UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
flag =1;//i=0;ADC_Result=0;
for (;;) {
switch (flag){case 1: //trickle ϸÁ÷ charge, keep battery current at 100mA
bat_current=ADC(4); //read battery current buck_control(bat_current, A_100MAbat); //seeks 100mA bat_voltage = ADC(3); //read battery voltage if(bat_voltage >=V_9V) state_advance++; //bat_voltage is great than 9V else state_advance =0; break;
case 2: //mpptmppt();bat_voltage=ADC(3);if(bat_voltage >=V_126V) state_advance++; //bat_voltage is greater than 9Velse state_advance=0;break;
case 4: //shutdown//pwm_limit = 0; //resets pwm limit counterP2OUT &= 0x7F; //turns buck/LED off
24
bat_voltage = ADC(3); //reads battery voltage
if(bat_voltage < V_126V) state_advance++; //bat_voltage is less than 12.6Velse state_advance=0;break;}
if(state_advance>10) { //advance to next statecharging_state++;if(charging_state==3) charging_state++;else if(charging_state==5) {charging_state=0;P2OUT |= 0x80; //turns on buck/LED}state_advance=0;}else if(state_advance<-10) {charging_state=1;state_advance=0;}
//for(i=0; i<8; i++){ //ADC_Result = ADC_Result+ results[i];
//} //ADC_Result=ADC_Result/8; //ADC result /8; if (ADC_Result< 0x1FF) //P1OUT &= ~BIT0; // Clear P1.0 LED off pwm(0,2); else //P1OUT |= BIT0; // Set P1.0 LED on pwm(1,2); //transmit_data(); //enable transmit the data; }}
// ADC10 interrupt service routine#pragma vector=ADC10_VECTOR__interrupt void ADC10_ISR(void){ //static unsigned char index = 0; switch(__even_in_range(ADC10IV,12)) { case 0: break; // No interrupt case 2: break; // conversion result overflow case 4: break; // conversion time overflow case 6: break; // ADC10HI case 8: break; // ADC10LO case 10: break; // ADC10IN case 12: //results[index] = ADC10MEM0; // Move results //index++; // Increment results index, modulo; Set Breakpoint1 here //if (index == 8){ //index = 0; } ADC_Result = ADC10MEM0; __bic_SR_register_on_exit(CPUOFF); break; // Clear CPUOFF bit from 0(SR) default: break; }
25
}
MPPT function /* * mppt.c * * Created on: 2012-2-9 * Author: dxjiang */#include "msp430f5172.h"
#include "ADC.h"#include "PWM.h"//#include "UART.h"#include "buck_control.h"
unsigned long power_0 =0; //right now's power Pxunsigned long power_1 =0; //previous power Pkunsigned long power_2 =0; //next power Pk+1unsigned long dP =0;unsigned int solar_voltage1=0; //voltage of solar cellunsigned int solar_current1 =0; //current through solar cell
unsigned int solar_voltage2=0; //voltage of solar cellunsigned int solar_current2 =0; //current through solar cell
unsigned int solar_voltage3=0; //voltage of solar cellunsigned int solar_current3 =0; //current through solar cell
char pwm_up=1; //direction of pwm, use for mppt
//Seeks maximum power pointvoid mppt(void) {solar_voltage1 = ADC(1);solar_current1 = ADC(2);pwm(0,1); //back 1/2 Tsolar_voltage2 = ADC(1);solar_current2 = ADC(2);pwm(1,2); //forward Tsolar_voltage3 = ADC(1);solar_current3 = ADC(2);
power_0 = (long)solar_voltage1 * solar_current1; //current powerpower_1 = (long)solar_voltage2 * solar_current2; //previous 1/2T powerpower_2 = (long)solar_voltage3 * solar_current3; //forward 1/2T powerdP = (long)2*power_0 - power_1-power_2;
if(dP==0){pwm(0,0);
}
else {if(dP>0){
if(solar_voltage3 > solar_voltage2){ pwm(1,2); //increase T's voltage } else{
pwm(0,2); //decrease T's voltage }
26
}else{ //dP<0;
if(solar_voltage3 > solar_voltage2){ pwm(0,2); //decrease T's voltage } else{
pwm(0,2); //increase T's voltage }
}}
}
Buck control function /* * buck_control.c * * Created on: 2012-2-9 * Author: dxjiang */
#include "msp430f5172.h"#include "PWM.h"//char pwm_limit1=0;void buck_control (unsigned int measurement, unsigned int desired){
signed int delta = measurement - desired;
if(delta>0) pwm(0,2); //buck voltage too high;else if(delta<0) pwm(0,2); // buck voltage too low//else pwm_limit1=0; buck voltage right on__delay_cycles(10); //give buck converter time to settle
}
ADC Function/* * ADC.C * * Created on: 2012-2-4 * Author: dxjiang */#include "msp430f5172.h"unsigned int ADC_Result1;
int ADC (char channel){switch (channel){case 1://Sensor[0] =0;
// Configure ADC ADC10CTL0 |= ADC10SHT_5 + ADC10ON+ADC10MSC; // ADC10ON, S&H=1024 ADC clks ADC10CTL1 |= ADC10SHP+ADC10DIV_7+ADC10CONSEQ_2; // ADCCLK =SMCLK; sampling timer; //clock divide by 8; single channel, Repeat-single-channel conversion; ADC10CTL2 |= ADC10RES; // 10-bit conversion results ADC10IE |= ADC10IE0; // Enable ADC conv complete interrupt
27
ADC10MCTL0 |= ADC10INCH_1; // A1 ADC input select; Vref=AVCC ADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
//Sensor[0] = ADC10MEM0; ADC10CTL0 &= ~ADC10ENC; __no_operation();// For debug only break;
case 2://Sensor[1]=0;// Configure ADCADC10CTL0 |= ADC10SHT_5 + ADC10ON+ADC10MSC; // ADC10ON, S&H=1024 ADC clksADC10CTL1 |= ADC10SHP+ADC10DIV_7+ADC10CONSEQ_2;// ADCCLK =SMCLK; sampling timer;
//clock divide by 8; single channel, Repeat-single-channel conversion;ADC10CTL2 |= ADC10RES; // 10-bit conversion resultsADC10IE |= ADC10IE0; // Enable ADC conv complete interrupt
ADC10MCTL0 |= ADC10INCH_2; // A2 ADC input select; Vref=AVCCADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
//Sensor[1] = ADC10MEM0;ADC10CTL0 &= ~ADC10ENC;__no_operation();// For debug only
break;
case 3://Sensor[1]=0;// Configure ADCADC10CTL0 |= ADC10SHT_5 + ADC10ON+ADC10MSC; // ADC10ON, S&H=1024 ADC clksADC10CTL1 |= ADC10SHP+ADC10DIV_7+ADC10CONSEQ_2;// ADCCLK =SMCLK; sampling timer;
//clock divide by 8; single channel, Repeat-single-channel conversion;ADC10CTL2 |= ADC10RES; // 10-bit conversion resultsADC10IE |= ADC10IE0; // Enable ADC conv complete interrupt
ADC10MCTL0 |= ADC10INCH_3; // A3 ADC input select; Vref=AVCCADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
//Sensor[1] = ADC10MEM0;ADC10CTL0 &= ~ADC10ENC;__no_operation();// For debug only
case 4://Sensor[1]=0;// Configure ADCADC10CTL0 |= ADC10SHT_5 + ADC10ON+ADC10MSC; // ADC10ON, S&H=1024 ADC clksADC10CTL1 |= ADC10SHP+ADC10DIV_7+ADC10CONSEQ_2;// ADCCLK =SMCLK; sampling timer;
//clock divide by 8; single channel, Repeat-single-channel conversion;ADC10CTL2 |= ADC10RES; // 10-bit conversion resultsADC10IE |= ADC10IE0; // Enable ADC conv complete interrupt
ADC10MCTL0 |= ADC10INCH_4; // A3 ADC input select; Vref=AVCCADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
28
//Sensor[1] = ADC10MEM0;ADC10CTL0 &= ~ADC10ENC;__no_operation();// For debug only
break;
case 5://Sensor[1]=0;// Configure ADCADC10CTL0 |= ADC10SHT_5 + ADC10ON+ADC10MSC; // ADC10ON, S&H=1024 ADC clksADC10CTL1 |= ADC10SHP+ADC10DIV_7+ADC10CONSEQ_2;// ADCCLK =SMCLK; sampling timer;
//clock divide by 8; single channel, Repeat-single-channel conversion;ADC10CTL2 |= ADC10RES; // 10-bit conversion resultsADC10IE |= ADC10IE0; // Enable ADC conv complete interrupt
ADC10MCTL0 |= ADC10INCH_5; // A3 ADC input select; Vref=AVCCADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
//Sensor[1] = ADC10MEM0;ADC10CTL0 &= ~ADC10ENC;__no_operation();// For debug only
break;}
return ADC_Result1;}
PWM function#include "msp430f5172.h"
#define PWM_MIN 48 //20% duty cycle#define PWM_MAX 228 //95% duty cycle
void pwm(char direction, char Increasestep){ //WDTCTL = WDTPW + WDTHOLD; // Stop WDT
//P3DIR |= BIT6+BIT5; // P3.6 and P3.5 output // P3SEL |= BIT6+BIT5; // P3.6 and P3.5 options select
// Configure TA0 //TA0CCR0 = 512-1; // PWM Period //TA0CCTL1 = OUTMOD_7; // CCR1 reset/set //TA0CCTL2 = OUTMOD_7; // CCR2 reset/set if(direction ==1 && Increasestep==1){
if(TA0CCR1 < PWM_MAX){ TA0CCR1 += 1; // CCR1 PWM duty cycle
} //else //pwm_limit++;
} else if (direction ==0 && Increasestep==1) {
if(TA0CCR1 > PWM_MIN){ TA0CCR1 -=1; } //else //pwm_limit++;
} else if (direction ==1 && Increasestep==2) {
29
if(TA0CCR1 < PWM_MAX){ TA0CCR1 -=2; } //else //pwm_limit++;
} else if (direction ==0 && Increasestep==2) {
if(TA0CCR1 > PWM_MIN){ TA0CCR1 -=2; } //else //pwm_limit++;
} else if (direction ==0 && Increasestep==0) {
TA0CCR1 -=0; } //else //pwm_limit++;
} //TA0CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, up mode, clear TAR
//__bis_SR_register(LPM0_bits); // Enter LPM0 //__no_operation(); // For debugger
/* * buck_control.c * * Created on: 2012-2-9 * Author: dxjiang */
#include "msp430f5172.h"#include "PWM.h"//char pwm_limit1=0;void buck_control (unsigned int measurement, unsigned int desired){
signed int delta = measurement - desired;
if(delta>0) pwm(0,2); //buck voltage too high;else if(delta<0) pwm(0,2); // buck voltage too low//else pwm_limit1=0; buck voltage right on__delay_cycles(10); //give buck converter time to settle
}
Display data function//Sends all data through serial portvoid display_data(void){unsigned int n=0;while(n<65000) {while(usart_state!=0); //waits until usart is readyswitch(n) {case 0:data = 0x000B; //new lineusart_state = 1; //begin transmitn=1;break;case 1:
30
data = 0x000D; //carriage returnusart_state = 1; //begin transmitn=2;break;case 2:transmit_int(load_current);usart_state = 1; //begin transmitn=4;break;case 4:data = 0x0009; //tabusart_state = 1; //begin transmitn=8;break;case 8:transmit_int(bat_current);n=16;break;case 16:data = 0x0009; //tabusart_state = 1; //begin transmitn=32;break;case 32:transmit_int(solar_voltage);n=64;break;case 64:data = 0x0009; //tabusart_state = 1; //begin transmitn=128;break;case 128:transmit_int(bat_voltage);n=256;break;case 256:data = 0x0009; //tabusart_state = 1; //begin transmitn=512;break;case 512:transmit_int(solar_current);n=1028;break;case 1028:data = 0x0009; //tabusart_state = 1; //begin transmitn=2056;break;case 2056:transmit_int(state_advance);n=4112;break;case 4112:data = 0x0009; //tabusart_state = 1; //begin transmitn=8224;break;
31
case 8224:transmit_int(charging_state);n=16448;break;case 16448:data = 0x0009; //tabusart_state = 1; //begin transmitn=32896;break;case 32896:transmit_int(TA0CCR0); //transmit PWM from P3.6;n=65000;break;}}}
transmit in function//Breaks down an integer into individual characters and transmits them via UARTvoid transmit_int(unsigned int number){while(usart_state!=0);data = ((number/10000)%10) | 0x0030;usart_state = 1;while(usart_state!=0);data = ((number/1000)%10) | 0x0030;usart_state = 1;while(usart_state!=0);data = ((number/100)%10) | 0x0030;usart_state = 1;while(usart_state!=0);data = ((number/10)%10) | 0x0030;usart_state = 1;while(usart_state!=0);data = (number%10) | 0x0030;usart_state = 1;}
//USI interrupt service routine//Transmits data serially through P2.6 following UART standards//Baudrate 9600 bits/sec, 2 stop bits, no parity#pragma vector=USCI_A0_VECTOR__interrupt void USCI_A0_ISR(void){//USICNT = 0x1F; //The USICNTx bits set the number of bits to be received or transmitted. 00011111= 31??//UCAxCTLW0 = UC7BIT Bit 12 Character length. Selects 7-bit or 8-bit character length.if(delay >= totaldelay) {//Used to verify Baudrate//P1OUT ^= 0x01; // Toggle P1.0 using exclusive-ORswitch(usart_state){case 0: //do nothing, data not avaliblebreak;case 1: //send start bitP3OUT &= 0xF7; //P3.3 F7 = 11110111;
32
usart_state += usart_state;break;case 2: //transmit dataif(data & 0x01) P3OUT |= 0x08; //P3.3 as output transmit data; 08=00001000;else P3OUT &= 0xF7;data = data >> 1;i += 1;if(i >= 8){i = 0;usart_state += 2;}break;case 4: //send stop bitsP2OUT |= 0x40;i += 1;if(i >= 7){i = 0;usart_state = 0;}break;}delay=0; //reset delay}delay+=1; //increment delay}
33
16. Components list we have buy:MSP430f5152 (microcontroller)LT 1637 op amp ( for high side current sensor)Two IR2104 FET driver (FET driver) Several IRFIZ44 (for buck converter)Two TLV2760 op amps ( for low side current sensor)
Other relative components we ordered from DigiKey website:
Besides, Target board and FET required to programming the microcontroller, we ordered it form TI
34
17. Cost estimateAccording to previous stage, the materials they need are as following picture. We almost need same cost. Besides, we need to get a better microprocessor, which may require more cost.The solar panel will be provided by the solar film company, which will save us a lot.
18. Project schedule
First semester:Week1---4: recognize each other, building email-list, make plan, study previous reports.Week5—8: understand how the stage 1 circuit work, find realistic problems.Week9---13: search for information we need, such as MPPT algorithm, more powerful microprocessor, cheap substitute parts and so. If it goes smoothly, we can also study data sheet of the microprocessor.Week 14, 15: prepare for the presentation, writing design plan
35
19. Reference
1. http://seniord.ece.iastate.edu/dec1013/seniord/Introduction.html
2. High side current sensor TI opa4342 (PDF.)
3. Improved MPPT Algorithms for Rapidly ChangingEnvironmental Conditions (PDF.)
4. Microprocessor MSP430f5152 data sheet (PDF.)
36
37