Abstract - Mustafa's E-Portfolio - Home



407239-880362Frequency converter and variable speed drivesAssessment TitleProgramme Title: ENB6008Bachelor of Engineering TechnologyCourse No.:Course Title:Power ElectronicsStudentName:Mustafa alansariStudentID:201000754Date submitted: 31 / 11 / 2014Due Date: 31 / 11 / 2014By submitting this assessment for marking, either electronically or as hard copy, I confirm the following:This assignment is our own workAny information used has been properly referenced.I understand that a copy of my work may be used for moderation.I have kept a copy of this assignmentGrade/Mark:Comments:AbstractThe aim of this assignment is to design build test sine wave generator ( 50/60Hz three or single phase) That can be used to drive H bridge(for DC to AC applications).However this assignment was only focusing on generating the sine wave using low pass filter without using H bridge. the setting accuracy of the output frequency must be better than 0.5% (-+0.25 Hz in 50Hz , and-+ 0.3 HZ in 60Hz). The other requirement of this assignment is to make it a variable frequency(10hz-80Hz) using quadrature encoder, and the frequency resolution should be better than half of a hertz. In order to achieve this, a microcontroller such as MBED LPC1768 must be used to generate high PWM frequency, and then changing the duty cycle to generate one complete cycle of a sine wave using RC low pass filter which is used as a digital to analog converter. Two programs were written, the first program has an issue which will be explained further in the report. The second code was the solution for the issue which is using DDS ( direct digital synthesis) to generate a high resolution sine wave. When the reset button of the mbed is pressed, all the output go high, and this will result a short circuit in the H bridge circuitry, the report will explain how the this problem was faced.Objectivebeing able to write an MBED code to generate single/three phase sine wavebeing able to convert frequencies (50hz/60hz )of a sine wave using a switch with setting accuracy better than 0.5%being able control the sine wave frequency using shaft/ quadrature encoder with a setting accuracy better than 0.5%being able to apply the DDS to increase the frequency resolutionDesign circuitry to make all outputs to go low when the reset button is pressed Contents TOC \o "1-3" \h \z \u Abstract PAGEREF _Toc405150320 \h 2Objective PAGEREF _Toc405150321 \h 2Simulation section PAGEREF _Toc405150322 \h 4Experimental section PAGEREF _Toc405150323 \h 7Finding the setting accuracy after using the DDS: PAGEREF _Toc405150324 \h 7Frequency converter PAGEREF _Toc405150325 \h 7Variable speed drives PAGEREF _Toc405150326 \h 10Solution to the reset problem. PAGEREF _Toc405150327 \h 12Questions section PAGEREF _Toc405150328 \h 14 Figures TOC \h \z \c "Figure" Figure 1sine wave using for loop method PAGEREF _Toc405154238 \h 5Figure 2 sine wave using DDS (50Hz) PAGEREF _Toc405154239 \h 8Figure 3 sine wave using DDS (60Hz) PAGEREF _Toc405154240 \h 9Figure 4 three phase sine wave generated using phase array PAGEREF _Toc405154241 \h 10Figure 5 sine wave using DDS (10Hz) PAGEREF _Toc405154242 \h 11Figure 6 sine wave using DDS (80Hz) PAGEREF _Toc405154243 \h 12Figure 7 schematic circuit of the frequency converter, and variable speed drive circuit using microcontroller PAGEREF _Toc405154244 \h 13 Table of tables TOC \h \z \c "Table" Table 1 the setting accuracy before using for loop method PAGEREF _Toc405154321 \h 6Table 2 the setting accuracy after using the DDS method PAGEREF _Toc405154322 \h 7Table 3 using DDS method PAGEREF _Toc405154323 \h 16Table 4 using for loop method PAGEREF _Toc405154324 \h 16 Simulation sectionFirst of all, an MBED code was written to generate a single phase sine wave with the following specification:128 sampling rate or division frequency of 50 Hz with setting accuracy less than 0.5%the PWMr frequency must be 16KhzThe way the sine wave is generated is by using the duty cycle to determine the amplitude using the following formulaVout=Vin*Dwhere Vin is 3.3 V ( the mbed pins voltage)D is the duty cycle The above figure is an example of how the single is generated using DAC ( digital to analog converter) which is a low pass filter. The following code was used to generate the sine wave#include "mbed.h"#define pi 3.14159PwmOut myled(LED3);PwmOut myled1(LED1);PwmOut out(p21);PwmOut out1(p22);PwmOut out2(p23); int main() { out.period_us(62); while(1) { for( int count=0; count<128; count++){ out= float(0.5+(sin(2*pi*(count/127.0))/2.0)); wait_us(57); } }}note: wait should be 156.25 us to output 50 Hz but the Mbed takes time to do the calculation which is greater than this value. therefore the "wait" has been changed to output 50 Hz.Figure 1sine wave using for loop methodAs it is shown above the frequency is almost 50 Hz, According to the specification requirement the setting accuracy should be better than 0.5 %. the table above will represents different frequency to see the if the setting accuracy is more less than 0.5%Table 1 the setting accuracy before using for loop methodFrequency Count Delta Frequency/ Delta countSetting Accuracy 50 47.857 640.3140.6%605731380.420.7%71.36710 170.6140.86%The table above does not agree with the requirement of the project as the setting accuracy is more than 0.5 %. Moreover, the frequency cannot reach 80 Hertz. to conclude, this method is useless because this assignment aims to output a range of frequencies between 10Hz-80Hz, and the maximum output is 77 Hz using this method. As a result, the DDS method will be used. the sine wave is generated by using for loop inside an infinite while loop. the function of the for loop is to output continuous sine wave. in other word it will generate one cycle of sine wave, then will repeat itself ,the problem is the process will keep repeating which causing the mbed to spend time to do the calculations over and over again. This results, the maximum frequency of the sine wave to be low ( less than 80Hz). To fix this problem, a phase array was used ( also known as sine lookup table). the function of this array is to save the sine wave value from 0- 2*pi(one cycle) in an array, and will keep repeating it . This method has fixed that problem which the frequency exceeds 80 HZ, but the setting accuracy is still greater than 0.5%. So, DDS method was used to let the setting accuracy to be better than 0.5%. The following section will discuss how the DDS was implemented to set the resolution of the sine wave frequency to be better than 0.5%Experimental sectionThis section will include the DDS method which is used in applications that requires higher resolutions frequency such as oscilloscopes. The last thing that was done to improve the frequency resolution is creating phase array which it saves the mbed time instead of doing the calculation every time ( in an infinite loop), it will do it once, and will start calling it again in an infinite loop. so DDS was added to this code. a counter was declared as an integer . the counter is incremented by a set amount (the Frequency Increment) every sample. The output from the counter is used as an index into a waveform phase array. Finding the setting accuracy after using the DDS:Table 2 the setting accuracy after using the DDS methodFrequency Count Frequency/countSetting Accuracy 50.01 50.21888 18950.0270.05%60.0860.26 226822750.0260.04%8080.183020 30270.0260.03%The table above shows that the frequency changes by few number of hertz when the count is increasing by 7. the accuracy is almost 0.05%. this mean that the resolution is higher than using "wait". This project will be designedFrequency converterater generating 50 Hz using DDS method , a switch was used to change the frequency to 60 Hz ( if the switch is on this mean 50 Hz, and if it was off this mean 60HZ) the switch was used with pull down resistor. the following graphs show figures of 50 hz and 60 HzFigure 2 sine wave using DDS (50Hz)The following formula was used to generate sine wave with frequency of 60 Hz:fo=M*fc2nWhere:fo is the desired frequencyM= the phase accumalator value( how much the phase wheel will increment ) n= the length of the array that was shiftedFc= the internal frequency clock in order to find Fo (60hz) Fc was found , so Fc became the subject of the following equation50=1888*fc215-1fc=434 HzFC changes as the length of the array that is shifted is changedto output 60 Hz M has to be manipulated, it can be determine using the following equation60=M*434215-1M=2265Then M was used in the code in MBED , and the following qraph was the output .lFigure 3 sine wave using DDS (60Hz)This was followed by generating three phase sine waves. this was done by adding the same formula as generating the signle sine wave, but with a phase shift of 120 and 240 degree with the respect to the first sine wave. note that the values of the new sine waves were stored in a new phase arrays which are called phase_3 , and Phase_2. the following figure shows a three phase sine wave:Figure 4 three phase sine wave generated using phase arrayVariable speed driveA part of this assignment is to write a code in Mbed that can be used to control the frequency of a sine wave by using a quardrature encode. an application of this is controlling the speed of a motor. The quardrature encoder has 5 pins two are grounded(pin1 ,and pin5) the second , and the forth pins are the output if the quardrature. the quardrature encoder was connected to in mbed digital input, because the quardrature generate digital output. The mbed has the ability to understand the output of the quardrature if it used for increasing or deacreasing the value by using "get pulse" command. the explanation of this is that the outputs of the quardrature(A and B) are out of phase (square waves). so by moving the knob in clock wise, the mbed will start knowing that A is giving pulses faster than B than it will start increasing as the number of pulses increasing. Now if the quardrature encoder was moved in counter clock wise then the mbed will see that B is giving pulses faster than A, and will realize that the value of b is increasing so, it will now decrease the value in the mbed. The encoder was used to change the frequency from 10 Hz to 80 Hz. Figure 5 sine wave using DDS (10Hz)Figure 6 sine wave using DDS (80Hz)Solution to the reset problem.the goal of this assignment is to use the PWM that is produced by the Mbed to Drive single/ three phase H bride, and when the reset button of the Mbed is pressed all the outputs go high, resulting short circuit in the H bridge circuit. The solution to this problem is to let the all the output to go low instead of high. This can be done using Logic gates or transistor with diode which is basically a logic gates. in this assignment three diodes , and a transistor were used. The following figure shows the schematic circuit of the whole circuit:Figure 7 schematic circuit of the frequency converter, and variable speed drive circuit using microcontrollerThe explanation of the solution will be divided into two scenarios, when the reset button is pressed, and one when it is not pressed: The first scenarioFirst of all, a digital output was declared in the Mbed it was named pin1 as shown in figure #. This output was initialized as zero, and it was connect to the base of the transistor ( BC 457C). three diodes IN4148 type were connected to the collector of the transistor , and the other sides were connected to PWM pins as shown in the figure. The emitter was connected to ground. So when the reset button is pressed this mean that the transistor will be switched on because it is connected to pin1. when it is switched on all the current will take the easiest path which is from the drain, all the way down to ground. resulting all the PWM pins to go low. After that it was noticed that the output does not go to zero, but to 0.6V because of the voltage across the diode. As a result, MOSFET drivers TC 4427 were used to let the output go to 0 volt. The reason why the MOSFET driver is used is because it switched on at 2.5 V. so when 0.6V applies into its input the output will be zero.Note- all the resistors are used as current limiters.The second scenario:the second scenario is when the reset button is not pressed. This mean that all the outputs will behave normally. Pin1 will be low which results the transistor to switch off. Now, say that all the outputs (PWM) are high. The current will not get to the other outputs because the diode will block it as it is allow the current to pass in one direction. this will result the current to go the easiest path which is the Phase outputs as show in the picture. Questions sectionHow many samples in one sine wave time period?128 samples in one cycle .What limits the number of samples in the sine wave?How big "int" is , in this assignment it is 2^32What is the theory behind this method?The idea behind this method is basically, two arrays are created, one(A) is filled with ones (i.e the number 127 has 7 ones(binary) in array size of2^ 8-1). another array(B) is created, A counter will be used in this array(phase accumulator), and shifting bits in the array will be used. if A&B , and B was filled with ones, then the output will have a very huge frequency . So a counter, and abit shift is used to slow down the frequency , and the sine wave is generated by the counter. The counter is incremented by a set amount (the Frequency Increment) every sample. The output from the counter is used as an index into a waveform phase array. What is the equation controlling the output frequency?fo=M*fc2nThis equation was discussed in the frequency converter sectionConclusionIn conclusion, The aim of this project was to be able to generate a sine wave with a setting accuracy better than 0.5%, and changing the frequency from 50 to 60 Hz using switch. Also, This assignment aims to use a shaft encoder to be able to change the frequency of a sine wave from 10- 80Hz.Different Method were tried to generate the sine wave. The first one was the for loop method, which has many issues such as the sitting accuracy is bad, and the frequency is not able to go up to 100Hz. To fix this issure, DDS method was used which it give better resolution frequency, and it is able to go up to 400 Hz with a setting accuracy less than 0.1%. Table 3 using DDS methodFrequency Count Frequency/countSetting Accuracy 50.01 50.21888 18950.0270.05%60.0860.26 226822750.0260.04%Table 4 using for loop methodFrequency Count Delta Frequency/ Delta countSetting Accuracy 50 47.857 640.3140.6%605731380.420.7%References "mbed.h"#include "QEI.h"#define pi 3.14159#define size 128PwmOut out(p21); // giving the outout a name to use it as PWM ( p is the pin number) PwmOut out1(p22); // giving the outout a name to use it as PWM indentify QEI shaft (p15, p16, NC,6 ); // giving a name from the input that is connected to to the shat encoder output.PwmOut out2(p23); // giving the outout a name to use it as PWM DigitalOut low(p30); //decleard a digital outputDigitalIn sw(p5); //declear a digital outputDigitalIn sw1(p6);DigitalIn sw2(p7);float phase_1[size];// make an array to save the sine wave valuesfloat phase_2[size];// make an array to save the sine wave valuesfloat phase_3[size]; // make an array to save the sine wave valuesint counting; // declearing an interger variableint shifting; // declearing an interger variableint c;int p;int shaftVal;int main(){ low=0; // let the output to be low 0 Volts out.period_us(62.5); // setting the period of the PWM for(int count=0; count<128; count++) { // for loop phase_1[count]=float(0.5+(sin(2*pi*(count/127.0))/2.0)); // save the sine wave in an array phase_2[count]=float(0.5+(sin(2*pi*(count/127.0)+(2*pi/3))/2.0)); // save the sine wave in an array phase_3[count]=float(0.5+(sin(2*pi*(count/127.0)+(4*pi/3))/2.0)); // save the sine wave in an array } shaft.reset(); // reset the shaft value when the program. if(!sw) { counting=1888 ; // phase accumalator shifting=15; // shafting the array both paramameters determines the the frequency which is 50 Hz } else { counting=2268 ;// phase accumalator shifting=15 ; // shafting the array both paramameters determines the the frequency which is 60 Hz } while(true) { shaftVal=1*shaft.getPulses(); // take the values from the shaft encoder c+=counting+shaftVal; // countig from 0- 2 to the power of 32 p=(c>>shifting)& 127; // counting from 0 - 127 ( it reapeats the values fror example 00 11 22 33... till 127127) out= phase_1[p];// call the values in the phase array0 out1= phase_2[p] ; // call the values in the phase array1 out2= phase_3[p]; // call the values in the phase array2 }} ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download