abstractmostafasportfolio.weebly.com/.../mustafa_isa_frequency…  · web viewthe last thing that...

25
201000754 StudentID: Mustafa alansari StudentName: Course Title: Course No.: Programme Title: Due Date: 31 / 11 / 2014 Date submitted: 31 / 11 / Grade/Mark: Comments: Assessment Title By submitting this assessment for marking, either electronically or as hard copy, I confirm the following: This assignment is our own work Any information used has been properly referenced. Power Electronics Bachelor of Engineering Technology ENB6008 Frequency converter and variable speed drives

Upload: truongngoc

Post on 15-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

201000754StudentID:

Mustafa alansariStudentName:

Course Title:

Course No.:

Programme Title:

Due Date: 31 / 11 / 2014 Date submitted: 31 / 11 / 2014

Grade/Mark:

Comments:

Assessment Title

By submitting this assessment for marking, either electronically or as hard copy, I confirm the following:

This assignment is our own work Any information used has been properly referenced. I understand that a copy of my work may be used for moderation.

Power Electronics

Bachelor of Engineering Technology

ENB6008

Frequency converter and variable speed drives

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.

Objective being able to write an MBED code to generate single/three phase sine wave

being 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 resolution Design circuitry to make all outputs to go low when the reset button is pressed

ContentsAbstract.......................................................................................................................................................2

Objective.....................................................................................................................................................2

Simulation section.......................................................................................................................................4

Experimental section...................................................................................................................................7

Finding the setting accuracy after using the DDS:....................................................................................7

Frequency converter...................................................................................................................................7

Variable speed drives................................................................................................................................10

Solution to the reset problem...................................................................................................................12

Questions section......................................................................................................................................14

FiguresFigure 1sine wave using for loop method....................................................................................................5Figure 2 sine wave using DDS (50Hz)...........................................................................................................8Figure 3 sine wave using DDS (60Hz)...........................................................................................................9Figure 4 three phase sine wave generated using phase array...................................................................10Figure 5 sine wave using DDS (10Hz).........................................................................................................11Figure 6 sine wave using DDS (80Hz).........................................................................................................12Figure 7 schematic circuit of the frequency converter, and variable speed drive circuit using microcontroller..........................................................................................................................................13

Table of tablesTable 1 the setting accuracy before using for loop method........................................................................6Table 2 the setting accuracy after using the DDS method...........................................................................7Table 3 using DDS method.........................................................................................................................16Table 4 using for loop method...................................................................................................................16

Simulation section

First 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 16Khz

The way the sine wave is generated is by using the duty cycle to determine the amplitude using the following formula

Vout=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.14159

PwmOut 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 method

As 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 method

Frequency Count Delta Frequency/ Delta count

Setting Accuracy

50 47.8

57 64

0.314 0.6%

60 57

31 38

0.42 0.7%

71.3 67

10 17

0.614 0.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 method

Frequency Count Frequency/count Setting Accuracy 50.01 50.2

1888 1895

0.027 0.05%

60.08 60.26

2268 2275

0.026 0.04%

80 80.18

3020 3027

0.026 0.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 designed

Frequency converter

ater 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 Hz

Figure 2 sine wave using DDS (50Hz)

The following formula was used to generate sine wave with frequency of 60 Hz:

fo=M∗fc2n

Where:

fo is the desired frequency

M= the phase accumalator value( how much the phase wheel will increment )

n= the length of the array that was shifted

Fc= the internal frequency clock

in order to find Fo (60hz) Fc was found , so Fc became the subject of the following equation

50= (1888 )∗fc215−1

fc=434Hz

FC changes as the length of the array that is shifted is changed

to output 60 Hz M has to be manipulated, it can be determine using the following equation

60=M∗434215−1

M=2265

Then M was used in the code in MBED , and the following qraph was the output .

l

Figure 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 array

Variable 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 microcontroller

The 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 scenario

First 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 sectiona) How many samples in one sine wave time period?

- 128 samples in one cycle .b) What limits the number of samples in the sine wave?

- How big "int" is , in this assignment it is 2^32c) What 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∗fc2n

This equation was discussed in the frequency converter section

ConclusionIn 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 method

Frequency Count Frequency/count Setting Accuracy 50.01 50.2

1888 1895

0.027 0.05%

60.08 60.26

2268 2275

0.026 0.04%

Table 4 using for loop method

Frequency Count Delta Frequency/ Delta count

Setting Accuracy

50 47.8

57 64

0.314 0.6%

60 57

31 38

0.42 0.7%

References

http://www.ocfreaks.com/sine-wave-generator-using-pwm-lpc2148-microcontroller-tutorial/

http://interface.khm.de/index.php/lab/interfaces-advanced/arduino-dds-sinewave-generator/

http://www.analog.com/library/analogDialogue/archives/38-08/dds.html

http://www.electricdruid.net/index.php?page=info.dds

Appendix#include "mbed.h"

#include "QEI.h"

#define pi 3.14159

#define size 128

PwmOut 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 output

DigitalIn sw(p5); //declear a digital output

DigitalIn sw1(p6);

DigitalIn sw2(p7);

float phase_1[size];// make an array to save the sine wave values

float phase_2[size];// make an array to save the sine wave values

float phase_3[size]; // make an array to save the sine wave values

int counting; // declearing an interger variable

int shifting; // declearing an interger variable

int 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

}

}