Pic Micro controller Based PWM

36
The University of Leeds School of Electronic & Electrical Engineering Page | 1 ELEC5451 B.Chong (2012/2013 Session) ELEC5451 Mini Project - Digital Implementation of PWM Generation Circuit and Control for a PV-Converter System Objectives: Learn to establish PIC-microcontroller based control for PWM Learn to implement the switching circuit for driving power electronic devices. Learn to appreciate the DC-DC voltage regulation and apply it to a photovoltaic (PV) energy system. Learn to measure the I-V characteristics of a practical PV panel Learn to identify the effect of various weather conditions on the I-V characteristics. Learn to apply dc-dc converter in controlling the PV terminal voltage In this lab session of ELEC5451 you will be guided to do the following: PART 1: To investigate and implement PWM signal generation using dsPIC microcontroller. PART 2: To analyse and build the switching circuit consisting of an opto-coupler and a driver for MOSFET. PART 3: To investigate the converter output voltage response when the switching duty cycle is being varied. In this lab session, the converter is used to regulate the voltage across two serially-connected 24W electric bulbs. Any differences from your expected results should be commented and explained. PART 4: To derive the relationship between PV voltage and current under various weather conditions. Apply the dc-dc converter in controlling the PV operating voltages. There will be two sets of notes; First Set is on Part 1 (Programming a Microcontroller) and Second Set is on Parts 2, 3 and 4 (Testing and Applying the Converter for a Stand-Alone PV System) Two symbols are used in the notes have different meanings A step you need to follow but is not necessary to be included in your report A step you need to implement and is necessary to be included/commented in your report

description

Mini project lab notes for Micro controller & PV tracking

Transcript of Pic Micro controller Based PWM

Page 1: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 1 ELEC5451 B.Chong (2012/2013 Session)

ELEC5451 – Mini Project - Digital Implementation of PWM Generation Circuit andControl for a PV-Converter System

Objectives: Learn to establish PIC-microcontroller based control for PWM Learn to implement the switching circuit for driving power electronic

devices. Learn to appreciate the DC-DC voltage regulation and apply it to a

photovoltaic (PV) energy system. Learn to measure the I-V characteristics of a practical PV panel Learn to identify the effect of various weather conditions on the I-V

characteristics. Learn to apply dc-dc converter in controlling the PV terminal voltage

In this lab session of ELEC5451 you will be guided to do the following:

PART 1: To investigate and implement PWM signal generation using dsPIC microcontroller.PART 2: To analyse and build the switching circuit consisting of an opto-coupler and a driver for

MOSFET.PART 3: To investigate the converter output voltage response when the switching duty cycle is

being varied. In this lab session, the converter is used to regulate the voltage across twoserially-connected 24W electric bulbs. Any differences from your expected resultsshould be commented and explained.

PART 4: To derive the relationship between PV voltage and current under various weatherconditions. Apply the dc-dc converter in controlling the PV operating voltages.

There will be two sets of notes; First Set is on Part 1 (Programming aMicrocontroller) and Second Set is on Parts 2, 3 and 4 (Testing and Applying

the Converter for a Stand-Alone PV System)

Two symbols are used in the notes have different meanings

A step you need to follow but is not necessary to be included in your report

A step you need to implement and is necessary to be included/commented inyour report

Page 2: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 2 ELEC5451 B.Chong (2012/2013 Session)

Note Set No. 1: PROGRAMMING A DSPIC30F MICROCONTROLLER

OverviewWe are going to use one device from the dsPIC30F family which is dsPIC30F4011. The fulldetails on device features can be found in VLE under datasheets but those that are essentialfor PWM generation are listed below (Note that different dsPIC30F device may be needed ifmore memory, more PWM modules, more ADC channels or higher processing speed isneeded) [1]. (Refer to page 2 of datasheet)No. of Pins: 40/44Program Memory: 48 Kilobytes / 16 000 instructionsSRAM: 2048 bytesTimer 16-bit: 5 countersMotor Control PWM Module: 6 channelsOutput Comp/Std PWM: 4 peripheralsA/D 10-bit (up to 200 ksps conversion rate): 9 ChannelsInternal Oscillator: 7.37 MHz

We are going to use MPLAB IDE to build the machine codes which are mainly used toprogram your device to generate the appropriate PWM signals. The complete process issummarized in Figure 1.

Figure 1. Flowchart for programming a microcontroller device

Start

Configuring the settings in MPLAB IDE

Writing a C program in Notepad / in C editor

End

Debugging the program in MPLAB IDE

Building the program in MPLAB IDE

Is theprogramcorrect?

Updating the program

Download the code to the device

Page 3: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 3 ELEC5451 B.Chong (2012/2013 Session)

Section 1: Setting up MPLAB IDE for Programming a dsPIC30F4011 deviceTo start the process, open MPLAB IDE (it should be located on the desktop or Microchipfolder under Start>Programs)

1. First choose the PIC device you want by clicking on “Configure” then “Select Device…”as shown in Figure 2:

Figure 2. Setting configuration for device

2. Pull down the Device Menu as shown below and select dsPIC30F4011. If your desktopalready has selected this, then skip this step.

Figure 3. Selecting the correct device

Page 4: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 4 ELEC5451 B.Chong (2012/2013 Session)

3. Note the ‘red’ and ‘green lights’. These indicate which MPLAB components support thisdevice. A green light indicates support and you can proceed with your design. Sometimes youmight see a yellow light; this would indicate minimal support for an upcoming part that mightnot yet be fully supported by MPLAB component. Usage of components with a yellow lightinstead of a green light is often intended for early adopters of new parts who need quicksupport and understand that some operations of functions may not be available. If the light isred then choose another PIC device or another programmer etc.

Figure 4. Summary of Microchip Tool Support

4. Next, create a project using the Project Wizard. Choose Project Wizard from the projectmenu as shown in Figure 5. A project is the way your files are organized to be compiled andassembled. In this case we will use a single ‘C’ file for this project.

Figure 5. Creating Project with the Wizard

Page 5: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 5 ELEC5451 B.Chong (2012/2013 Session)

5. The Project Wizard should start and show the following opening screen, press “Next” tocontinue.

Figure 6. Welcome Dialogue Box

6. The first step allows you to select the device, which you have already done. If the deviceshown is not the dsPIC30F4011, change it on this dialog. This seems like a redundant step,but the project wizard bases most of the information related to the assembler, linker etc on thedevice selected.

