SlideShare a Scribd company logo
1 of 7
Download to read offline
MICRCONTROLLER PROGRAMING
PWM WAVE GENRATORE
#include<reg51.h>
#include<stdio.h>
#include"lcd.h"
sbit Add_A=P0^7; // Address pins for selecting input channels.
sbit Add_B=P0^6;
sbit Add_C=P0^5;
sbit ALE=P0^4; //address latch enable
sbit START=P0^0; //start conversion
sbit EOC=P0^1; //end of conversion
sbit OE=P0^2; //output enable
sbit CLK=P0^3; // clock
sbit Increment=P3^0;
sbit Decrement=P3^1;
sbit Enter=P3^2;
sbit pwm=P3^4;
#define Data_Bus P2
#define Half Cycle Delay 10 // usecs
#define AN0 0
#define AN1 1
#define AN2 2
#define AN3 3
#define AN4 4
#define AN5 5
#define AN6 6
#define AN7 7
float voltage=0;
unsigned char volt=0;
unsigned int Ton=0;
unsigned int Toff=0; // Function Declarations
void Init ADC(void);
unsigned int ReadADC(unsigned char);
void __delay_us(unsigned int );
void Duty_Delay();
void PWM(unsigned char x);
void main()
{
unsigned char ADC_Value = 0; // To capture ADC value
unsigned int i=0;
InitADC(); // Initialize ADC
LCD_INIT();
LCD_COMMAND(0x01);
LCD_STRING("POWER CONVERTOR ");
LCD_COMMAND(0xC0);
MICRCONTROLLER PROGRAMING
LCD_STRING(" CONTROL SYSTEM ");
for(i=0;i<60;i++)
DELAY();
for(i=0;i<50;i++)
DELAY();
LCD_COMMAND(0x01);
LCD_STRING(" VOLTAGE IS ");
ADC_Value = ReadADC(AN0); // Read ADC value from Channel 0
voltage=(ADC_Value);
voltage=(voltage*33/255);
LCD_COMMAND(0xC0);
LCD_FLOAT(voltage);
LCD_STRING(" VOLT ");
for(i=0;i<50;i++)
DELAY();
while(1)
{
for(i=0;i<50;i++)
DELAY();
LCD_COMMAND(0x01);
LCD_STRING(" VOLTAGE IS ");
ADC_Value = ReadADC(AN0); // Read ADC value from Channel 0
voltage=(ADC_Value);
voltage=(voltage*33/255);
LCD_COMMAND(0xC0);
LCD_FLOAT(voltage);
LCD_STRING(" VOLT ");
for(i=0;i<50;i++)
DELAY();
if(Increment==0) //Check if Increment pin is pressed
{
volt=0;
while(Enter!=0) //loop untill enter is pressed
{
if(Increment==0)
{
++volt;
if(volt>10)
volt=10;
LCD_COMMAND(0x01);
LCD_COMMAND(0x80);
LCD_STRING(" VOLTAGE IS ");
LCD_COMMAND(0xC0);
LCD_INT(volt*3);
LCD_STRING(" VOLT ");
}
if(Decrement==0)
{
MICRCONTROLLER PROGRAMING
--volt;
if(volt<1)
volt=1;
LCD_COMMAND(0x01);
LCD_COMMAND(0x80);
LCD_STRING(" VOLTAGE IS ");
LCD_COMMAND(0xC0);
LCD_INT(volt*3);
LCD_STRING(" VOLT ");
}
} // end of while(Enter!=0)
LCD_COMMAND(0xC0);
LCD_STRING(" ZERO ");
//PWM(volt*10); //volt=0;
} // end of if(increment==0)
if(Decrement==0) //Check if Decrement pin is pressed
{
volt=0;
while(Enter!=0) //loop untill enter is pressed
{
if(Decrement==0)
{
if(volt<=1)
volt=1;
else
--volt;
LCD_COMMAND(0x01);
LCD_COMMAND(0x80);
LCD_STRING(" VOLTAGE IS ");
LCD_COMMAND(0xC0);
LCD_INT(volt*3);
LCD_STRING(" VOLT ");
}
if(Increment==0)
{
++volt;
if(volt>10)
volt=10;
LCD_COMMAND(0x01);
LCD_COMMAND(0x80);
LCD_STRING(" VOLTAGE IS ");
LCD_COMMAND(0xC0);
LCD_INT(volt*3);
LCD_STRING(" VOLT ");
}
} // end of while(Enter!=0)
LCD_COMMAND(0xC0);
MICRCONTROLLER PROGRAMING
LCD_STRING(" ZERO "); // PWM(volt*10); //volt=0;
} //end of if(decrement==0)
PWM(volt);
} //end of while(1)
} //end of main()
void PWM(unsigned char x) //400HZ=2500us Duty cycle=Ton/Ton+Toff*100
{
unsigned char i=0;
if(x==1)
{
pwm=1;
__delay_us(100);
pwm=0;
__delay_us(900);
}
if(x==2)
{
pwm=1;
__delay_us(200);
pwm=0;
__delay_us(800);
}
if(x==3)
{
pwm=1;
__delay_us(300);
pwm=0;
__delay_us(700);
}
if(x==4)
{
pwm=1;
__delay_us(400);
pwm=0;
__delay_us(600);
}
if(x==5)
{
pwm=1;
__delay_us(500);
pwm=0;
__delay_us(500);
}
if(x==6)
{
pwm=1;
MICRCONTROLLER PROGRAMING
__delay_us(600);
pwm=0;
__delay_us(400);
}
if(x==7)
{
pwm=1;
__delay_us(700);
pwm=0;
__delay_us(300);
}
if(x==8)
{
pwm=1;
__delay_us(800);
pwm=0;
__delay_us(200);
}
if(x==9)
{
pwm=1;
__delay_us(900);
pwm=0;
__delay_us(100);
}
if(x==10)
{
pwm=1;
__delay_us(1000);
}
else
pwm=0;
}
void InitADC(void)
{
Add_A = 0; // Make output
Add_B = 0; // Make output
Add_C = 0; // Make output
ALE = 0; // Make output
EOC = 1; // Make output
OE = 0; // Make output
START = 0; // Make output
CLK = 0; // Make output
Data_Bus = 0xFF; // Make Inputs
}
MICRCONTROLLER PROGRAMING
unsigned int ReadADC(unsigned char Channel)
{
unsigned int i = 0;
unsigned int ADC_value = 0;
// Select Channel
switch(Channel)
{
case AN0: Add_C = 0; Add_B = 0; Add_A = 0; break;
case AN1: Add_C = 0; Add_B = 0; Add_A = 1; break;
case AN2: Add_C = 0; Add_B = 1; Add_A = 0; break;
case AN3: Add_C = 0; Add_B = 1; Add_A = 1; break;
case AN4: Add_C = 1; Add_B = 0; Add_A = 0; break;
case AN5: Add_C = 1; Add_B = 0; Add_A = 1; break;
case AN6: Add_C = 1; Add_B = 1; Add_A = 0; break;
case AN7: Add_C = 1; Add_B = 1; Add_A = 1; break;
}
__delay_us(HalfCycleDelay); // 250kHz Frequency
ALE = 1; // Enable Address Latch
CLK = 1; // Make CLK High
__delay_us(HalfCycleDelay); // 250kHz Frequency
CLK = 0; // Make CLK Low
START = 1; // Start ADC Conversion
__delay_us(HalfCycleDelay); // 250kHz Frequency
CLK = 1; // Make CLK High
ALE = 0; // Disable Address Latch
__delay_us(HalfCycleDelay); // 250kHz Frequency
CLK = 0; // Make CLK Low
START = 0; // Complete the start pulse
for(i=0;i<2000;i++)
{
CLK = !CLK; // Toggle Clock
__delay_us(HalfCycleDelay); // 250kHz Frequency
if(!EOC) // Wait for EOC to be low
break;
}
for(i=0;i<2000;i++)
{
CLK = !CLK; // Toggle Clock
__delay_us(HalfCycleDelay); // 250kHz Frequency
if(EOC) // Wait for EOC to be High
break;
}
MICRCONTROLLER PROGRAMING
CLK = 0; // Make CLK Low
OE = 1; // Enable Output
__delay_us(HalfCycleDelay); // 250kHz Frequency
CLK = 1; // Make CLK High
__delay_us(HalfCycleDelay); // 250kHz Frequency
CLK = 0; // Make CLK Low
__delay_us(HalfCycleDelay); // 250kHz Frequency
CLK = 1; // Make CLK High
ADC_value = Data_Bus; // Read value
__delay_us(HalfCycleDelay); // 250kHz Frequency
OE = 0; // Disable Output
CLK = 0; // Make CLK Low
__delay_us(HalfCycleDelay); // 250kHz Frequency
return ADC_value; // Return ADC value
}
void __delay_us(unsigned int d)
{
unsigned int i, limit;
limit = d/15;
for(i=0;i<limit;i++);
}
void DELAY()
{
int k;
for(k=0;k<10000;k++);
}
void Duty_Delay()
{
int k;
for(k=0;k<5000;k++);
}

