single phase ac motor speed control report with altium files

39
Single Phase AC Motor Speed Control Muhammad Fahad Ahmed Asad Ali Khan Haseeb Fayyaz Abbasi MS System Engineering 2012-14 Supervised By Mr. Nauman Masood

Upload: haseeb-fayyaz-abbasi

Post on 26-Oct-2015

44 views

Category:

Documents


1 download

DESCRIPTION

It is about Single Phase AC Motor Speed Control Report

TRANSCRIPT

Page 1: Single Phase AC Motor Speed Control Report With Altium Files

Single Phase AC Motor Speed Control

Muhammad

Fahad Ahmed

Asad Ali Khan

Haseeb Fayyaz Abbasi

MS System Engineering 2012-14

Supervised By

Mr. Nauman Masood

Pakistan Institute of Engineering & Applied Sciences,

Page 2: Single Phase AC Motor Speed Control Report With Altium Files

ii

Nilore-45650, Islamabad

Page 3: Single Phase AC Motor Speed Control Report With Altium Files

iii

Declaration of Originality

I hereby declare that the work contained in this report and the intellectual content of

this report are the product of my own work. This report has not been previously

published in any form nor does it contain any verbatim of the published resources

which could be treated as infringement of the international copyright law.

I also declare that I do understand the terms ‘copyright’ and ‘plagiarism,’ and that in

case of any copyright violation or plagiarism found in this work, I will be held fully

responsible of the consequences of any such violation.

Signature: ____________

Author’s Name: Muhammad

Signature: ____________

Author’s Name: Fahad Ahmed

Signature: ____________

Author’s Name: Asad Ali Khan

Signature: ____________

Author’s Name: Haseeb Fayyaz Abbasi

Page 4: Single Phase AC Motor Speed Control Report With Altium Files

iv

Acknowledgement

Gratitude and endless thanks to Allah Almighty, the Lord of the World, who

bestowed mankind, the light of knowledge through laurels of perception, learning and

reasoning, in the way of searching, inquiring and finding the ultimate truth. To whom

we serve, and to whom we pray for help.

Apart from the efforts of myself, the success of any project depends largely on

the encouragement and guidelines of many others. I take this opportunity to express

my gratitude to the people who have been instrumental in the successful completion

of this project.

I feel my privilege and honor to express my sincere gratitude to my supervisor

Mr. Nauman Masood for all their kind help, guidance, suggestions and support

through the development of this project.

I would like to express my special thanks and gratitude to Dr Aqil for his

support and guidance in carrying out this project work

Finally, I would also like to thank Pakistan Institute of Engineering and

Applied Sciences for providing very conducive educational environment.

Page 5: Single Phase AC Motor Speed Control Report With Altium Files

v

Table of Contents

Table of Contents....................................................................................................v

List of Figures.........................................................................................................vi

Abstract................................................................................................................vii

Chapter 1. Introduction......................................................................................1

1.1 Speed Control....................................................................................................1

1.1.1 Pole Changing..................................................................................................................1

1.1.2 Variable Rotor Resistance................................................................................................1

1.1.3 Variable Frequency..........................................................................................................1

1.2 The motive for keeping V/f constant with adjustable speed drives.....................2

Chapter 2. Circuit Description............................................................................4

2.1 Low Power Circuit:.............................................................................................4

2.1.1 Isolation Supplies:............................................................................................................4

2.1.2 Regulator.........................................................................................................................5

2.1.3 Microcontroller................................................................................................................6

2.1.4 Dead Time........................................................................................................................7

2.1.5 CMOS Buffer (4050) and Inverting Buffer (4049):............................................................9

2.1.6 4049 hex NOT and 4050 hex buffer.................................................................................9

2.1.7 Opto-Coupler HCPL4502:...............................................................................................10

2.2 High Power Circuit:..........................................................................................11

Chapter 3. Coding and Flow Chart....................................................................13

3.1 ECCP1CON:......................................................................................................13

3.2 PR2:.................................................................................................................13

3.3 ECCPR1L:..........................................................................................................14

3.4 ECCP1DEL:........................................................................................................14

Chapter 4. Results and Simulations..................................................................16

Conclusion.............................................................................................................18

Future Recommendations.....................................................................................19

Appendix.................................................................................................................... 20

Page 6: Single Phase AC Motor Speed Control Report With Altium Files

vi

List of FiguresFigure 2-1: Isolation Supply for Microcontroller.................................................................................4