Figure 7. Setting the Correct Device

Page 6: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 6 ELEC5451 B.Chong (2012/2013 Session)

7. This step is used to set up the language tools suite. All projects will be in ‘C’, so from the“Active Toolsuite” select the “MPLAB C30 C Compiler” which is for dsPIC30F seriesdevices. The locations for these toolsuites may have been changed. The correct locations areshown in Figure 8.

Figure 8. Selecting the relevant toolsuite for dsPIC30F devices

8. Step three asks for the project name; for this first exercise, simply call it as “PWM_1”.Note that you have to enter the drive and the directories (if applicable) you are saving into asshown in Figure 9.

Figure 9. Giving a Project Name

Locations of C30 toolsuite contents (for our School’s PCs)C:\Program Files\Microchip\MPLAB C30\bin\pic30-as.exeC:\Program Files\Microchip\MPLAB C30\bin\pic30-gcc.exeC:\Program Files\Microchip\MPLAB C30\bin\pic30-ld.exeC:\Program Files\Microchip\MPLAB C30\bin\pic30-ar.exe

(If the above are not available, i.e. when is indicated, use“Browse” to locate these files.)

Page 7: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 7 ELEC5451 B.Chong (2012/2013 Session)

9. Click “Next” to continue and the next step asks you to add files into the project. You canskip this step by clicking “Next”. This brings you to a “Summary”. As soon as you click“Finish”, “Project” and “Output” windows as shown in Figure 10. If you do not get them goto “View” menu and select “Project” and “Output”.

Figure 10. Summary of the Project Created

The project window shows the workspace file name (PWM_1.mcw) in the title bar, and theproject file (PWM_1.mcw) at the top of the file tree view. A workspace file keeps track ofwhat files and windows are open, where the windows are located in the MPLAB IDEworkspace, what programmer or debugger tools are selected and how they are configured andother information on how the MPLAB environment is set up. A project file keeps track of allnecessary files to build a project including source and header files, library files, linker scriptsand other files.

10. All programs require the linker script and header file relating to the device you use. Alinker script is required to build the project. It is a command file for the linker, and definesoptions that describe the available memories on the target microcontroller. The linker scriptfor dsPIC30F4011 can be added by right-clicking “Linker Script”, select “Add Files…” andsearch for p30f4011.gld under “C:\Program Files\Microchip\MPLAB C30\support\dsPIC30F\gld”.Header file initializes or assigns any variables and functions needed for programming theselected device. For dsPIC30F2011, the header file needed is p30f4011.h under “C:\ProgramFiles\Microchip\MPLAB C30\support\dsPIC30F\h”. Save your project by selecting “SaveProject” from the “Project” menu. The “Project” and “Output” windows will be updated asshown in Figure 11.

11. (Only when you know what Oscillator your device is based on) It is quite important tofirst set the oscillator you want your microcontroller to be based on. For this PWM generationcircuit, we will use the highest PLL factor of the internal clock. To set this up properly, go to“Configure” menu, and then “Configuration Bits…”. Untick “Configuration Bits set in code”.

Page 8: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 8 ELEC5451 B.Chong (2012/2013 Session)

Along “Oscillator” category and under the “Setting” tab select “FRC w/PLL 16x”. Moreinformation will be provided in Section 2.1 later.

Figure 11. Project with Header File and Linker Script Added

