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.

PWM generation using PIC

Status
Not open for further replies.

sandhyaram

Newbie level 6
Newbie level 6
Joined
Aug 12, 2010
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
coimbatore
Activity points
1,365
Hai...

I want to generat carrier based PWM using PIC 16F877A .... but I don't know about basic also... Mikro C software use for that..... any one help me how to write a program..... and basic...PLEASE...... Thanks..........:!::!::!:
 

You may need to specify the version of basic you plan on using.
 

See mikroc help and look for libraries then click on hardware libraries and then click PWM library ...it has a sample program too
 

Hi,
Here is a sample code to generate 40kHz:
Code:
//Program to generate 40kHz output at RC2(CCP1) pin
//Microcontroller: Microchip PIC18452
//Language: C
//Compiler: mikroC v8.20
//Programmer: Tahmid

void main (void){
     TRISC = 0;
     PORTC = 0;
     ADCON1 = 7;
     T2CON = 0;
     TMR2 = 0;
     PWM1_Init(40000); //40kHz
     PWM1_Change_Duty(128); //50% duty cycle
// Choose Duty cycle as such:
// PWM_Change_Duty(x);
// x = ( (Duty Cycle in %) / 100) * 255
     PWM1_Start(); //Start PWM
     while (1){ //Loop forever
// Whatever else might be needed to be done while PWM is running
     }
}

Take a look here:
https://www.edaboard.com/threads/169704/#post714600
https://www.edaboard.com/threads/169704/

Hope this helps.
Tahmid.
 
Hai...
Thanks for ur reply.... actually i want to control the Z source inverter switches using simple boost PWM method..... so i want to program ...... comparison of sine wave and traingular wave &traingular wave and
DC value it gives the PWM signals to switches..... any one help me.....
 

Hello
Tahmid
I tried your code and test them on Proteus but nothing happen and I cant see anything on oscilloscope @channel connected to RC2
 

Did you use 18F452? Did you set the proper clock settings, the proper configuration bit settings? It is a simple program and I've tested it - it's all right.
 

I dont have pic18f452 and i want to use it on pic16f877a I think no difference is it? and if there is diference can you give me code for pic16f877a?
 

It's the same. It should work. Maybe there's some problem in the simulation file. Build the circuit on a breadboard/veroboard/PCB and it'll work.
 

---------- Post added at 20:18 ---------- Previous post was at 20:17 ----------

[/COLOR]ok i will try it on breadboard
 
what I asked you before was only in simulation but now I am going to build it in real and try it

---------- Post added at 20:52 ---------- Previous post was at 20:25 ----------

Ok thanks very much tahmid i tried in real and work but why it doesnt work in proteus
 

Hi all,
Quick question can pic16f72 be swapped
For pic16f876?
Thanks
 

Depends. It's pin compatible, but has different features. To start off with, the 16F72 has an 8-bit ADC, 16F876 has a 10-bit ADC.
 
  • Like
Reactions: deva

    deva

    Points: 2
    Helpful Answer Positive Rating
Ok thanks T. Do you know any pic16f72 alternatives?
 

Exact replacements, no. But, you can use 16F876 by tweaking the original code. Is it in assembly or high-level language like C or BASIC?
 

thanks T, its in ASM. Can this be converted to C?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top