Figure 2-2: Isolation Supplies.................................................................................................................5

Figure 2-3: Regulator..............................................................................................................................6

Figure 2-4: Microcontroller and its interfacing....................................................................................7

Figure 2-5: Driving H-Bridge using ECCP module with dead band delay........................................8

Figure 2-6: Optical Isolation Sceheme...................................................................................................9

Figure 2-7: Buffer..................................................................................................................................10

Figure 2-8: Octo-Coupler......................................................................................................................10

Figure 2-9: High power circuit block diagram...................................................................................11

Figure 2-10: PCBs. (a) Low power circuit, (b) High power circuit...................................................12

Figure 3-1 Flow chart representing flow of implemented algorithm................................................15

Figure 4-1: Comparison of sinusoidal wave with triangular wave...................................................16

Figure 4-2: Bipolar Pulses.....................................................................................................................16

Figure 4-3: 10 µsec dead time introduced in between the gate signals of higher and the lower

switches..........................................................................................................................................17

Figure 4-4: Fundamental component of pulses........................................................................................17

Page 7: Single Phase AC Motor Speed Control Report With Altium Files

vii

Abstract

Induction motors are ubiquitous. They form a major portion of electrical power

consumption. Motor-driven systems are often designed to handle peak loads. This

often leads to energy inefficiency in systems that operate for extended periods at

reduced load. So, there is a need to adjust motor’s speed in such a way that enable

closer matching of motor output to load and thus results in energy savings.

Voltage Control using SCR has limited range and cause harmonic problems as well.

Therefor Frequency Control using Volts/Hertz rule is preffered over voltage control.

PWM based frequency control is widely used in industry. They requires high speed

Solid State Switches for their operation. A major requirement of such drives is to

avoid shoot through currents by providing satisfactory amount of dead band delay.

Hence a design strategy has been developed using dedicated controller to provide

dead time. Furthermore issue of floating ground is resolved through isolation supplies.

Page 8: Single Phase AC Motor Speed Control Report With Altium Files

1

Chapter 1. Introduction

This Single phase induction motors are widely used in daily life. Also Induction

motors are widely used in industry; hence they form a major portion of electrical

power consumption. In the modern Industry, Motor-driven systems are often designed

to handle peak loads that have a safety factor. This often leads to energy inefficiency

in systems that operate for extended periods at reduced load. So, there is a need to

adjust motor’s speed in such a way that enable closer matching of motor output to

load and thus results in energy savings.

1.1 Speed Control

There are number of methods devised to control the speed of ac motors, some of them

are given below:

1.1.1 Pole Changing

Early machines were designed with multiple poles to facilitate speed control by pole

changing. By switching in different numbers or combinations of poles a limited

number of fixed speeds could be obtained.

1.1.2 Variable Rotor Resistance

The speed of induction motors can however be varied over a limited range by varying

the rotor resistance but only by using wound rotor designs negating many of the

advantages of the induction motor.

1.1.3 Variable Frequency

Since motor speed depends on the speed of the rotating field, speed control can be

affected by changing the frequency of the AC power supplied to the motor.

As in most machines, the induction motor is designed to work with the flux density

just below the saturation point over most of its operating range to achieve optimum

efficiency.

The flux density B is given by:

Page 9: Single Phase AC Motor Speed Control Report With Altium Files

2

Where V is the applied voltage, f is the supply frequency and k2 is a constant

depending on the shape and configuration of the stator poles.

In other words if the flux density is constant, the Volts per Hertz is also a constant.

This is an important relationship and it has the following consequences.

For speed control, the supply voltage must increase in step with the frequency;

otherwise the flux in the machine will deviate from the desired optimum operating

point. Practical motor controllers based on frequency control must therefore have a

means of simultaneously controlling the motor supply voltage. This is known as

Volts/Hertz control.

Increasing the frequency without increasing the voltage will cause a reduction of the

flux in the magnetic circuit thus reducing the motor's output torque. The reduced

motor torque will tend to increase the slip with respect to the new supply frequency.

This in turn causes a greater current to flow in the stator, increasing the IR volt drop

across the windings as well as the I2R copper losses in the windings. The result is a

major drop in the motor efficiency. Increasing the frequency still further will

ultimately cause the motor to stall.

1.2 The motive for keeping V/f constant with adjustable

speed drives

By using variable frequency control, it is possible to adjust the speed of the motor

either above or below base speed. But it is important to maintain certain voltage and

torque limitations on the motor as the frequency is varied, to ensure safe operation.

