Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

controlling a pair of motors

Status
Not open for further replies.

desijays

New Member
I need to control a pair of motors using a PIC16f877a for one my projects.

The motors would be subjected to an approximate load of 1200 grams to 2000 grams and they would be required to move forward, backward and should be able to respond to commands from the PIC on a dime.

I would like to know, what kind of circuit I should be using. I have heard about H-bridge. And I have seen a few here and there. But Im not sure which one to use. Any recommendation with regards to what motors I could use for this purpose would also be helpful.

I know my question seems very vague and generic, but Im not much of an electronics guy. I come from a computer science background.

Thank you.
 
I think first you have to choose your motor. Look at the information about your motor, how big current it will use under the load and which voltage it needs... then you can use this information to choose a suitable H-bridge. There are many ICs which are integrated H-brigdes - the one often mentioned here (SN754410) is for small motors max. 1A current, there are bigger like L298, L6203 or LMD18200. If you need higher current than 4-5A you will probably have to build the H-bridge with MOSFETs and a MOSFET driver.
I have seen a H-bridge with HIP4082 and RFP3055LE (11A) but if needed you can use MOSFETs rated for even higher currents.

Petr
 
I have a motor with me but unfortunately, the make and name of the motor is not mentioned anywhere on it. I am posting pictures of the motor im talking about. Please check it out. Im using a third party hosting website. I hope its alright.

**broken link removed**
**broken link removed**
**broken link removed**

I just bought it from a local store for 40 bucks. It is a small motor. I think its a DC motor. As I mentioned earlier, both the motors will be subjected to a total load of 1200 grams to 2000 grams. So each motor will be subjected to a load of 600 grams to 1000 grams. If I can be recommended any other motors for this purpose, that would be fine as well.
 
zanes said:
You'd be better off with the tamiya double/twin gearbox I suspect, would save the hassle of building a gearbox and mounts.
See here;
https://www.pololu.com/catalog/category/34

109$!!. Isn't that a tad too expensive? Well, yea, it comes with almost all that I need.

I was thinking more along the lines of getting some kind of circuit(H-bridge for example) to control the two motors I already have.

I'll try to dig up the specs of the motor I have, so I can be suggested a circuit that can control them. I'll specify the details as soon as i can dig up their specifications.

Thanks
 
Anyway if you have the motors you can take your multimeter and measure the current your motor needs - try measure free running, with the load and stalled.
Assuming you will power your motor with the correct voltage ... then you can choose the h-bridge accordingly.
 
if you have the cash maybe you can hack up some hobby servos for full rotation. they already have all the gears and make for excellent small robot propulsion. also they only need one i/o pin so that's always a plus
 
One source for servos already designed for continuous rotation is VexLabs. The **broken link removed** stalls at 6.5 in-lbs and no-load 100 rpm, meaning a pair of these (with 4" wheels) could accelerate in about 3-4 seconds and run straight at up to 20 inches per second (on level smooth surface). There's a chart on the website with recommended gears for your chosen speed, and of course slower means more torque.

[edit] One nice thing about these motors is the slip clutch (that green thing on the shaft) which reduces the risk of burning it out. [\edit]
 
Last edited:
I went out and got myself an L298N h-bridge controller. My plan is to get the hang of controlling a motor using the L298 using PWM before getting the motors I would need. As the "rat motor" I am using the motor; pictures, of which I have posted above to test out the pwm.

I know the 16f877a has 2 PWM modules, but I thought for now, just to get the hang of it, to code the PWM in software. So this is what I did. I read up on PWM theory. Armed with that knowledge, I coded a PWM routine with period cycle of 1 second. Since this was my first tryst with pwm, I set it at 50% duty cycle. I expected the motor to run for 500ms and do nothing for another 500ms.

But when I loaded the program and everything the motor did not move at all. But I heard some ticking noise coming from the motor. When I touched it, I felt vibrations at half a second pulses. And then when I pressed hard on the terminals of the motor that lead to the power supply, it started rotating at half a second pulses. When I removed my hand again, the motor stopped rotating but the vibrations were still there. Whenever I had my fingers on the terminals of the motor, it would conform to the pwm. I know its not a case of loose connection or anything. I don't know whats happening.

Anyone know what it is?

And could someone guide my to a tutorial or some article dealing with how to use the PWM module in 16f877a. I read the datasheet but it wasn't exactly clear.

Thank you
 
desijays said:
I went out and got myself an L298N h-bridge controller. My plan is to get the hang of controlling a motor using the L298 using PWM before getting the motors I would need. As the "rat motor" I am using the motor; pictures, of which I have posted above to test out the pwm.

I know the 16f877a has 2 PWM modules, but I thought for now, just to get the hang of it, to code the PWM in software. So this is what I did. I read up on PWM theory. Armed with that knowledge, I coded a PWM routine with period cycle of 1 second. Since this was my first tryst with pwm, I set it at 50% duty cycle. I expected the motor to run for 500ms and do nothing for another 500ms.

But when I loaded the program and everything the motor did not move at all. But I heard some ticking noise coming from the motor. When I touched it, I felt vibrations at half a second pulses. And then when I pressed hard on the terminals of the motor that lead to the power supply, it started rotating at half a second pulses. When I removed my hand again, the motor stopped rotating but the vibrations were still there. Whenever I had my fingers on the terminals of the motor, it would conform to the pwm. I know its not a case of loose connection or anything. I don't know whats happening.

Anyone know what it is?

And could someone guide my to a tutorial or some article dealing with how to use the PWM module in 16f877a. I read the datasheet but it wasn't exactly clear.

You might try my PWM 'tutorial', it was written to do just what you want, forward and reverse, plus speed control, for two motors.
 
Hard to say what is your problem with the L298 PWM and H-bridge without seeing the schematics, maybe you can post it, the code can help as well. By the way, be sure not to leave out the protection diodes.

Petr
 
blueroomelectronics said:
The PWM project might help a little.
**broken link removed**

Nigel Goodwin said:
You might try my PWM 'tutorial', it was written to do just what you want, forward and reverse, plus speed control, for two motors.

Thank you very much. That should help. I will look into them both
 
petrv said:
Hard to say what is your problem with the L298 PWM and H-bridge without seeing the schematics, maybe you can post it, the code can help as well. By the way, be sure not to leave out the protection diodes.

Petr

I will post pictures of the setup Im using. I believe that will help.

This is the H-bridge and motor connected.

**broken link removed**

The following picture is a picture of the entire setup Im using now, just for figuring out PWM. It has the h-bridge, power supply and the step down transformer for reducing the voltage from the wall outlet which is at 240 volts .

**broken link removed**

Now as I said before the motor in the first picture is the one causing problems. i don't know if there could be a problem with the power supply or the H-bridge. It does not run during the duty cycle. But if I hold my hands to the terminal of the motor it runs during the duty cycle. Otherwise it just gives of vibrations during the duty cycle; however long that maybe. I used a 1 second period cycle and 50% duty cycle in my first try.

And is there any standard period cycle that should be used? Because a period cycle in milliseconds for LED's is too large and a period cycle in microseconds for motors it too short... I hope Im clear!!
 
Well, I asked around and finally realized what the problem was. Even though the H-bridge was grounded from the power supply, I completely forgot to ground the circuit that housed the controller that was sending control signals to the h-bridge. I did that and now it works well. It seems very simple now that I know what the problem was.

Than you
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top