View Single Post
  #6   Spotlight this post!  
Unread 11-06-2009, 21:05
lynca's Avatar
lynca lynca is offline
Andrew Lynch
FRC #2587 (DiscoBots)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Houston, TX
Posts: 1,612
lynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond repute
Send a message via AIM to lynca
Re: Program digital IO to PWM?

Quote:
Originally Posted by Daniel Jones View Post
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.
For those who are not familiar with MPLAB, the CustomPWM.c code was meant to be part of a project in MPLAB. For those curious in getting a working project you need to download the full project from VEX's software downloads.
http://www.vexrobotics.com/docs/VexCode_def_2008.zip

Once you have MPLAB opened, add the source files for CustomPWM.c & CustomPWM.h

Thanks for posting this awesome code !!! Kevin Watson also has some great interfacing examples, http://www.kevin.org/frc/ but this is only for FRC 2008 & 2007 systems.
__________________
History: 624 - Cryptonite --> 118 - Robonauts --> 2158 - AusTIN CANS --> 2587 DiscoBots
Bio: Andrew Lynch "How I Work" ---- LinkedIn , Facebook, Twitter