More Related Content

What's hot

EEP306: Phase locked loop
EEP306: Phase locked loopEEP306: Phase locked loop
EEP306: Phase locked loopUmang Gupta
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solutionZunAib Ali
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINOS Ayub
 
Smart traffic light controller using verilog
Smart traffic light controller using verilogSmart traffic light controller using verilog
Smart traffic light controller using verilogVaishaliVaishali14
 
Switched reluctance motor speed control using microcontroller
Switched reluctance motor speed control using microcontrollerSwitched reluctance motor speed control using microcontroller
Switched reluctance motor speed control using microcontrollerKrishnaraj Jadav
 
Introduction to pll
Introduction to pllIntroduction to pll
Introduction to pllsartaj ahmed
 
Datasheet 74 ls90
Datasheet 74 ls90Datasheet 74 ls90
Datasheet 74 ls90everest_vls
 
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABDIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABPrashant Srivastav
 
Using Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsUsing Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsCorrado Santoro
 
All Digital Phase Lock Loop 03 12 09
All Digital Phase Lock Loop 03 12 09All Digital Phase Lock Loop 03 12 09
All Digital Phase Lock Loop 03 12 09imranbashir
 
Ee443 phase locked loop - presentation - schwappach and brandy
Ee443   phase locked loop - presentation - schwappach and brandyEe443   phase locked loop - presentation - schwappach and brandy
Ee443 phase locked loop - presentation - schwappach and brandyLoren Schwappach
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051logesh waran
 
