Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to generate a PWM(20KHz) for 0 to 5V i/P using PIC16F72

Status
Not open for further replies.

codekuru

Junior Member level 1
Joined
Sep 15, 2006
Messages
19
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,384
pwm 20khz

Hi,
my requirement is to generate a PWM wave(20KHz). i am using PIC16f72 Micro controller. i have 0-5V Variable Input. i have to generate a waveform corresponding to tht input signal.tht wave form need to have 50% Duty Cycle.
Plz help me in this problem. if anybody can giv a sample pgm for this will help me very much.
For programming which language is suitable in this condition, C / ASM?
i hope tht many of you can help me very much.
thanks & regards,
sarin
 

pwm 20 khz

If I may suggest something, swap horses and use PICAXE microcontroller as it has build-in PWM function and a number bewteen 0 and 1023 can be used to generate PWM between 0 and 100% ..
Here is an example:


Regards,
IanP
 

generate 12 to 5v

hi
u can use ccs c compiler for this target
here code for your requirement:
Code:
#include <16F72.h>
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPROTECT
int value;

main()
{
   setup_adc_ports( ALL_ANALOG );
   setup_adc(ADC_CLOCK_INTERNAL );
   setup_timer_2 ( T2_DIV_BY_4, value, 2);
   set_adc_channel( 0 );
   setup_ccp1(CCP_pwm);
   while(true)
   {
      delay_ms(100);
      value = read_adc();
      setup_timer_2 ( T2_DIV_BY_16, value, 2);
   }
}
 

    codekuru

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top