When running at speeds below the base speed of the motor, it is necessary to reduce

the terminal voltage applied to the stator for proper operation. The terminal voltage

applied to the stator should be decreased linearly with decreasing stator frequency. If

it is not done, the steel in the core of the induction motor will saturate and excessive

magnetization currents will flow in the machine. This is because, in an induction

motor induce emf (E) is proportional to supply frequency and air-gap flux,

E ∝ f ∅If we can ignore the stator resistance and inductance then E will be approximately

equal to Vs (Stator supply voltage),

E ≅ Vs

Then,

Vs ∝ f ∅

Page 10: Single Phase AC Motor Speed Control Report With Altium Files

3

And

∅ ∝ Vs/f

Therefore when we decrease f keeping the stator supply voltage constant the flux in

the core of the motor will increase and the magnetization current of the motor will

also increase. But induction motors are normally designed to operate near the

saturation point on their magnetization curves, so the increase in flux due to decrease

in frequency will cause excessive magnetization currents to flow in the motor. To

avoid from this effect it is customary to keep V/f ratio constant.

1.3 Comparison of speed controllability with frequency

control and voltage control

By using variable frequency control, it is possible to adjust the speed of the motor

either above or below base speed. A properly designed variable frequency induction

motor can control the speed over a range from as little as 5% of base speed up to

about twice base speed. The torque developed by an induction motor is proportional

to the square of the applied voltage. Therefore the speed of the motor may be

controlled over a limited range by varying the line voltage. This method is sometimes

used on small motor driving fans.

1.4 Objective:

Aim of this project is to develop PWM based Single Phase AC Motor Speed Control

Mechanism in which V/f ratio is kept constant and to resolve dead time and floating

ground issues.

Page 11: Single Phase AC Motor Speed Control Report With Altium Files

4

Chapter 2. Circuit Description

The circuit of our ac motor speed drive has been separated into two sub circuitries,

low power circuit and high power circuit. Each of these modules has been described

below:

2.1 Low Power Circuit:

Low power circuit consist of following components

2.1.1 Isolation Supplies:

In order to resolve the issue of floating ground, isolation supplies are required

to provide gate to source voltage for the MOSFETs of H-bridge. There are 4 isolation

supplies in this circuit two for upper MOSFETs (one for each) and one supply for

lower two MOSFETs. Fourth isolation supply is used for Microcontroller and related

circuitry.

For this purpose isolation transformer (220/7 V r.m.s) was designed. It has 4

secondaries. These are then rectified and applied to regulators.

For Microcontroller it is regulated using LM7805 to provide 5V regulated DC power.

Figure 2-1: Isolation Supply for Microcontroller

For gate pulses it is applied to LM7806 to get 6V regulated DC power supply which is

applied at the output of opto-coupler. One of isolation supply is shown in Fig. 2-1.

There are four similar circuits.

Page 12: Single Phase AC Motor Speed Control Report With Altium Files

5

2.1.2 Regulator

The LM78XX gives positive voltage while LM79XX gives negative voltage

both are discussed below.

2.1.2.1 Fixed Positive linear Voltage Regulators

Although many types of IC regulators are available, the 78XX series of lC regulators

is representative of three-terminal devices that provide a fixed positive output voltage.

The three terminals are input, output, and ground as indicated in the standard fixed

voltage configuration in figure. The last two digits in the part number designate the

output voltage, for example 7805 is a + 5.0 V regulator.

Capacitors, although not always necessary, are sometimes used on the input and

output. The output capacitor acts basically as a line filter to improve transient

response. The input capacitor is used to prevent unwanted oscillations when the

regulator is at some distance from the power supply filter such that the line has a

significant inductance. The 78XX series can produce output currents up to in excess

of 1A when used with an adequate heat sink. The input voltage must be at least 2V

above the output voltage in order to maintain regulation. The circuits have internal

thermal overload protection and short circuit current-limiting features. Thermal

overload occurs when the internal power dissipation becomes excessive and the

temperature of the device exceeds a certain value. Almost all applications of

regulators require that the device be secured to a heat sink to prevent thermal

overload.

2.1.3 Microcontroller

In this project we used pic18f458 due to its in built feature of dead band delay found

in ECCP module. ECCP module is discussed along with code description.

Page 13: Single Phase AC Motor Speed Control Report With Altium Files

6

Figure 2-2: Microcontroller and its interfacing

2.1.4 Dead Time

