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

Dual H-Bridge motor control

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



Joined: 19 May 2009
Posts: 6

View user's profile Send private message

Dual H-Bridge motor control
PostPosted: Fri Jul 17, 2009 5:49 am     Reply with quote

I'm trying to use this motor driver in my project:
http://www.sparkfun.com/commerce/product_info.php?products_id=8905
The pic is the 18f4550.

Anyone as an example with ccs?
robomaniac



Joined: 16 Jul 2009
Posts: 19
Location: Sherbrooke, Québec, Canada

View user's profile Send private message Visit poster's website

PostPosted: Fri Jul 17, 2009 6:29 am     Reply with quote

Created a PWM output

Connect that output to the PWMA and PWMB

Then you will to have 4 more output to control the direction of the motor.

So connect some IO to BIN1,BIN2, AN1 and AN2.

When
BIN1 = 0
BIN2 =1 motor will trun in one direction

BIN1 = 1
BIN2 = 0 motor will trun the other direction

The speed will be control with PWMB.

Look in the CCS manual page 236 of manual
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
or page 248 of pdf.

Look at the example file to have the code.

Have fun
_________________
Jérôme Demers
www.jeromedemers.com
ricard0g0mes



Joined: 19 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Fri Jul 17, 2009 7:48 am     Reply with quote

but i want to control 2 motor's with different velocity's
robomaniac



Joined: 16 Jul 2009
Posts: 19
Location: Sherbrooke, Québec, Canada

View user's profile Send private message Visit poster's website

PostPosted: Fri Jul 17, 2009 7:55 am     Reply with quote

yes that is why you have PWMA and PWMB on your chip.

Depending of your PIC, you can have 2 PWM on the PIC

CCP1 and CCP2

I use 18F4580 for my robot sumo and I have 2 PWM.

Check the datasheet of your pic and see if you have 2 PWM on it.

Fisrt thing you must do, it dim a LED with CCP1. After you will create a other PWM. When that is done the rest is easy.
_________________
Jérôme Demers
www.jeromedemers.com
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