Section 2: Writing a C program for PWM generationThis section guides you to write the C program which can be 1) converted to machine codeand then 2) uploaded to the device we use so that it can generate PWM signal as required.Copy the following program codes from the electronic copy of this notes onto a newNOTEPAD window (Though can be omitted, the comments indicated by ‘//………..’ areuseful to explain the codes).#include <p30f4011.h>//This line is required to program any PIC device_FOSC(CSW_FSCM_OFF & FRC_PLL16);//FRC w/ PLL 16x instruction cycle clock rate 7.37MHz//REFER to the Part 2.1 for explanation//For more details read Pg 140 and Pg 143 of //datasheet#define MILLISEC 29480 // 1 mSec delay constant

//***** function declarations******//int main(void);void init(void);void DelayNmSec(unsigned int N);//*****Variable declarations******//int ADCValue;//*****Main Program starts here******//int main()init(); //****Program initialization - Jump to this functionwhile (1)ADCON1bits.SAMP = 1; // start sampling ...DelayNmSec(100); // for 100 mSADCON1bits.SAMP = 0; // start Convertingwhile (!ADCON1bits.DONE); // conversion done?//If not the program will be trappedADCValue = ADCBUF0; // If yes then get ADC value 10-bitPDC1 = ADCValue;return 0;

Page 9: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 9 ELEC5451 B.Chong (2012/2013 Session)

// ***** INITIALISATION ***** *//void init(void)//****SETUP of ADC****////REFER to the Section 2.3 for explanation// For more details see Page 131 - 138 of data sheet for reference//***ADC in Manual Sampling Mode*****//ADPCFG = 0xFFFB; // all PORTB = Digital; RB2 = analogADCON1 = 0x0000; // SAMP bit = 0 ends sampling ...// and starts convertingADCHS = 0x0002; // Connect RB2/AN2 as CH0 input ..// in this application RB2/AN2 is the inputADCSSL = 0; //Channel scanning is disabledADCON3 = 0x0003; // Manual Sample, Tad = internal 2 TcyADCON2 = 0;ADCON1bits.ADON = 1; // turn ADC ON

//**SETUP OF PWM MODULE****//

PWMCON1 = 0x0011; //Enable PWM Pins and enable complementary modePTCON = 0x8002; //Read Section 2.2PTPER = 736; //Read Section 2.2PDC1 = 736; //Read Section 2.2PTMR = 0;

void DelayNmSec(unsigned int N) //Redundant N loopunsigned int j;while(N--)for(j=0;j < MILLISEC;j++);

Save the code under “PWM_1.c” and add this into Source Files of your project. You areexpected to understand the codes above. The following 3 sub-sections will guide you throughbut the full details and explanation of the device operation can be found in the datasheets.

Page 10: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 10 ELEC5451 B.Chong (2012/2013 Session)

Section 2.1 Setting up and Understanding the Device Clock

Table 1: Frequency and Clock settings for dsPIC30F4011 device [1]

There is a variety of clock types/oscillator you can use as the basis for the processing unit ofyour device. Using the setting we have done in Step 11 of Section 1, we are using the fastestclock rate the device can offer which is 16 x the internal clock frequency (7.37 MHz) (i.e.using FRC internal w/16x PLL).

Page 11: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 11 ELEC5451 B.Chong (2012/2013 Session)

Calculate the Instruction Execution Frequency using the formula stated in Note 3under Table 24-15: Internal Clock Timing Examples in Table 1 (of previous page).You should remember in microcontroller, there are 4 clock cycles required to carry outeach instruction. This value corresponds to the variable FCY in your program. Inaddition, the datasheet may use MIPS (millions instructions per second) which isequal to FCY/(106). The reciprocal of FCY is TCY which indicates the amount of timerequired to carry out one instruction. In your report you should demonstrate andexplain how you determine FCY, MIPS and TCY based on the settings we have in thecodes.

In your program, there is a variable called MILISEC. Assume there is anothervariable, (j for example) is to be iteratively incremented to the value of MILISEC, andone increment takes one instruction cycle. Based on the understanding of the clocktype you selected, mathematically show that with MILISEC equals to 29480 so that a1 milisecond delay can be achieved. Show and explain your calculation. (In latersection, you will find that practically this cannot be achieved because the oneincrement step may take longer than one instruction cycle.)

Section 2.2 Setting up the PWM operation

dsPIC30F devices have two main approaches using either Output Compare or MotorControl PWM modules. The former is sufficient for single or isolated PWM while the latteris useful for H-bridge type of converter (i.e. containing switches that require floating ground).However not all devices have both modules (dsPIC30F2011, dsPIC30F4013, dsPIC30F3014etc only have Output Compare while dsPIC30F4011 for example has both).

We are going to drive one dc-dc boost converter and actually Output Compare module willbe sufficient but this lab is designed to help you in future projects which may require MotorControl PWM module; before the settings are done, please follow the brief explanationabout Motor Control PWM module:

Using this module, there are several approaches for generating PWM; one is by comparing asaw-tooth waveform (which is actually the value of PTMR) with a constant value which isdefined by PDCx (x could be 1, 2, or 3) as shown in the Figure 12. We call this as edgedaligned PWM – The PWM1H is based on PDC1 and PWM2H is based on PDC2.

Figure 12: Edged-aligned PWM

Task 1

Page 12: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 12 ELEC5451 B.Chong (2012/2013 Session)

Another approach is by comparing a triangular waveform (which is actually the value ofPTMR again) with a constant value of PDCx (x could be 1, 2, or 3) as shown in the Figure13. We call this as Centre-Aligned PWM – PWM1H is based on PDC1 and PWM2H onPDC2.

Figure 13: Centre-aligned PWM

Can you tell the relationship between the duty ratio of PWM1H and the value of PDC1?Actually there is another output (which is not shown in the figures) which has thecomplementary (or the inverted) form of PWM1H and it is found at PWM1L. And so can youpredict the relationship between the duty ratio of PWM1L and the value of PDC1? If so, whatdoes the value of PDC1 represent? You will find that the second PWM method is more usefulespecially for more complicated PWM schemes (which will be covered in ELEC5525). Soplease read carefully the operation below:

In the center aligned mode, the time base is an up-down counter: it starts from zero, counts upto the value in the period register and then counts down to zero and so on. Bit 15 in the timerregister (PTMR) indicates the counting direction. In this mode, the PWM period is twice thetime base period. The duty cycle buffers are updated when the timer is reset to zero; theinterrupt flag is set at the same time. As you can see from Figure 13, the PWM waveform iscentered around the instant in time when the timer reaches its maximum value and startcounting back: from this the name “center aligned”. Although the PWM frequency is half theedge aligned PWM, this mode is very useful because it avoids the simultaneous switching ofall the PWM outputs at the same time. This is not a problem for the device itself, but sincepower switches are connected to these outputs, the switching current can be quite high andmay require an oversized power supply.

a) Configure the PWM module

- To use the centre-aligned PWM mode, we set PTMOD<1:0> in PTCON register to be 2or 10(binary). The clock that governs the PWM should be the internal clock hence bit 15is 1 and it is the same scale of the clock frequency hence bits 3 – 2 is 00. Hence PTCON isset to be 0x8002 (in hex).

b) Set the PWM period by writing an appropriate value for (PTPER)

- We will need 20kHz PWM which has a period of 50 μs (Tpwm).

Page 13: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 13 ELEC5451 B.Chong (2012/2013 Session)

- From Figure 13, the time for PTMR to reach PTPER is half of Tpwm. Hence thefollowing formula can be used to calculate the right value for PTPER to give the desiredPWM frequency:TPWM = (2TCY PTCKPS pre scale value (PTPER + 1) )Since we have set the pre-scale value 1, TPWM = (2TCY (PTPER + 1) ). Now can youverify the code given.

c) Set the PWM duty ratio by writing to the PDC1 register (assuming PDC1 has a directrelationship with the duty ratio)

- From (a), we know PTPER represents half of the total period and we will know how long(or by what proportion) the pulse has to be high; thus the duty ratio can be set. Theamount of the proportion is stored under PDC1 register. Note that the duty ratio of 100%will correspond to 2 PTPER using Centre-aligned PWM. What is the duty ratio value ifPDC1 = 736?

d) Reset PTMR

- It is worthwhile to reset the PTMR at the beginning of the coding and hence PTMR is etto 0.

Section 2.3 Setting up ADC Channels and Retrieving Data from the ADCBuffers

Figure 14 shows a basic conversion sequence and the terms that are used. Sample and Hold(S/H) amplifier first of all is connected to the (designated) analogue input for sampling. Thetime taken when S/H amplifier is called the sample time (Note that this may not necessary tobe equal to the overall “sampling time” you will need to know for Modelling, Control etc.).Sample time may be set through the code (hence automatic sampling) or set manually throughsetting and clearing the SAMP bit (manual sampling). For both modes, the S/H amplifier isdisconnected from the input at the end of sampling time. The conversion to the digital valuemay start automatically or by some externally triggered source. The conversion time fordsPIC30F devices are 12 TAD where TAD is one ADC clock cycle (the explanation for TADwill be covered below). At the end of the conversion, the result is loaded into ADC buffer. Ifa series of conversions (and hence few buffers will be used) are required, an interrupt can beused (will be explained later). For our dsPIC30F device (i.e. 4011 series), we have aminimum sample time which is about 154 ns so that the desired accuracy for the ADCconversion can be obtained.