The time required for turning off of a switch is usually greater than time

required turning on it. Therefore if two switches are such that one is turning on while

other is turning off there will be a short time for which both switches will be in turn

on state. If these switches are connected in series and a high voltage is applied across

the as is in case of one leg of H bridge or hex bridge a short circuit will occur. This

case occurs in bipolar PWM switching technique which is used in this project.

Therefore a dead time should be introduced so that the turning on pulse is applied

after some delay usually 10µ sec is sufficient time for it. Fortunately it is found in

ECCP module of PIC 18f458 therefore it is selected for this purpose.

In the Half-Bridge Output mode, two pins are used as outputs to drive push-

pull loads. The RD4/PSP4/ ECCP1/P1A pin has the PWM output signal, while the

RD5/PSP5/P1B pin has the complementary PWM output signal. This mode can be

used for half-bridge applications, as shown in Figure or for full-bridge applications

where four power switches are being modulated with two PWM signals. In Half-

Bridge Output mode, the programmable dead band delay can be used to prevent

shoot-through current in bridge power devices. The value of register ECCP1DEL

Page 14: Single Phase AC Motor Speed Control Report With Altium Files

7

dictates the number of clock cycles before the output is driven active. If the value is

greater than the duty cycle, the corresponding output remains inactive during the

entire cycle. Since the P1A and P1B outputs are multiplexed with the PORTD<4> and

PORTD<5> data latches, theTRISD<4> and TRISD<5> bits must be cleared

toconfigure P1A and P1B as outputs.

Figure 2-3: Driving H-Bridge using ECCP module with dead band delay

Page 15: Single Phase AC Motor Speed Control Report With Altium Files

8

2.1.5 Prevention of Micro Controller and Opto Coupler from

Loading

In order to prevent microcontroller and opto-coupler from loading CMOS

buffers are used. 4050 is used after microcontroller. As isolation supplies is not

applied yet a single package which contains six buffers (here we require only four) is

sufficient. Care must be taken for buffers at output of opto-coupler as ground is

isolated now so 3 buffers are required each for respective supply. Also in this case

buffers are inverting as there is inversion in opto-coupler output as signal is taken

from the emitter of output transistor.

VDD4

12

04

GND4

GND1

8

53

26

74 1 4502-4

AD741LNGND1

HCC4050BF2

81

10 9U15D

HCC4050BF3

81

54U11B

HCC4049BF3

5K

R12Res1

200

R11

VDD1

12

C271.5uF

12

C260.1uF

1 2C25

0.1uF

GND1GND4

Figure 2-4: Optical Isolation Sceheme

2.1.6 Isolation:

Opto-coupler provides optical isolation and here it is used in isolation supplies. The

opto-coupler selected is HCPL 4502 which is a high speed opto-coupler. As switching

frequency is greater than 2 kHz therefore use of such high speed opto-coupler is

necessary.

Maximum value of turn on and turn off time is 1 µsec. while for another common

opto-couple CNY-17 it may be as high as 42.5 µ sec.

Page 16: Single Phase AC Motor Speed Control Report With Altium Files

9

2.2 Drive Circuit:

Due to high voltage and currents involved drive circuit is fabricated on separate PCB

so as to isolate it from Low Power Control Circuit. Drive circuit consists of:

Full bridge rectifier in which 10A06 diodes are used whose rating is

10A/800V.

DC link is provided using 3900 µF /400V capacitor.

IRF 740 MOSFETs are used as switching device in H-bridge. It has rating of

10A/400V. Switching time is in order of nano seconds. Turn on time is 15-21

ns while turn off time is 42 ns.

Figure 2-5: High power circuit block diagram

Page 17: Single Phase AC Motor Speed Control Report With Altium Files

10

All the above mentioned components are assembled together to get the two pcbs of

low power circuits and high power circuit as shown in figure 2.10a and 2.10b

respectively.

(a)

(b)

Figure 2-6: PCBs. (a) Low power circuit, (b) High power circuit

Page 18: Single Phase AC Motor Speed Control Report With Altium Files

11

Chapter 3. Coding and Flow Chart

In this code when code starts first of all two arrays are initialized. In first array named

angle 51 values of angle from 0 to 2π are stored in equal steps. In second array named

sin_table corresponding duty cycles are placed (duty cycle can be in between 0-255).

After that settings of analog to digital converter (ADC) are performed by

setting the ADCON0 and ADCON1 registers to the desired value.

This code will involve timer interrupt for changing the duty cycle according

