View previous topic :: View next topic |
Author |
Message |
madcreator
Joined: 07 Sep 2012 Posts: 4
|
Power PWM module 18f2331 |
Posted: Fri Sep 07, 2012 7:48 am |
|
|
Hi, I'm using the 18f2331 microcontroller from microchip and I want to use the Power Pwm module.
I need to control each PWM (PWM0,PWM1,PWM2,PWM3) independently to drive this :
How can I drive a pair to drive the bridge ??
Thanks for your help ! |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Sep 07, 2012 9:36 am |
|
|
i dont think anyone is going to give you the code for exactly what you want or code it for your.... you can try your luck searching on the code library.
try coding it yourself, and should you have any problems, then the forum users will gladly help you.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
madcreator
Joined: 07 Sep 2012 Posts: 4
|
|
Posted: Fri Sep 07, 2012 11:25 am |
|
|
I don't want the exact code, I just want someone that understand how the power pwm module work ! So I can understand it !
I have already tried coding but nothing works that why I'm posting here!
Madz |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 07, 2012 12:02 pm |
|
|
Then post the code that you tried but didn't work. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1354
|
|
Posted: Fri Sep 07, 2012 12:04 pm |
|
|
Generally the first step (and part of our forum guidelines), is to create a small, compilable program that only addresses your issue, and post it up here so we can take a stab at why the code you tried doesn't work. We're not looking for your entire program, just something that compiles and runs on it's own and that illustrates the problem.
Once you can get that up, we can try to help you out better. |
|
|
madcreator
Joined: 07 Sep 2012 Posts: 4
|
|
Posted: Fri Sep 07, 2012 12:08 pm |
|
|
Code: | #define POWER_PWM_PERIOD 1999
void main()
{
setup_power_pwm_pins(PWM_BOTH_ON, PWM_BOTH_ON, PWM_OFF, PWM_OFF);
//Frequency = Fosc / (4 * (period+1) *postscale)
setup_power_pwm(PWM_FREE_RUN, 1, 0, POWER_PWM_PERIOD, 0, 1,0);
while(1)
{
SET_POWER_PWM0_DUTY(100);
set_power_pwm_override(1,1,0);
SET_POWER_PWM2_DUTY(30);
set_power_pwm_override(2,1,0);
}
} |
This code is to make the motor turn in one direction. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
madcreator
Joined: 07 Sep 2012 Posts: 4
|
|
Posted: Fri Sep 07, 2012 1:45 pm |
|
|
Cool example ! I've made the circuit like that,and this pic is quite little tht why I choosed this one, and I was thinking that the power pwm module was easy to use...
I think I will make a another circuit with a 18f4550 and use the ECCP !
Thanks a lot for your help.
Madz |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 07, 2012 1:59 pm |
|
|
Here are some PICs with an ECCP module:
18F1220/1330
18F4221/4321
18F4220/4320
18F4410/4510/4515/4610
18F4480/18F4580
18F4420/4520
18F4525/4620
18F4550/4455
There's a lot more. I just stopped at that point. |
|
|
|