Figure 14: General timing diagram of ADC process [2]

Task 2

Page 14: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 14 ELEC5451 B.Chong (2012/2013 Session)

In general to configure the ADC for dsPIC30F device, the following steps must be performed:

a) Setting the analogue input pins- This can be done by clearing (i.e. ‘0’) the relevant bits from bit 0 – bit 7 of

ADPCFG register (bit 0 corresponds to AN0, bit 1 to AN1 etc); pins which arenot used should be defined as 1.

b) Setting the voltage reference- We want the full range of the 5V supply and hence ADC-ref-H should be set to

AVDD and ADC-ref-L should be set to AVSS. Hence VCFG in ADCON2 is000. If you need other voltage range, you can then use External Vref+/- and setthe VCFG accordingly (refer to the datasheet [1]).

c) Setting the type of sampling and conversion- There are a few types of sampling and conversion you can do with the ADC

for dsPIC30F devices. In the code above, only manual sampling is required;hence, ASAM in ADCON1 is set to 0. However, the sampling should not bedone immediately (during the initialization stage) so SAMP is initially 0.SAMP is only set to 1 when the code is ready to perform sampling. We alsowant a manual conversion (i.e. the starting of conversion is done by the code),hence SSRC = 000. You can store the output in the buffer in various forms(integer, fractional, signed integer etc.) but in our case we will use integer typehence FORM = 00. ADON is turned off initially but has to be turned on at theend of the initialization stage. We also need to connect the channel of ADCconversion correctly to the ADC input. This can be done by setting CH0SAbits in ADCHS properly. CH0SB is used when multiplexing function isapplied.

c) Setting the Sampling time (TAD)

- This is important especially auto sampling and conversion mode is applied. First mostof our applications employ internal clock, hence ADRC in ADCON3 is equal to 0.Two other registers which are important for ADC settings; SAMC defines the numberof TAD between the start of the sampling and the start of the conversion (this isimportant for auto conversion – in this case the minimum SAMC is 1 TAD). Formanual conversion, SAMC can be set to 0. The other register is ADCS and theformula to calculate this is shown below:ADCS = 2 (TAD/TCY) -1

d) Other features (like channel scanning and interrupts) – Optional

- When you have more than one ADC inputs or when you want to have moreaccurate measurements (by taking the average of a number of noisy signals),Channel scanning with ADC interrupts can be used. The register relating to this isADCON2.

- CSCNA = 0 when scanning is not needed and 1 when it is needed. For the latter,the relevant bits in ADCSSL have to be set (‘1’) so that the inputs are selected forthe scanning (bit 0 corresponds to AN0, bit 1 to AN1 etc).

- BUFM is set to 0 if the data from ADC are not split into two words. (This mode isnormally what we are going to use.)

- ALTS = 0 when only MUX A is used. (This mode is normally what we are goingto use.)

Page 15: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 15 ELEC5451 B.Chong (2012/2013 Session)

- SMPI determines the number of samples being converted before an interruptoccurs. (0000 means an interrupt occurs after conversion of one sample, 0001 –two samples, 0002 – three samples and so on.)

e) Turn on the ADC when all the initialization has been done (i.e. ADCON1bits.ADON = 1)

- Study the codes above and with the help of the datasheet, describe how the ADChas been set.

Three other ADC approaches (auto sampling-conversion, and auto sampling-conversion withaveraging and auto sampling conversion for two inputs) are listed in the Appendix. (YOUARE EXPECTED TO TRY THEM OUT BUT ONLY WHEN YOU HAVE BUILT,DEBUGGED and PROGRAMMED YOUR DEVICE).

Section 3: Building and Debugging your Program

In this section, we will build the program and before uploading the machine language to themicrocontroller, we will debug the program to 1) ensure the results (by observing the relevantregisters) obtained are the expected ones and 2) measure the real time taken to execute one ora group of codes – this can then help us to calculate the overall sampling time later forexample.

First select “Build All” under “Project” menu, as shown in Figure below:

Figure 15: Building a Project

Almost immediately in the “Output” window under “Build” tab, there appears the summary ofthe programs built – this includes the overall data and program memory that has been used. At

Task 3

Page 16: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 16 ELEC5451 B.Chong (2012/2013 Session)

this stage, you are actually free to upload the machine codes (i.e. programming your devicethrough a programmer like PICKIT2).

For our exercise, we will firstly need to debug the program. To do this, select MPLAB SIMunder “Debugger” menu. (This step is essential to confirm your code is working like how itwas designed for.)

Figure 16: Turn on the MPLAB SIM Debugging Mode

You can observe additional tab called MPLAB SIM appearing in the “Output” window andthere are more options in “Debugger” menu as shown in Figure 17.

Figure 17: Debugging Functions

Before we “Run” the program, let us turn on the following:

a) “Watch” window under “View” menu.b) “Stopwatch” window under “Debugger” menu.c) “Stimulus” window under “Debugger” menu. You need to create a new one for the firsttime. There are a few stimulus features you can use but the most useful one is the “RegisterInjection”. Select that tab, click on the first empty row, automatically some texts as shown inFigure 18 will appear. The program detects that you can have registry entry for ADCBUF0.

(NOTE: If the window you have opened does not appear on the screen, you may need to goback to “Window” menu to select it.)

Page 17: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 17 ELEC5451 B.Chong (2012/2013 Session)

Figure 18: Stimulus Window – Register Injection

You need to upload a .txt file under Data Filename. Using NOTEPAD, type out the followinglist and save it under the name of “PWM_value.txt”.

0x00010x00020x00030x00040x00050x00060x00070x00080x00090x000A0x00AA0x00FF0x00550x03FF0x03000x0388

Go back to the “Register Injection” window, browse and select PWM_value.txt. Click“Apply” and minimise this window.

We also intend to observe any change of data stored in ADCBUF0, PDC1 and ADCValue –this can be done under “Watch” window. Add these variables from the list. ADCBUF0 andOC1RS (inherent for any dsPIC30F) are obtained from “SFR” list while ADCValue (user-defined) isfrom “Symbol”. When you have added them all, the window should look likeFigure 19. (Do not worry if the addresses look different from yours)

Page 18: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 18 ELEC5451 B.Chong (2012/2013 Session)

Figure 19: Observing Various Registers in Watch Window