presentation of samra
presentation of samrapresentation of samra
presentation of samraNimrafarooq3
 
PHASE LOCKED LOOP FOR GSM 900
PHASE LOCKED LOOP FOR  GSM 900PHASE LOCKED LOOP FOR  GSM 900
PHASE LOCKED LOOP FOR GSM 900chirag2003
 
Differential audio using pwm
Differential audio using pwmDifferential audio using pwm
Differential audio using pwmAbuBakar Siddique
 

What's hot (20)

EEP306: Phase locked loop
EEP306: Phase locked loopEEP306: Phase locked loop
EEP306: Phase locked loop
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solution
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 
Pll
PllPll
Pll
 
Smart traffic light controller using verilog
Smart traffic light controller using verilogSmart traffic light controller using verilog
Smart traffic light controller using verilog
 
DPLL PRESENTATION
DPLL PRESENTATIONDPLL PRESENTATION
DPLL PRESENTATION
 
Switched reluctance motor speed control using microcontroller
Switched reluctance motor speed control using microcontrollerSwitched reluctance motor speed control using microcontroller
Switched reluctance motor speed control using microcontroller
 
Introduction to pll
Introduction to pllIntroduction to pll
Introduction to pll
 
Datasheet 74 ls90
Datasheet 74 ls90Datasheet 74 ls90
Datasheet 74 ls90
 
Verilog code
Verilog codeVerilog code
Verilog code
 
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABDIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
 
Using Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsUsing Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUs
 
Phase locked loop
Phase locked loopPhase locked loop
Phase locked loop
 
All Digital Phase Lock Loop 03 12 09
All Digital Phase Lock Loop 03 12 09All Digital Phase Lock Loop 03 12 09
All Digital Phase Lock Loop 03 12 09
 
Ee443 phase locked loop - presentation - schwappach and brandy
Ee443   phase locked loop - presentation - schwappach and brandyEe443   phase locked loop - presentation - schwappach and brandy
Ee443 phase locked loop - presentation - schwappach and brandy
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
presentation of samra
presentation of samrapresentation of samra
presentation of samra
 
PHASE LOCKED LOOP FOR GSM 900
PHASE LOCKED LOOP FOR  GSM 900PHASE LOCKED LOOP FOR  GSM 900
PHASE LOCKED LOOP FOR GSM 900
 
Pll Basic Linkedin2
Pll Basic Linkedin2Pll Basic Linkedin2
Pll Basic Linkedin2
 
Differential audio using pwm
Differential audio using pwmDifferential audio using pwm
Differential audio using pwm
 

