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

PWM on pic16f877a WITHOUT CCP modules

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



Joined: 09 Mar 2013
Posts: 3

View user's profile Send private message

PWM on pic16f877a WITHOUT CCP modules
PostPosted: Sat Mar 09, 2013 6:10 am     Reply with quote

Hi there,

I am relatively new to CCS and am not very good at understanding the programming language and need help. I am trying to operate two motors using PWM. I have a circuit set up with an H-bridge to allow each motor to operate in both directions. But in order to get both motors to turn in both directions I need to generate 4 PWM signals.

Is it possible to make an efficient code which will create these 4 PWM signals without the use of the CCP modules?
Any help would be very much appreciated!!

runpigeon
temtronic



Joined: 01 Jul 2010
Posts: 9228
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 7:15 am     Reply with quote

Yes, very easy...
1) start with controlling just one motor.
2)typical H-bridge has 2 bits, direction and speed, with 3 allowed states and one NEVER allowed state(poof)!
3)cut code for a '1Hz blinking LED' program.Proves PIC runs and you can code!
4) once running,recode to allow different 'on' and 'off' times(ie:1on,3off)
5) now send those signals to H-bridge,see how motor responds.
6) 'tune'(adjust) on/off times to control speed.

once happy with basic code,add direction(on/off=cw/ccw), add second motor control..

be sure to test for that NEVER allowed state !!

hth
jay
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 7:32 am     Reply with quote

Quote:
Is it possible to make an efficient code which will create these 4 PWM signals without the use of the CCP modules?
Any help would be very much appreciated!!

Your query has different possible answers.

1) Yes. you can do 4 PWMs without using the CCP modules.
2) Depending on your H-bridge you may only need two PWMs.

Mike

EDIT You need to provide more information. Helps if you read the forum guidelines.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 2:42 pm     Reply with quote

Use Google to search the forum for software PWM threads which use
timer interrupts to create the PWM signal. Use this exact search string
with Google:
Quote:

site:ccsinfo.com "software pwm" #int_timer1 OR #int_timer0
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