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 CCS Technical Support

Changing the direction of a motor

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








Changing the direction of a motor
PostPosted: Fri Nov 13, 2009 4:25 pm     Reply with quote

I know most PIC's cannot output enough current to drive a DC motor, but let's say they could. Is it possible in CCS to change the polarity of a motor that's connected +- to two in/out pins? For instance, for fwd, the code would be:
Code:

//FORWARD
output_low (pin_1); ground the motors - pin
output_high (pin_2); 5V to the motors + pin

//REVERSE
output_high (pin_1); 5V to the motors - pin
output_low (pin_2); ground the motors + pin

My project requires 2 servos, but I have to custom make them and I'm not sure what components will allow me to change the polarity of the motor. Each servo will be analog, relying on the output of a connected potentiometer. If this isn't possible to achieve with a PIC, does anyone know where I can order JUST the chip that's in a typical servo?

The circuit needs to be as lightweight as possible because it's going to be mounted on a hand thrown glider, which is why I have to custom-make it. It also needs to be inexpensive. Can anyone suggest another method of changing the polarity of a DC motor? Each servo/motor will control an aileron on the glider.

Thanks in advance!
Guest








PostPosted: Fri Nov 13, 2009 5:18 pm     Reply with quote

Hi,

Sure, that will work, but as you note, the current will be quite limited. I use basically the same method to control a bi-color LED (red/green) for a status indicator on my projects.

Doug
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Fri Nov 13, 2009 5:53 pm     Reply with quote

Do you want to control a servo, or emulate a servo?

Controlling a servo is quite straight forward. Pulse width controls the distance of travel. Take a look here: http://www.seattlerobotics.org/guide/servos.html and here http://www.seattlerobotics.org/encoder/200304/Futaba%20S148%20Servo%20mod%20for%20PWM.htm

Emulating a servo is a bit more complicated (as shown on the link above as well). The following link also offers good general info: http://www.baldor.com/pdf/manuals/1205-394.pdf

To emulate a servo you need, at a minimum, some sort of h-bridge to control the motors, and some feedback to determine position.
Guest








PostPosted: Tue Nov 17, 2009 1:02 pm     Reply with quote

Hey thanks for the ideas! I found a DUAL DC motor control chip with built in bridge and all, which will work perfectly, for under a dollar. If anyone's interested, making a servo this way makes for much more fluid movement. Instead of the ugly sound of a pulsing motor, everything works in single perfect and accurate movements. Technically it's not even a servo, but is just as accurate.
Guest








PostPosted: Tue Nov 17, 2009 3:30 pm     Reply with quote

And what is the name of the chip?
Guest








PostPosted: Tue Nov 17, 2009 3:40 pm     Reply with quote

The chip model number is A3901, it's a DUAL digital DC motor control chip which uses 2 interrupts per motor to determine the activity and direction of the connected motor. The only tough part is creating the mechanics, gears, and connecting it all to a pot.

http://www.allegromicro.com/en/Products/Part_Numbers/3901/3901.pdf
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