Viewers also liked

Viewers also liked (20)

Formato portafolio virtual (2)
Formato portafolio virtual (2)Formato portafolio virtual (2)
Formato portafolio virtual (2)
 
La equidad de genero
La   equidad de generoLa   equidad de genero
La equidad de genero
 
Trousse de secours_aa
Trousse de secours_aaTrousse de secours_aa
Trousse de secours_aa
 
Para la reunión de padres inicio de curso Delibes Burgos
Para la reunión de padres inicio de curso Delibes BurgosPara la reunión de padres inicio de curso Delibes Burgos
Para la reunión de padres inicio de curso Delibes Burgos
 
Luisa y cardenas
Luisa y cardenasLuisa y cardenas
Luisa y cardenas
 
Playoffs futbol 3er curs 2013
Playoffs futbol 3er curs 2013Playoffs futbol 3er curs 2013
Playoffs futbol 3er curs 2013
 
Por que tuvo que morir Jesus
Por que tuvo que morir JesusPor que tuvo que morir Jesus
Por que tuvo que morir Jesus
 
El aborto...
El aborto...El aborto...
El aborto...
 
14 de febrero
14 de febrero14 de febrero
14 de febrero
 
Grandiosamente
GrandiosamenteGrandiosamente
Grandiosamente
 
Que es el plagio
Que es el plagioQue es el plagio
Que es el plagio
 
ONG "Juntos podemos + "
ONG "Juntos podemos + "ONG "Juntos podemos + "
ONG "Juntos podemos + "
 
Trabajo práctico
Trabajo prácticoTrabajo práctico
Trabajo práctico
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Practica word marianela
Practica word marianelaPractica word marianela
Practica word marianela
 
Grandiosamente
GrandiosamenteGrandiosamente
Grandiosamente
 
Fotosparameditar
FotosparameditarFotosparameditar
Fotosparameditar
 
Poemas cortos de amistad
Poemas cortos de amistadPoemas cortos de amistad
Poemas cortos de amistad
 
La Tecnología Como Instrumento Para El Juego y El Aprendizaje
La Tecnología Como Instrumento Para El Juego y El Aprendizaje La Tecnología Como Instrumento Para El Juego y El Aprendizaje
La Tecnología Como Instrumento Para El Juego y El Aprendizaje
 
Torneig de futbol -2on curs - Annexa 2013
Torneig de futbol -2on curs - Annexa 2013Torneig de futbol -2on curs - Annexa 2013
Torneig de futbol -2on curs - Annexa 2013
 

Similar to Pwm wave

8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdfShashiKiran664181
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docxajoy21
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxSANTIAGO PABLO ALBERTO
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfforwardcom41
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)antonio michua
 
Original Mosfet MC33151DR2G 33151 MC33151 SOP-8 New
Original Mosfet MC33151DR2G 33151 MC33151 SOP-8 NewOriginal Mosfet MC33151DR2G 33151 MC33151 SOP-8 New
Original Mosfet MC33151DR2G 33151 MC33151 SOP-8 NewAUTHELECTRONIC
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
Aurduino coding for transformer interfacing
Aurduino coding for transformer interfacingAurduino coding for transformer interfacing
Aurduino coding for transformer interfacingCOMSATS Abbottabad
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
PROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfPROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfvidhyalakshmi153619
 
Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...Karthik Rathinavel
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuatorsEueung Mulyana
 

Similar to Pwm wave (20)

Direct analog
Direct analogDirect analog
Direct analog
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
 
chapter 4
chapter 4chapter 4
chapter 4
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)
 
Original Mosfet MC33151DR2G 33151 MC33151 SOP-8 New
Original Mosfet MC33151DR2G 33151 MC33151 SOP-8 NewOriginal Mosfet MC33151DR2G 33151 MC33151 SOP-8 New
Original Mosfet MC33151DR2G 33151 MC33151 SOP-8 New
 
Robotics lec7
Robotics lec7Robotics lec7
Robotics lec7
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Aurduino coding for transformer interfacing
Aurduino coding for transformer interfacingAurduino coding for transformer interfacing
Aurduino coding for transformer interfacing
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
 
PROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfPROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdf
 
Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 

Recently uploaded

Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts ServiceVip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Serviceankitnayak356677
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...lizamodels9
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckPitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckHajeJanKamps
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024christinemoorman
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedLean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedKaiNexus
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in managementchhavia330
 