to frequency settings (voltage will also be changed according to V/f rule along with

changing of frequency) dictated by ADC. Therefore timer (Timer 0) and interrupt

settings are performed next involving setting of global interrupt enable (GIE bit in

INTCON register). Analog to Digital Interrupt enable (ADIE bit in PIE1 register)

timer 0 interrupt is enabled (TMR0IE bit in INTCON register) Timer 0 Interrupt flag

is cleared.

After that PWM is enabled. Following register are involved in PWM settings

3.1 PWM Control Register (ECCP1CON):

This is ECCP1 control registers. From here we can select whether to use

ECCP module as capture, compare or PWM module. Here in this code we are using it

as PWM module.

In PWM mode we can select one of following four configurations

Single output Full Bridge Half Bridge Full Bridge Reverse.

These settings are also performed using ECCP1CON register.

Here we are using it as Half Bridge due to its in built feature of dead band delay. The

use of ECCP module in half bridge PWM with dead band delay will be further

explained under PIC 18f458 microcontroller.

Page 19: Single Phase AC Motor Speed Control Report With Altium Files

12

3.2 Period Registor (PR2):

PR2 stands for timer 2 Period register. From here we can set the switching

frequency for PWM.

3.3 Duty Cycle Registor (ECCPR1L):

It is an eight bit register which is used in PWM mode for setting of duty cycle.

When 0 is placed in ECCPR1L duty cycle is 0%.

When 255 are placed in ECCPR1L duty cycle is 100%.

When x is placed in ECCPR1L duty cycle is ((x/255) x100) %.

3.4 Dead-band delay Registor (ECCP1DEL):

This register is used for the setting of dead band delay in half bridge mode. Its

operation is discussed while discussing Dead Time in inverters.

After enabling PWM duty cycle is set continuously is while 1 loop and it repeats

forever until microcontroller is turned off.

Now up to here we have discussed firmware flow chart now we will discuss

main firmware of code now we will discuss interrupt service routine. The timer

settings are such that interrupt service routine occurs every 0.4ms. In this service

routine duty cycle is changed in such a manner that when these PWM pulses will be

applied to inverter due to filtering effect of high inductance of motors current will be

sinusoidal.

When interrupt occurs timer (timer 0) is disabled so that another interrupt does

not occur during this period. Timer 0 flag is cleared (as it is set after interrupt occurs

so it is cleared so it may be set during next interrupt). As (θ=ω*t) so t is incremented

in each interrupt and corresponding value of theta is calculated. If this value equals 2π

t is reset to 0. And then corresponding angle is sorted from angle array initialized at

beginning. After sorting corresponding duty cycle is taken from sin_table array and is

manipulated according to V/f rule and is updated in ECCPR1L register.

Care should be taken that this duty cycle should not be near 0 or 100 %. For

this purpose if duty cycle is less than 20 (<7.8%) the value of duty cycle is set to 20

and when it is more than 235 (>92%) it is set to 235. Otherwise operation of half

bridge and dead band delay will not be as desired.

Page 20: Single Phase AC Motor Speed Control Report With Altium Files

13

Also a counter is incremented inside the service routine if it equals 1000 ADC

is read. As reading ADC is time consuming process therefore it is not done in each

service routine.

After reading ADC frequency is calculated. As ω=2πf so now sin table will be

read in faster way hence frequency of output will be increased.

At the end of Interrupt Service Routine Timer is enabled so that next interrupt

can occur.

The flow chart of the Code is given below while code is provided in the

Appendix of the report.

Page 21: Single Phase AC Motor Speed Control Report With Altium Files

14

Figure 3-7 Flow chart representing flow of implemented algorithm

Chapter 4. Results and Simulations

Page 22: Single Phase AC Motor Speed Control Report With Altium Files

15

The code developed for microcontroller using Mikro C pro was simulated using

Proteus. The dead time was judged and was found satisfactory. When sinusoidal wave

is compare with triangular wave the waveforms obtained are shown in figure 4.1.

Figure 4-8: Comparison of sinusoidal wave with triangular wave

Simulation gives exactly same pattern as shown in figure 4.2

Figure 4-9: Bipolar Pulses

Figure 4.3 shows the 10 µsec dead time introduced in between the gate signals of

higher and the lower switches.

Page 23: Single Phase AC Motor Speed Control Report With Altium Files

16

Figure 4-10: 10 µsec dead time introduced in between the gate signals of higher and the lower

switches

