Previous in Forum: When Do You Get a Shock?   Next in Forum: Hi-Precision Distance Measurement Sensor - Ultrasonic or Optical??
Close
Close
Close
6 comments
Rate Comments: Nested
Participant

Join Date: Sep 2008
Location: INDIA
Posts: 3

PWM Prog in C

09/30/2008 12:46 AM

I am using PIC 18f2620 to generate PWM signal .what is the program code for PIC C18 Compiler? How can I set this PWM signal in specific PORT ?

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Anonymous Poster
#1

Re: PWM Prog in C

09/30/2008 11:19 PM

Can't actually help with the program code.

just wanted to suggest you use a 666 (2x555) chip instead. Much simpler. one timer sets the pulse start the second the length (pulse finish) I've used them for one off servo control in the past.

Register to Reply
Guru
Engineering Fields - Electrical Engineering - New Member

Join Date: Oct 2007
Location: Sour Lake, TX 30°08'59.68"N 94°19'42.81"W
Posts: 675
Good Answers: 13
#3
In reply to #1

Re: PWM Prog in C

10/01/2008 7:20 PM

666=evil (Newton said it!)

Mono timer 555

Dual timer 556

__________________
Bridge rule #1: Nobody is as good as he thinks about himself nor as dumb, as his partner thinks...
Register to Reply
Member
United States - Member - New Member Engineering Fields - Electrical Engineering - New Member Fans of Old Computers - Altair 8800 - Long time Computer Geek

Join Date: Oct 2007
Posts: 6
#2

Re: PWM Prog in C

10/01/2008 10:05 AM

The 18F2620 has a built in PWM generator. You just need to set up the appropriate registers and you should get the right signals out. This can provide you with a PWM signal on the pins marked CCP1 or CCP2 (Capture/Compare/PWM). IF you want it on another pin ... no you don't want to put it on another pin. Read the datasheet and app notes.

Register to Reply
Participant

Join Date: Sep 2008
Location: INDIA
Posts: 3
#4
In reply to #2

Re: PWM Prog in C

10/05/2008 12:53 AM

THANX, BUT I WANT TO GENERATE A VARIABLE PWM SIGNAL WITH FEEDBACK CONTROLLER. WHAT R THE STEPS OR THE SAMPLE CODE IN C18?

Register to Reply
Participant

Join Date: Sep 2008
Location: INDIA
Posts: 3
#6
In reply to #2

Re: PWM Prog in C

11/10/2008 11:50 PM

CAN U GIVE ME THE CODE OF PID CONTROLLER USING PIC?

OR ANY SUGGESTION!

NEED URGENTLY

Register to Reply Off Topic (Score 5)
Member
United States - Member - New Member Engineering Fields - Electrical Engineering - New Member Fans of Old Computers - Altair 8800 - Long time Computer Geek

Join Date: Oct 2007
Posts: 6
#5

Re: PWM Prog in C

10/08/2008 1:46 PM

I haven't used C18, so I don't have exact code. Changing the PWM value appears to just require writing the new duty cycle into the appropriate register. How you compute that value is up to you.

Have you looked at the sample code on the Microchip web site?

Register to Reply
Register to Reply 6 comments
Copy to Clipboard

Users who posted comments:

Anonymous Poster (1); indel (1); LOGNO (2); Richard_Damon (2)

Previous in Forum: When Do You Get a Shock?   Next in Forum: Hi-Precision Distance Measurement Sensor - Ultrasonic or Optical??

Advertisement