Call Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any TimeCall Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any Timedelhimodelshub1
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCRsoniya singh
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurSuhani Kapoor
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 

Recently uploaded (20)

Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts ServiceVip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
 
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckPitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedLean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in management
 
Call Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any TimeCall Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any Time
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Keshav Puram 🔝 Delhi NCR
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 

Pwm wave

  • 1. MICRCONTROLLER PROGRAMING PWM WAVE GENRATORE #include<reg51.h> #include<stdio.h> #include"lcd.h" sbit Add_A=P0^7; // Address pins for selecting input channels. sbit Add_B=P0^6; sbit Add_C=P0^5; sbit ALE=P0^4; //address latch enable sbit START=P0^0; //start conversion sbit EOC=P0^1; //end of conversion sbit OE=P0^2; //output enable sbit CLK=P0^3; // clock sbit Increment=P3^0; sbit Decrement=P3^1; sbit Enter=P3^2; sbit pwm=P3^4; #define Data_Bus P2 #define Half Cycle Delay 10 // usecs #define AN0 0 #define AN1 1 #define AN2 2 #define AN3 3 #define AN4 4 #define AN5 5 #define AN6 6 #define AN7 7 float voltage=0; unsigned char volt=0; unsigned int Ton=0; unsigned int Toff=0; // Function Declarations void Init ADC(void); unsigned int ReadADC(unsigned char); void __delay_us(unsigned int ); void Duty_Delay(); void PWM(unsigned char x); void main() { unsigned char ADC_Value = 0; // To capture ADC value unsigned int i=0; InitADC(); // Initialize ADC LCD_INIT(); LCD_COMMAND(0x01); LCD_STRING("POWER CONVERTOR "); LCD_COMMAND(0xC0);
  • 2. MICRCONTROLLER PROGRAMING LCD_STRING(" CONTROL SYSTEM "); for(i=0;i<60;i++) DELAY(); for(i=0;i<50;i++) DELAY(); LCD_COMMAND(0x01); LCD_STRING(" VOLTAGE IS "); ADC_Value = ReadADC(AN0); // Read ADC value from Channel 0 voltage=(ADC_Value); voltage=(voltage*33/255); LCD_COMMAND(0xC0); LCD_FLOAT(voltage); LCD_STRING(" VOLT "); for(i=0;i<50;i++) DELAY(); while(1) { for(i=0;i<50;i++) DELAY(); LCD_COMMAND(0x01); LCD_STRING(" VOLTAGE IS "); ADC_Value = ReadADC(AN0); // Read ADC value from Channel 0 voltage=(ADC_Value); voltage=(voltage*33/255); LCD_COMMAND(0xC0); LCD_FLOAT(voltage); LCD_STRING(" VOLT "); for(i=0;i<50;i++) DELAY(); if(Increment==0) //Check if Increment pin is pressed { volt=0; while(Enter!=0) //loop untill enter is pressed { if(Increment==0) { ++volt; if(volt>10) volt=10; LCD_COMMAND(0x01); LCD_COMMAND(0x80); LCD_STRING(" VOLTAGE IS "); LCD_COMMAND(0xC0); LCD_INT(volt*3); LCD_STRING(" VOLT "); } if(Decrement==0) {
  • 3. MICRCONTROLLER PROGRAMING --volt; if(volt<1) volt=1; LCD_COMMAND(0x01); LCD_COMMAND(0x80); LCD_STRING(" VOLTAGE IS "); LCD_COMMAND(0xC0); LCD_INT(volt*3); LCD_STRING(" VOLT "); } } // end of while(Enter!=0) LCD_COMMAND(0xC0); LCD_STRING(" ZERO "); //PWM(volt*10); //volt=0; } // end of if(increment==0) if(Decrement==0) //Check if Decrement pin is pressed { volt=0; while(Enter!=0) //loop untill enter is pressed { if(Decrement==0) { if(volt<=1) volt=1; else --volt; LCD_COMMAND(0x01); LCD_COMMAND(0x80); LCD_STRING(" VOLTAGE IS "); LCD_COMMAND(0xC0); LCD_INT(volt*3); LCD_STRING(" VOLT "); } if(Increment==0) { ++volt; if(volt>10) volt=10; LCD_COMMAND(0x01); LCD_COMMAND(0x80); LCD_STRING(" VOLTAGE IS "); LCD_COMMAND(0xC0); LCD_INT(volt*3); LCD_STRING(" VOLT "); } } // end of while(Enter!=0) LCD_COMMAND(0xC0);
  • 4. MICRCONTROLLER PROGRAMING LCD_STRING(" ZERO "); // PWM(volt*10); //volt=0; } //end of if(decrement==0) PWM(volt); } //end of while(1) } //end of main() void PWM(unsigned char x) //400HZ=2500us Duty cycle=Ton/Ton+Toff*100 { unsigned char i=0; if(x==1) { pwm=1; __delay_us(100); pwm=0; __delay_us(900); } if(x==2) { pwm=1; __delay_us(200); pwm=0; __delay_us(800); } if(x==3) { pwm=1; __delay_us(300); pwm=0; __delay_us(700); } if(x==4) { pwm=1; __delay_us(400); pwm=0; __delay_us(600); } if(x==5) { pwm=1; __delay_us(500); pwm=0; __delay_us(500); } if(x==6) { pwm=1;
  • 5. MICRCONTROLLER PROGRAMING __delay_us(600); pwm=0; __delay_us(400); } if(x==7) { pwm=1; __delay_us(700); pwm=0; __delay_us(300); } if(x==8) { pwm=1; __delay_us(800); pwm=0; __delay_us(200); } if(x==9) { pwm=1; __delay_us(900); pwm=0; __delay_us(100); } if(x==10) { pwm=1; __delay_us(1000); } else pwm=0; } void InitADC(void) { Add_A = 0; // Make output Add_B = 0; // Make output Add_C = 0; // Make output ALE = 0; // Make output EOC = 1; // Make output OE = 0; // Make output START = 0; // Make output CLK = 0; // Make output Data_Bus = 0xFF; // Make Inputs }
  • 6. MICRCONTROLLER PROGRAMING unsigned int ReadADC(unsigned char Channel) { unsigned int i = 0; unsigned int ADC_value = 0; // Select Channel switch(Channel) { case AN0: Add_C = 0; Add_B = 0; Add_A = 0; break; case AN1: Add_C = 0; Add_B = 0; Add_A = 1; break; case AN2: Add_C = 0; Add_B = 1; Add_A = 0; break; case AN3: Add_C = 0; Add_B = 1; Add_A = 1; break; case AN4: Add_C = 1; Add_B = 0; Add_A = 0; break; case AN5: Add_C = 1; Add_B = 0; Add_A = 1; break; case AN6: Add_C = 1; Add_B = 1; Add_A = 0; break; case AN7: Add_C = 1; Add_B = 1; Add_A = 1; break; } __delay_us(HalfCycleDelay); // 250kHz Frequency ALE = 1; // Enable Address Latch CLK = 1; // Make CLK High __delay_us(HalfCycleDelay); // 250kHz Frequency CLK = 0; // Make CLK Low START = 1; // Start ADC Conversion __delay_us(HalfCycleDelay); // 250kHz Frequency CLK = 1; // Make CLK High ALE = 0; // Disable Address Latch __delay_us(HalfCycleDelay); // 250kHz Frequency CLK = 0; // Make CLK Low START = 0; // Complete the start pulse for(i=0;i<2000;i++) { CLK = !CLK; // Toggle Clock __delay_us(HalfCycleDelay); // 250kHz Frequency if(!EOC) // Wait for EOC to be low break; } for(i=0;i<2000;i++) { CLK = !CLK; // Toggle Clock __delay_us(HalfCycleDelay); // 250kHz Frequency if(EOC) // Wait for EOC to be High break; }
  • 7. MICRCONTROLLER PROGRAMING CLK = 0; // Make CLK Low OE = 1; // Enable Output __delay_us(HalfCycleDelay); // 250kHz Frequency CLK = 1; // Make CLK High __delay_us(HalfCycleDelay); // 250kHz Frequency CLK = 0; // Make CLK Low __delay_us(HalfCycleDelay); // 250kHz Frequency CLK = 1; // Make CLK High ADC_value = Data_Bus; // Read value __delay_us(HalfCycleDelay); // 250kHz Frequency OE = 0; // Disable Output CLK = 0; // Make CLK Low __delay_us(HalfCycleDelay); // 250kHz Frequency return ADC_value; // Return ADC value } void __delay_us(unsigned int d) { unsigned int i, limit; limit = d/15; for(i=0;i<limit;i++); } void DELAY() { int k; for(k=0;k<10000;k++); } void Duty_Delay() { int k; for(k=0;k<5000;k++); }