View Single Post
  #5   Spotlight this post!  
Unread 10-06-2009, 21:57
Daniel Jones Daniel Jones is offline
Registered User
AKA: Hanes
FRC #0190 (Gompei and the HERD)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Shrewsbury MA
Posts: 13
Daniel Jones is on a distinguished road
Re: Program digital IO to PWM?

The PIC18F8520 actually has several hardware counter-compare modules which are connected to the first four motor ports. These can be used to generate a high resolution PWM signal from 0% duty to 100% duty at high frequencies (I think I used 40kilohertz). Since hardware is taking care of this, after you set a value your code can continue to do anything else and the signal will continue to be generated until it is told otherwise.

I attached some code that I used to drive an h-bridge motor controller via this method.
Attached Files
File Type: c CustomPWM.c (4.0 KB, 52 views)
File Type: h CustomPWM.h (317 Bytes, 36 views)
__________________
"there are 10 types of people in this world, those who understand binary and those who don't"