CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to generate two PWM from PIC18F452

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Johnson Kao
Guest







How to generate two PWM from PIC18F452
PostPosted: Sun Dec 23, 2007 3:44 pm     Reply with quote

Dear All,
I will generate two PWM from PIC18F452. The two signal will be push-pull within a deadtime. Have anyone know how to do? I have tried many times but all failed. Have any sample code for reference? Thanks a lot,

Johnson
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 23, 2007 4:45 pm     Reply with quote

This post shows how to do simple dual PWM using the CCP modules.
http://www.ccsinfo.com/forum/viewtopic.php?t=17729&start=1
However, that's not what you want to do.

Quote:
The two signal will be push-pull within a deadtime.

I think you need a PIC with an ECCP module. I suggest that you
get an 18F4520. It's similar to the 18F452, except that it has an ECCP
with these features:
Quote:

Enhanced Capture/Compare/PWM (ECCP) module:
- One, two or four PWM outputs
--- Single Output
--- Half-Bridge Output
--- Full-Bridge Output, Forward mode
--- Full-Bridge Output, Reverse mode

- Selectable polarity
- Programmable dead time
- Auto-Shutdown and Auto-Restart
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Sun Dec 23, 2007 7:44 pm     Reply with quote

It all depends on the frequency of the waves you want to generate, and the resolution of the PWM outputs. It could be an easy project, or just plain impossible. You'll have to explain more.
Guest








PostPosted: Mon Dec 24, 2007 10:04 am     Reply with quote

John P wrote:
It all depends on the frequency of the waves you want to generate, and the resolution of the PWM outputs. It could be an easy project, or just plain impossible. You'll have to explain more.


Thanks for all reply.
More describe about my requirement, I will generate two pwm signal(push-pull) and both of frequency are 50Khz(external XTAL=20MHz).
Any information need to provide?
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Mon Dec 24, 2007 10:45 am     Reply with quote

Maybe I wasn't clear about what's needed to understand the requirements. By "resolution" I meant how many different pulse widths need to be produced, potentially.

For instance, you're saying that the period of the output signal, at 50KHz, must be 20usec. So would it be acceptable to have the ability to produce 11 different outputs, at 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, or 20 usec (where 0 and 20 would be "always off" or "always on")? I'd call that "10% resolution"; if it's not acceptable, what would you need?

Also, will the chip have to do anything else while this runs, such as servicing interrupts? Communication of any kind?

I'm thinking that there might be a minimal way to do this, by setting up a loop outside of any interrupts which simply decrements a counter and flips external port pins at the right times. But it won't be able to keep doing that and service interrupts or do much of anything else at the same time unless you can tolerate disruptions in the output waveform.

And if a change in duty cycle is called for, is irregularity in the waveform acceptable for one (or a few) cycles a during the transition?
Johnson Kao
Guest







PostPosted: Tue Dec 25, 2007 11:49 am     Reply with quote

Resolution is 40%.
Thanks a lot,
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Fri Dec 28, 2007 2:45 pm     Reply with quote

You're not providing enough information to know if this can be done or not.

Also, is it a class project? If so, I think you need to figure it out for yourself.
Guest








PostPosted: Fri Jan 18, 2008 2:46 pm     Reply with quote

for example?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 18, 2008 5:07 pm     Reply with quote

There are many projects posted on the internet, that show how to use
a PIC to drive a motor. Do a search with http://www.google.com for
Quote:
PIC pwm push pull

Here is one of the projects:
http://hades.mech.northwestern.edu/wiki/index.php/PIC_PWM_Motor_Driver
He uses a PIC that has built-in motor-driver features in the PWM module.
He connects the PWM outputs of the PIC to a push-pull driver chip.
The schematic in the L293B data sheet shows how to connect it to a
motor. So does the link above.
http://www.st.com/stonline/books/pdf/docs/1328.pdf

I suggest that you buy one of many PICs that have a built-in motor
driver module (it's part of the PWM module). Then the project will be
very easy. The PIC that he uses (16F684) is extremely cheap.
Digikey sells it for only 2.63(USD) for quantity 1 in the DIP package.
http://www.digikey.com
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group