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 support@ccsinfo.com

A small question on PWM

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







A small question on PWM
PostPosted: Mon Aug 15, 2005 8:10 am     Reply with quote

Hi Everyone
i m using a 16F877A PIC , and i m trying to control 2 DC motors using the Built-in PWM
when i checked ex_pwm.c, how come they ask us to use C2, lets say
i have 2 counters
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);

and i setup 2 duties for 2 different motors
set_pwm1_duty(X1);
set_pwm2_duty(X2);

how can i know where to connect my H-Bridge from the DC motor C1 , C2 ....??
i know in the HEader file of 16f877a.h
it says
#define CCP_PWM 0xC
which means i m using port C, but how can choose and know which pin in Port C to use

i hope i made myself Clear
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 15, 2005 8:14 am     Reply with quote

Read the datasheet for the PIC. It will tell you where the PWM outputs are.
Beginner
Guest







PostPosted: Mon Aug 15, 2005 10:09 am     Reply with quote

I could't find it on the Manual of the Chip
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 15, 2005 11:40 am     Reply with quote

Are you trying to tell me that you read the datasheet for the PIC and could not determine which outputs were the PWM's? I'd suggest that you look again!

CCP1 is RC2
CCP2 is RC1
Guest








Re: A small question on PWM
PostPosted: Mon Aug 15, 2005 11:54 am     Reply with quote

Begineer wrote:
Hi Everyone
i m using a 16F877A PIC , and i m trying to control 2 DC motors using the Built-in PWM
when i checked ex_pwm.c, how come they ask us to use C2, lets say
i have 2 counters
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);

and i setup 2 duties for 2 different motors
set_pwm1_duty(X1);
set_pwm2_duty(X2);

how can i know where to connect my H-Bridge from the DC motor C1 , C2 ....??
i know in the HEader file of 16f877a.h
it says
#define CCP_PWM 0xC
which means i m using port C, but how can choose and know which pin in Port C to use

i hope i made myself Clear


2 different motors? So you mean two different H-bridges too?
You plan on controlling them with four independent PWMs each?

I don't know how you plan on hooking the h-bridge up (let alone TWO h-bridges), with just 2 pwms.

Go read the ECCP on a pic18f448. you might even need a dspic or an 18f4431 to control two motors with an h-bridge.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

Re: A small question on PWM
PostPosted: Mon Aug 15, 2005 12:09 pm     Reply with quote

Anonymous wrote:

2 different motors? So you mean two different H-bridges too?
You plan on controlling them with four independent PWMs each?

I don't know how you plan on hooking the h-bridge up (let alone TWO h-bridges), with just 2 pwms.

Go read the ECCP on a pic18f448. you might even need a dspic or an 18f4431 to control two motors with an h-bridge.


I'm using the L293 quad half h-bridge chip. I use PWM into the enable, and the h-bridge just gets direction controls

Scott
beginner
Guest







Re: A small question on PWM
PostPosted: Tue Aug 16, 2005 7:56 am     Reply with quote

Anonymous wrote:
Begineer wrote:
Hi Everyone
i m using a 16F877A PIC , and i m trying to control 2 DC motors using the Built-in PWM
when i checked ex_pwm.c, how come they ask us to use C2, lets say
i have 2 counters
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);

and i setup 2 duties for 2 different motors
set_pwm1_duty(X1);
set_pwm2_duty(X2);

how can i know where to connect my H-Bridge from the DC motor C1 , C2 ....??
i know in the HEader file of 16f877a.h
it says
#define CCP_PWM 0xC
which means i m using port C, but how can choose and know which pin in Port C to use

i hope i made myself Clear


2 different motors? So you mean two different H-bridges too?
You plan on controlling them with four independent PWMs each?

I don't know how you plan on hooking the h-bridge up (let alone TWO h-bridges), with just 2 pwms.

Go read the ECCP on a pic18f448. you might even need a dspic or an 18f4431 to control two motors with an h-bridge.


i m sorry my mistake i ll be controling a one-way motor , which means i won't be needing a full H bridge, the motors will go only for one direction ,, and i figured out the PWM registers for 16f877A they are
RC1 -->set_pwm2_duty()
RC2----> set_pwm1_duty()


thanks guys
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: A small question on PWM
PostPosted: Tue Aug 16, 2005 7:59 am     Reply with quote

beginner wrote:
Anonymous wrote:
Begineer wrote:
Hi Everyone
i m using a 16F877A PIC , and i m trying to control 2 DC motors using the Built-in PWM
when i checked ex_pwm.c, how come they ask us to use C2, lets say
i have 2 counters
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);

and i setup 2 duties for 2 different motors
set_pwm1_duty(X1);
set_pwm2_duty(X2);

how can i know where to connect my H-Bridge from the DC motor C1 , C2 ....??
i know in the HEader file of 16f877a.h
it says
#define CCP_PWM 0xC
which means i m using port C, but how can choose and know which pin in Port C to use

i hope i made myself Clear


2 different motors? So you mean two different H-bridges too?
You plan on controlling them with four independent PWMs each?

I don't know how you plan on hooking the h-bridge up (let alone TWO h-bridges), with just 2 pwms.

Go read the ECCP on a pic18f448. you might even need a dspic or an 18f4431 to control two motors with an h-bridge.


i m sorry my mistake i ll be controling a one-way motor , which means i won't be needing a full H bridge, the motors will go only for one direction ,, and i figured out the PWM registers for 16f877A they are
RC1 -->set_pwm2_duty()
RC2----> set_pwm1_duty()


thanks guys


Yeah, I already told you that.
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