View previous topic :: View next topic |
Author |
Message |
runpigeon
Joined: 09 Mar 2013 Posts: 3
|
PWM on pic16f877a WITHOUT CCP modules |
Posted: Sat Mar 09, 2013 6:10 am |
|
|
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: 9221 Location: Greensville,Ontario
|
|
Posted: Sat Mar 09, 2013 7:15 am |
|
|
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
|
|
Posted: Sat Mar 09, 2013 7:32 am |
|
|
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
|
|
Posted: Sat Mar 09, 2013 2:42 pm |
|
|
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 |
|
|
|
|