View previous topic :: View next topic |
Author |
Message |
ricard0g0mes
Joined: 19 May 2009 Posts: 6
|
|
|
robomaniac
Joined: 16 Jul 2009 Posts: 19 Location: Sherbrooke, Québec, Canada
|
|
Posted: Fri Jul 17, 2009 6:29 am |
|
|
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
|
|
Posted: Fri Jul 17, 2009 7:48 am |
|
|
but i want to control 2 motor's with different velocity's |
|
|
robomaniac
Joined: 16 Jul 2009 Posts: 19 Location: Sherbrooke, Québec, Canada
|
|
Posted: Fri Jul 17, 2009 7:55 am |
|
|
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 |
|
|
|