If we were to run the program now, the registers will continue changing and we hardly canview the change. We can indicate breakpoints within the code so that we can observe andverify our codes. Let us have one breakpoint along ADCValue = ADCBUF0; line by justdouble-clicking on it. A “B” will appear beside the line of interest.

Figure 20: Breakpoint indication

Now you can run your program by selecting “Run” from Debugger or pressing F9. If yourcodes have been correctly entered, the execution of your code should stop at the breakpointyou indicated. Monitor the Watch Window each time you press F9. (Note you can press F7once to run only one program line at a time).

Using the above debugging approach, explain how you can verify that the above codeshave been correctly entered (i.e. manual sampling of ADC has been set and if a 5V isapplied to the ADC input, a duty ratio of 50% of PWM signal will be generated.

Now let us check the time between two consecutive updates of PDC1 (i.e. the duty ratio ofPWM signal). To do this, let us Run the code and let the program point (the green arrow) stopat the breakpoint indicated in Figure 20. From the “Stopwatch” window, reset the time byclicking the “zero” tab. Press F9 once and you should check the time along “Time” row under“Stopwatch”. It should gives you 491 ms.

Can you explain why you could not obtain 100 ms? (How can you improve this?HINT: The function DelayNmSec may take more than 1 ms to be executed in practice.So should 100 be still passed as the input?)

Task 4

Task 5

Page 19: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 19 ELEC5451 B.Chong (2012/2013 Session)

Figure 21: Stopwatch window when “zero” is pressed.

Section 4: Uploading the Program to the Device using PICKIT 2

Figure 22. Pin diagrams for dsPIC30F4011

Referring to the Pin Diagrams in Figure 22, the following indicates some of important pinsyou need to know for this lab:

AN0 – AN8: Analogue input channels (0 – 5 Volt) AVDD : Positive supply for analogue module AVSS : Negative supply for analogue module MCLR: Master clear input. (An active LOW to this will reset the device) OC1 – OC2: Output Compare 1 through 2 PWM1L – PWM3H: PWM Module Output 1 Low to PWM Module Output 3 High PGD: In-circuit serial programming data input/output pin PGC: In-circuit serial programming clock input/output pin VDD: Positive supply for logic and I/O pins VSS: Ground for logic and I/O pins.

External connections need to be done in order for the microcontroller to be programmedproperly the device. The circuit diagram is given to you as shown in Figure 23.

Page 20: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 20 ELEC5451 B.Chong (2012/2013 Session)

Figure 23. External Connection for Programming dsPIC30F4011 using PICKIT2

To program your device, select PICKIT2 from the “Select Programmer” under Programmer.When your PICKIT2 has been connected to the circuit as shown in Figure 23, click on thefollowing button (which can be normally shown at the top right corner):

Once it is clicked, the following messages appear in the “Output” window:

Figure 24. Establishing a link between dsPIC30F4011 and PICKIT2

To start uploading your code to the device, select “Program” from “Programmer Menu” asshown below:

Click on this to establish connection to the device

10kΩ

40

39

32

31

26

25

PWM1H 37

4011

Page 21: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 21 ELEC5451 B.Chong (2012/2013 Session)

Once it is uploaded, the following messages should appear in your “Output” window.

Figure 25. Uploading machine code to dsPIC30F4011 through PICKIT2 and MPLAB IDE

Your microcontroller can now function as PWM generator!

BUT

You need to know if it is functioning as it should.

Section 5: Testing the Microcontroller Device

Note that when the device is used as to generate PWM, MCLR has to be pulled-up to HIGH(5V supply) through a 10 kΩ resistor as shown in Figure 22. This is to prevent the devicefrom being reset while operating as a PWM generator. For this lab, the analogue input signalto AN2 is taken from a potentiometer which can be implemented using the circuit shown in

Page 22: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 22 ELEC5451 B.Chong (2012/2013 Session)

Figure 26. (The only different between this circuit diagram and that in Figure 21 is that theADC is applied with an analogue signal and the device is powered by an external 5 V supply.

Figure 26. External connections for dsPIC30F4011 when it is used as PWM generationCircuit

Figure 27. Duty cycle adjustment circuit

Note that the voltage across AN2 varies from 0 – 5V since AVDD and AVSS respectively areconnected to 5 and 0 V. We are using this to determine the duty cycle value for the PWMsignal we are generating.

Theoretically you can now derive the relationship between the duty cycle valueand the voltage level across AN2, referring to the full range of duty ratioprovided by the code.

Obtain three different PWM signals with duty ratios of your own choice.

Measure the voltage levels across the input potentiometer. For all cases, use

oscilloscope to measure the voltage when the output PWM1H is HIGH and

LOW. How about the frequency value? Confirm the observed frequency with

the given code.

AVDD

AVSS

AN2 ‘Duty cycle value’

Task 6

Task 7

40

39

32

31

4011

PWM1H

Page 23: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 23 ELEC5451 B.Chong (2012/2013 Session)

Section 6: Testing Other ADC Approaches

- Briefly describe the ADC process for the three subsequent programs (A, B, C).

You are encouraged to refer to the datasheet. Determine the overall sampling time

for each of them.

- Note that DutyCycle is updated using ADCValue>>2; this means 2 bits shifted to

the right or a division of 4 in operated. Debug the program and check how much

faster the shifting operator is than the multiplication operation. (Note that the shift

operation can only be used because our scale factor is around 1/4. For other

multiplication, fixed point arithmetic is required.)

Program A: Auto Sampling-Conversion for the ADC

#include <p30f4011.h>

//This line is required to program any PIC device

_FOSC(CSW_FSCM_OFF & FRC_PLL16);

#define MILLISEC 29480 // 1 mSec delay constant

//***** function declarations******//int main(void);void init(void);void DelayNmSec(unsigned int N);

//*****Variable declarations******//int ADCValue;int DutyCycle;

//*****Main Program starts here******//int main()init(); //****Program initialization - Jump to this functionwhile (1)ADCValue = 0;ADCON1bits.ASAM = 1; //auto start samplingwhile (!ADCON1bits.DONE); // conversion done?ADCON1bits.ASAM = 0;ADCValue = ADCBUF0; // yes then get ADC value 12-bitPDC1 = ADCValue;return 0;// ***** INITIALISATION ***** *//void init(void)//****SETUP of ADC****//// Setup of ADC - Read Page 131 - 138 of data sheet for reference//***ADC in Automatic Sampling Mode*****//ADPCFG = 0xFFFB;ADCON1 = 0x00E0;ADCHS = 0x0002;ADCSSL = 0;ADCON3 = 0x0127;ADCON2 = 0;ADCON1bits.ADON = 1;

Task 8

Page 24: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 24 ELEC5451 B.Chong (2012/2013 Session)

//**SETUP OF PWM MODULE****//PWMCON1 = 0x0011;PTCON = 0x8002;PTPER = 736;PDC1 = 737;PTMR = 0;

void DelayNmSec(unsigned int N) //Redundant N loopunsigned int j;while(N--)for(j=0;j < MILLISEC;j++);

Program B: Auto Sampling-Conversion with Averaging

#include <p30f4011.h>//This line is required to program any PIC device_FOSC(CSW_FSCM_OFF & FRC_PLL16);#define MILLISEC 29480 // 1 mSec delay constant

//***** function declarations******//int main(void);void init(void);void DelayNmSec(unsigned int N);

//*****Variable declarations******//int ADCValue;int DutyCycle;//*****Main Program starts here******//int main()init(); //****Program initialization - Jump to this functionwhile (1)ADCValue = 0;IFS0bits.ADIF = 0;ADCON1bits.ASAM = 1;while(!IFS0bits.ADIF); // conversion done?ADCON1bits.ASAM = 0;ADCValue = ADCBUF0 + ADCBUF1;ADCValue = ADCValue>>1;PDC1 = ADCValue;

return 0;// ***** INITIALISATION ***** *//void init(void)//****SETUP of ADC****//// Setup of ADC - Read Page 131 - 138 of data sheet for reference//***ADC in Manual Sampling Mode*****//ADPCFG = 0xFFFB;ADCON1 = 0x00E0;ADCHS = 0x0002;ADCSSL = 0;ADCON3 = 0x0127;ADCON2 = 0x0004;ADCON1bits.ADON = 1;

//**SETUP OF PWM MODULE****//PWMCON1 = 0x0011; //Enable PWM Pins and enable complementary mode

Page 25: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 25 ELEC5451 B.Chong (2012/2013 Session)

PTCON = 0x8002;PTPER = 736;PDC1 = 736;PTMR = 0;void DelayNmSec(unsigned int N) //Redundant N loopunsigned int j;while(N--)for(j=0;j < MILLISEC;j++);

Program C: Auto Sampling-Conversion for Two outputs

#include <p30f4011.h>//This line is required to program any PIC device_FOSC(CSW_FSCM_OFF & FRC_PLL16);#define MILLISEC 29480 // 1 mSec delay constant

//***** function declarations******//int main(void);void init(void);void DelayNmSec(unsigned int N);

//*****Variable declarations******//int ADCValue;int DutyCycle;//*****Main Program starts here******//int main()init(); //****Program initialization - Jump to this functionwhile (1)ADCValue = 0;IFS0bits.ADIF = 0;ADCON1bits.ASAM = 1;while (!IFS0bits.ADIF); // conversion done?ADCON1bits.ASAM = 0;ADCValue = ADCBUF0 + ADCBUF1;ADCValue = ADCValue>>1;PDC1 = ADCValue;return 0;// ***** INITIALISATION ***** *//void init(void)//****SETUP of ADC****//// Setup of ADC - Read Page 131 - 138 of data sheet for reference//***ADC in Manual Sampling Mode*****//ADPCFG = 0xFFF3;ADCON1 = 0x00E0;ADCHS = 0x0002;ADCSSL = 0x000C;ADCON3 = 0x0127;ADCON2 = 0x0404;ADCON1bits.ADON = 1;

//**SETUP OF PWM MODULE****//PWMCON1 = 0x0011;PTCON = 0x8002;PTPER = 736;PDC1 = 736;PTMR = 0;

Page 26: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 26 ELEC5451 B.Chong (2012/2013 Session)

void DelayNmSec(unsigned int N) //Redundant N loopunsigned int j;while(N--)for(j=0;j < MILLISEC;j++);

Note Set No. 2: TESTING AND APPLYING THE CONVERTER FOR ASTAND-ALONE PV SYSTEM

Section 1 INVESTIGATION OF THE STEP-UP CONVERTER MOUNTEDON A PCB BOARD

In this laboratory, the boost converter circuit we are working on is as shown in Figure 1. As

observed, input and output terminals are left unconnected. You have the freedom to choose

any supply or load AS LONG AS the voltage and current ratings are not exceeded.

Therefore, it is part of your task to analyze the limitations (voltage, current, internal

resistances, response time etc..) each component has. To do this, you must refer to the

datasheet of the components and following explanation may provide you some helpful

guides.

NOTE: All component datasheets are in PDF version and can be obtained from ELEC5510

VLE.

Figure 1. A Boost converter circuitCapacitors C1 and C2

The most important attribute you should check for is the maximum rating for the voltage

across the capacitor. This value should not be exceeded at any operating conditions, whether

during the transient or steady state. For our application, it is one of our precaution measures

S

DL

C2C1

GInputSocket

OutputSocket

GateSocket

L = 1 mHC1 = 82 μFC2 = 82 μF

+ +

__

Page 27: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 27 ELEC5451 B.Chong (2012/2013 Session)

to further restrict the peak voltage across the capacitor to be within 70% of the maximum

rated value.

Inductor L

The inductor we are using is the powdered-iron core type and the major advantage using this

is the high saturation flux density. With this inductor, the current flowing through it will

hardly saturate even at a higher DC value. There are a number of features you have to be

aware of and these include the following:

Rated current, IR (Maximum current value)

Rated inductance, LR

DC resistance

Inductance at rated current, IR

All the above features should be considered when designing low-ripple converter whilst the

operating current at any condition (transient or steady state) should NOT exceed the rated

value.

Power Switch S

In this laboratory, we are using MOSFET type of switch. The maximum ratings including

drain-source voltage, gate-source voltage and drain current impose a limitation on our

converter operation. This means the supply voltage should not be above the maximum drain-

source voltage, the gate signal should be below the maximum gate-source voltage and the

switch current should be always lower than the maximum rated value.

All semiconductor power losses including those in MOSFET are dissipated in the form of

heat. It is therefore important to know these characteristics of our device. They are expressed

as thermal resistances in the datasheet. This information will lead you to the design of

adequate cooling system for MOSFET (or any other power devices in your future work).

There are other important features which also determine your converter design limitation.

These include:

Gate threshold voltage (This determines the gate voltage at which the switch is

properly turned on or off – refer to Figures 4 in the datasheet).

Static drain-source on resistance (This determines the losses and voltage drop across a

switch during turn-on time – refer to Figure 6 in the datasheet).

Switching times; turn-on and turn-off delay times, rise and fall times (This determines

the maximum switching frequency this converter can operate – refer to Figure 17 in

the datasheet)

Page 28: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 28 ELEC5451 B.Chong (2012/2013 Session)

Power Diode D

A fast recovery diode is used for our converter circuit. Check that the reverse recovery

time is much faster than switching period. Also similar to MOSFET, it has maximum

limits for operating forward current and its thermal characteristics are represented by the

thermal resistance. Also it has a threshold voltage above which the diode is properly

turned on (forward-biased).

In this laboratory session you are assigned to populate the above described components on

a PCB board which has been fabricated in advance for you. The layout is illustrated in

Figure 2.

You are expected to do the following tasks for this part of exercise.

Task 1: Analyze the given PCB board and identify the locations for all the components.

Remember that some components have polarity for the pins and they have to

be connected appropriately. Remember also to attach the heat sinks to the

devices properly. The input, output and gate sockets are the Weidmuller type

(orange-coloured).

IMPORTANT: Check with the lab supervisor or demonstrator if you are unsure before you

perform any test on the converter.

(SAFETY COMES FIRST)

Figure 2. PCB Layout for boost converter

Page 29: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 29 ELEC5451 B.Chong (2012/2013 Session)

Section 2: DEVELOPING SWITCHING CIRCUIT FOR MOSFET

A general block diagram for the switching circuit is illustrated in Figure 3. This consists offollowing components:

a) Microcontrollerb) Opto-couplerc) MOSFET DRIVER.

