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.

help with PWM circuit for PIC16f877A

Status
Not open for further replies.
help with pwm and PIC16f877a

MODERATOR ACTION: Your post related to pwm will deleted other post for same question I merge with another post of same topic read rules or go here


Hi all

I want to generate 500 Hz clock using PWM module in PIC16f877a

so i wrote this code in mikroC but I get no output on the oscilloscope

Code:
void main(){
     TRISC.f2 = 0;
     pwm1_init(500);
     pwm1_start();
     PWM1_change_Duty(127);

     while(1){}

    }

I am using 8MHz oscillator

so please anyone help me doing this ??
 

help with pwm and PIC16f877a

Hi,
I've also faced this problem earlier. I don't know why this happens, but if you use 18F series PIC this problem does not occur.

Hope this helps.
Tahmid.
 

Hi,
I didn't see the earlier post. Guess I missed it.
Check this for tutorial: https://www.mikroe.com/en/books/picbasicbook/00.htm

For interfacing to LCD, look under the help menu in the LCD part. Details are given there.

Say, if you have a variable that stores the value of the duty cycle(255 for 100%, 0 for 0%, 128 for 50%), this is in 8-bit "byte" or "char" data format.

To send this to LCD, you have to convert this to string using this:
Code:
   dim txtDuty as string[3]
   dim Duty as byte 'Holds duty cycle
   dim Duty16 as word
   Duty16 = (Duty * 100) >> 8
   Duty = Duty16
   ByteToStr(Duty, txtDuty) 'Converts byte to string and stores in txtDuty
   LCD_Out(R, C, txtDuty) 'Replace R by desired row no and C by desired column no
'On LCD, a value on a scale of 100 will be shown
For initialization of LCD, it depends on compiler version. This is available in the help menu.

Hope this helps.
Tahmid.
 

Can any one help me?
I got a servo motor,16f877a,20MHz xtal,PICC compiler,I have a burner for my PIC and I use C when writing a program. I got a 5k pot connected to pin A0 and I am planning to use port D to control the servo to go left and right when I turn the pot. The problem is I don't know how to start :p.... I really wanted to learn more about the MCU and I tried blinking LEDs an and using push buttons before, I hope that someone can help me with complete codes, Thanks in advance!!
 

Hi Tahmid..hope you notice this reply,
can you help me correct the programming below.ican't compile it..it is from earlier that i want to make variable duty cycle..hope you will help..thanks in advance

program 1
x var byte
TRISC.2 = 0 ' CCP1 (PortC.2 = Output)
PR2 = 110 ' Set PWM Period for approximately 45KHz
CCPR1L = 55 ' Set PWM Duty-Cycle to 50%
CCP1CON = %00001100 ' Select PWM Mode
T2CON = %00000100 ' Timer2 = ON + 1:1 prescale
Main:
if PortA.0=0 then wait0
Pause 500
if PortA.0=1 then wait1
Goto Main
wait0:
CCPR1L=0' reset PWM duty cycle
end
wait1:
CCPR1L=x+6' increase PWM duty cycle by 20% each time the push button is press
end.

Added after 7 minutes:

i mean that each time the push button is press or active low,,,it will reset the duty cycle..and when the push button is release the duty cycle will increase 5 percent up to 80% duty cycle..then if the push button is press again after 80% ,the duty cycle will back to 50% and this process will go on.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top