It can be seen easily that there is exactly 10 micro seconds’ dead time between two

wave forms.

In order to judge that whether sinusoidal is correctly modulated in the above wave

forms an RC filter of 50 Hz is designed with R=330Ω and C=10µF. the fundamental

component of the above waveform was obtained as shown in figure 4.4.

Figure 4-11: Fundamental component of pulses

Page 24: Single Phase AC Motor Speed Control Report With Altium Files

17

Conclusion

Controlling induction motor speed by SCR has limited range and cause harmonic

problems as well. So PWM based speed control strategy is used in this project using

high speed solid state switches (MOSFET IRF740 which has very low ON-OFF

delyas in order of 117ns). For this, bipolar switching technique was used. Isuues of

dead time was tackled using ECCP module of PIC18F458. Another isuue of floating

ground was solved using isolation supplies.

Page 25: Single Phase AC Motor Speed Control Report With Altium Files

18

Future Recommendations

Improvement in pulse shapes can be made. Apart from that dead time can be lessend.

Another aspect is that it can be used in feedback scheme. Communcation with

computer can be done to achieve more accurate and sophisticated speed control.

Page 26: Single Phase AC Motor Speed Control Report With Altium Files

19

Appendixfloat angle[51]=

0.0000,0.1257,0.2513,0.3770,0.5027,0.6283,0.7540,0.8796,1.0053,1.1310,1.2566,

1.3823,1.5080,1.6336,1.7593,1.8850,2.0106,2.1363,2.2619,2.3876,2.5133,2.6389,

2.7646,2.8903,3.0159,3.1416,3.2673,3.3929,3.5186,3.6442,3.7699,3.8956,4.0212,

4.1469,4.2726,4.3982,4.5239,4.6496,4.7752,4.9009,5.0265,5.1522,5.2779,5.4035,

5.5292,5.6549,5.7805,5.9062,6.0319,6.1575,6.2838;

int sin_table[51]=

128,144,160,175,189,203,215,226,235,243,249,253,255,255,253,249,243,235,226,2

15

,203,189,175,160,144,128,112,96,81,67,53,41,30,21,13,7,3,1,1,3,7,13,21,30,41,53,

67,81,96,112,128;

void timer0_isr(void);

void interrupt()

if(TMR0IF)

timer0_isr();

unsigned int count=0;

float t;

float theta;

float freq=25;

unsigned int i;

float temp;

float temp1;

float freq_temp;

unsigned int temp2=3;

float omega;

float frequency;

unsigned int adc_output;

unsigned int adc_out;

void main(void)

omega=6.283*freq;

Page 27: Single Phase AC Motor Speed Control Report With Altium Files

20

ADCON0=0x81;

ADCON1=0xCE;

ADRESH=0x00;

ADRESL=0x00;

T0CON=0x88;

TRISA=0xFF;

T0CON.TMR0ON=0;

INTCON.GIE=1;

PIE1.ADIE=1;

INTCON.TMR0IE=1;

INTCON.TMR0IF=0;

TMR0L=0xAD;

TMR0H=0xFB;

T0CON.TMR0ON=1;

TRISD=0xFF;

ECCP1CON=0;

PR2=249;

ECCPR1L=127;

ECCP1DEL=0x14;

T2CON=0x01;

ECCP1CON=0X8C;

TRISD=0;

TMR2=0;

T2CON.TMR2ON=1;

while(1)

ECCPR1L=temp2;

void timer0_isr(void)

T0CON.TMR0ON=0;

INTCON.TMR0IF=0;

Page 28: Single Phase AC Motor Speed Control Report With Altium Files

21

TMR0L=0xAD;

TMR0H=0xFB;

t=t+0.0016;

theta=omega*t;

if (theta>6.283)

t=0.0;

theta=0.0;

for(i=0;i<=50;i++)

if(angle[i]>=theta)

temp=sin_table[i];

break;

temp1=(0.01*freq*temp);

temp2=temp1;

if (temp2<=10)

temp2=10;

else if (temp2>=245)

temp2=245;

ECCPR1L=temp2;

count++;

if (count==1000)

adc_output=ADC_Read(0);

PIR1.ADIF==0;

ADCON0.GO=1;

ADCON0=0x81;

freq_temp=adc_output;

frequency=freq_temp*(0.0977);

Page 29: Single Phase AC Motor Speed Control Report With Altium Files

22

freq=frequency;

omega=6.283*freq;

count=0;

T0CON.TMR0ON=1;