Figure 3. Block diagram for the switching circuit

Opto-coupler

The switching circuit is actually the interface between the low power digital circuit(microcontroller) and the high power converter circuit. Hence, it is crucial to have anadequate isolation between the two networks so that any high current fault in power circuitwill not damage more expensive microcontroller and other control circuits. As observed inFigure 7 for opto-coupler internal structure, there is an electrical isolation between a LED anda photo-detector. The electrical signal from the input (ANODE-CATHODE) is firstlyconverted to light energy in the LED. The nearby photo-detector then senses the light beamand converts it back to electrical signal through an amplification circuit at the output.

As given by the corresponding truth table, we know that the output from this opto-coupler isbeing inverted (A HIGH signal in the input means a LOW in the output). Can you explainthis? Do we need any additional circuit connection? Refer to Figure 8. An input resistor, Rin

connected at the input is used to limit the current flowing through the LED. Its value can bedetermined by the relationship between the desired forward current and the typical inputforward voltage across the LED. This is given by

F

Fin

I

VR

5

Please read Page 2 and Page 9 of the datasheet for VF and IF values.

At the output, a pull-up resistor of 4.7kΩ is added (chosen according to driver specification).Can you predict what the output voltage value is when the input is HIGH (or LED isilluminated) and vice versa? You may worry about the ACTIVE LOW operation but you mayfind the solution for this when you go through the driver.

Microcontroller

Opto-coupler Driver

Gating signalfor MOSFET

Page 30: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 30 ELEC5451 B.Chong (2012/2013 Session)

Notice that there are two power supplies connected to this component. A ceramic capacitor100nF is also connected across VCC and GND. To reduce noise interference, the capacitorshould be physically as close to the opto-coupler as possible.

IMPORTANT: You MUST make sure that the two power supplies are properly isolated. Thegrounds of both supplies MUST NOT be ‘common’. The 5V supply is the same as the onewhich powers the microcontroller whilst the 15V supply will also supplies energy to thedriver circuit.

Figure 7. Pin diagram for HCPL – 4503 Optocoupler

Figure 8. External connection for opto-coupler circuit

Driver

This component provides the driving signal (with sufficient current and voltage level) to

appropriately turn on and turn off the device which in our case is the power MOSFET (VH =

15V and VL = 0V). We shall use TD351which is advanced driver for MOSFET or IGBT. Its

general pins diagram is shown in Figure 9.

Page 31: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 31 ELEC5451 B.Chong (2012/2013 Session)

Figure 9. Pins diagram for TD351 driver

There are various attractive features for this driver. These include the innovative active Miller

clamp function which obviates negative gate drive in most applications and two-level turn-off

feature with adjustable level and delay. Whilst the latter can protects against excessive

overvoltage at turn off in the case of overcurrent/short-circuit condition, the former can

reduce voltage spike on the device gate. In this laboratory, one level turn-off is sufficient for

our application but we still include the Miller clamp function in our gating circuit.

External circuit has to be connected to this component and this is illustrated in circuit diagram

shown in Figure 10.

Figure 10. Gate driver circuit with TD351

Notice that the input has been pulled up to positive supply of 15V through a 4.7KΩ. When the

input is driven low, the output is high cancelling the inverted effect by the opto-coupler. Since

one-level turn off is used, VREFand CD are connected with 4.7KΩ. (If you embark on two-

level turn off in future, you have to connect a capacitor to each of these two pins as explained

in Page 5/12 of the datasheet.). The gating resistor (47Ω) is sufficient to turn on the MOSFET

quickly but not too small that the current capability limit is exceeded. As can be observed, the

gating voltage is constantly connected back to CLAMP pin for Miller Active Clamp function.

Please read Page 5/12 of datasheet and Page 5/15 of TD351 Application Note for more

details.

Similar to opto-coupler, a capacitor is connected closely to the VH and VL pins of the driver.

In order for the device to operate properly, another connection is needed between the

MOSFET source and the negative terminal of 15V supply.

Page 32: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 32 ELEC5451 B.Chong (2012/2013 Session)

Again, remember that all power sources (5V, 15V and your power circuit supplies) have to be

isolated. Make sure their grounds are NOT on the common point!

In this part, you are expected to make necessary connections for all the above described

circuits. DO NOT connect these circuits to the power converter you have built. You are

expected to conduct some tests and make some observations on each of the circuit.

You have to bear the following points in mind before you do the tests.

Confirm with lab supervisor or demonstrator before you turn on your supplies.

Build and test the circuit independently. (Microcontroller, Opto-coupler and Driver).

Get ready with paper and pen as you need to make some observations (sketches and

voltage measurements) and when you are ready, perform the following task.

Test on Opto-coupler

Task 1: Make all necessary connections and test on the circuit by just using TTL input (5V –

HIGH, 0V - LOW) from a signal generator. Make sure you have the same frequency as that

obtained from microcontroller output. Make sure you apply the CORRECT power supply!

Confirm your connection with the lab supervisor or demonstrator. Observe the input and

output waveforms.

Task 2: Replace the signal generator with the microcontroller. Check if you obtain expected

outputs when you vary the duty cycle. Now can you see any difference in the output from the

input of opto-coupler? Confirm your finding by repeating with a set of duty cycle values.

Test on Driver

Task 1: Make all necessary connections linking the driver to the opto-coupler and

microcontroller. Make sure you apply the CORRECT power supply! Confirm your

connection with the lab supervisor or demonstrator. Observe the input and output waveforms

when you repeat again with a set of duty cycle values.

You are also expected to sketch all the following waveforms when the input potentiometer is

respectively measured at 1.5V, 2.5V, 3.5V and 4.5V

a) Output from Microcontroller

b) Output from Optocoupler

c) Output from Driver

Provide supportive explanation for your obtained results.

Section 3: TESTING THE BOOST CONVERTER

Page 33: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 33 ELEC5451 B.Chong (2012/2013 Session)

Figure 11. Application of converter to electric bulbs

REMEMBER: CONFIRM WITH LAB SUPERVISOR OR DEMONSTRATOR

BEFORE YOU TURN ON THE SUPPLY.

DANGER: YOU ARE NOW DEALING WITH POWER CIRCUIT – MAKE

DISCONNECTION ONLY WHEN YOU HAVE TURNED OFF ALL SUPPLIES

Task 1: Use your built converter to regulate the voltage across two-serially connected electric

bulbs as shown in Figure 11. Connect a 5V 2A to the input and the gate is driven by the

switching circuit you have built.

Task 2: Vary the duty cycle of the PWM signal and observe the bulb brightness. Also

observe the voltage across both the bulbs. Does it satisfy the input-output voltage relationship

for boost converter? If not, why? (HINTS: Analyse boost converter operation when switch is

turn on and turn off respectively. When you do this, reflect on the losses/voltage drops which

may occur in any components/devices. Confirm your results with any relevant datasheets)

You are expected to observe the output voltage values corresponding to input potentiometer

of 1.5V, 3.5V and 4.5V. What are the applied duty cycles? List all the obtained measurement

in a table. Discuss on the results.

Section 4: IDENTIFYING CURRENT-VOLTAGE CHARACTERISTICS OFA PRACTICAL PV PANEL

In this laboratory, a PV panel with a sun simulator setup has been prepared for you. The

latter is used to practically simulate various weather conditions under which the PV system

is experiencing. For this part, you are given a rheostat, which is sufficiently large to

consume the energy generated by PV. You are expected to connect this component across

the PV out as shown in Figure 1. Note that an ammeter and a voltmeter are included in the

connection.

S

DL

C2C1

G

+ +

__

5V

Page 34: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 34 ELEC5451 B.Chong (2012/2013 Session)

To derive the I-V characteristics of the PV panel, the rheostat has to be adjusted accordingly.

Task 1: Can you explain the relationship between the resistance values of the rheostat

and the I-V characteristics you will obtain later?

Task 2: You should obtain two sets of I-V characteristics. The first is when the

ambient temperatures (T1, T2, T3) are low under three solar irradiation levels (G1,

G2, G3). The second one is when the ambient temperatures are high (T4, T5, T6)

under the same irradiation levels (G1, G2, G3).

For this task, you should be able to fill up the following table

A

V

Page 35: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 35 ELEC 5451 B. Chong (2012/2013 Session)

Low Temperature (23 – 26oC)

T1 T2 T3

G1 G2 G3

VPV IPV VPV IPV VPV IPV

Task 3: Note that you are not expected to measure the resistance of the rheostat.

Therefore for each weather condition in task 2, derive the variation of the rheostat

resistance. Does it conform to the relationship you state in Task 1? How would your

measured I-V characteristics be different from the theoretical ones? Also observe the

values for open circuit voltage and short circuit current when the weather changes.

Task 4: Under each weather condition, deduce the maximum power point and list them

all under a table. Can you see how the points vary when the weather conditions are

changing?

Section 5: INVESTIGATION OF DC-DC CONVERTER USED FORCONTROLLING PV TERMINAL VOLTAGE

For this part, the lab supervisor will demonstrate how the PV voltage can be controlled by

the DC-DC converter. The output of the converter is connected with a CONSTANT load.

Task 1: Perform various tests with four different values of duty cycles under a “fixed”

weather condition. Observe the PV voltage and current. What does the DC-DC converter

function as? What happens when duty cycle is regulated? Referring to the answers you

provided for the previous two questions, can you explain the action in duty cycle regulation

by relating the I-V characteristics you obtained. (Hint: You need the fundamental Ohm’s

law for this.)

High Temperature (31 – 35oC)

T4 T5 T6

G1 G2 G3

VPV IPV VPV IPV VPV IPV

(You should obtain enough I-V pairs so that your I-V graphs can be accurately sketched.)

Page 36: Pic Micro controller Based PWM

The University of Leeds School of Electronic & Electrical Engineering

Page | 36 ELEC 5451 B. Chong (2012/2013 Session)

References and Bibliography

[1] Datasheet of “dsPIC302011 – High – Performance Digital Signal Controllers”,

Microchip Technology Inc. DS70065D, 2005.

[2] Datasheet of 12-bit A/D Converter from “dsPIC30F Family Reference Manual

DS70065D”, Microchip Technology Inc., 2005, pp 18.1 – 18.38.

[3] Tom Markvart and Luis Castaner, “Practical handbook of photovoltaics: fundamentals

and applications”, Elsevier Advanced Technology, New York, 2003. (Available online from

library)

[4] Tomas Markvart, “Solar electricity”, 2nd Edition, Wiley, Chichester, 2000.

[5] Tore M. Undeland, William P. Robbins, “Power electronics: converters, applications,

and design”, John Wiley & Sons, Hoboken, NJ, 2003. (Available online from library)

and other references can be found in library or online journals by typing keywords, “Power

Electronics, dc-dc converter, Photovoltaic, digital implementation of PWM generator, gate

drive circuit, MOSFET etc.”