Controlling a DC motor with external power source
#1
Posted 20 November 2012 - 03:24 PM
#2
Posted 20 November 2012 - 03:54 PM
There are a few possible solutions that I would suggest that you look into. First off, you should never power a DC motor directly from the Netduino's pin. DC motors are incredilbly hungry for amps (current). Additionally, if powered by same source as your Netduino, the motors can produce a lot of electrical noise causing havoc to any sort of readings on the Netduino. To overcome this, you generally see a motor using it's own power source, such as your battery, that is separate from the Netduino's power source.
Here are a couple common examples written by community members ItsDan and Stefan on how to wire and use your DC motors.
- This first example, by ItsDan, uses a transistor type system. - Transistor Example
- The second example by Stefan uses a low cost chip called an H-Bridge to control a motor. - H-Bridge Example
- The third, and my preferred method of controlling a motor, is using a pre-built motor controller, which generally incorporate H-Bridges Here are two common motor controllers that are known to work with the Netduino. - Adafruit Motor Shield and DFRobot Motor Shield
Hopefully this can get you started. And if you have any question please feel free to ask them here.
Cheers,
Steve
Twiiter: https://twitter.com/Gutworks
#3
Posted 22 November 2012 - 09:28 PM
Absolutely!
There are a few possible solutions that I would suggest that you look into. First off, you should never power a DC motor directly from the Netduino's pin. DC motors are incredilbly hungry for amps (current). Additionally, if powered by same source as your Netduino, the motors can produce a lot of electrical noise causing havoc to any sort of readings on the Netduino. To overcome this, you generally see a motor using it's own power source, such as your battery, that is separate from the Netduino's power source.
Here are a couple common examples written by community members ItsDan and Stefan on how to wire and use your DC motors.
- This first example, by ItsDan, uses a transistor type system. - Transistor Example
- The second example by Stefan uses a low cost chip called an H-Bridge to control a motor. - H-Bridge Example
- The third, and my preferred method of controlling a motor, is using a pre-built motor controller, which generally incorporate H-Bridges Here are two common motor controllers that are known to work with the Netduino. - Adafruit Motor Shield and DFRobot Motor Shield
Hopefully this can get you started. And if you have any question please feel free to ask them here.
Cheers,
Steve
Thank you for your reply.I tried the second option you suggested,but it didn't work,and I thought your could give me a hand:
https://netmftoolbox...pported devices
I connected everything exactly as the picture shows,but when the program run,it does not work.I've added a while loop in order to make it go forever,and used the onboard led to tell me when it's off(with a delay of 2 seconds),but nothing works.Both of the engines are off.
What can be the problem? Are they common mistakes out there that maybe I made?
Thank you very much!
#4
Posted 22 November 2012 - 09:47 PM
I'll try and setup the project later this evening and give you a hand with it. I saw that you were in chat earlier. Sorry I missed you.Thank you for your reply.I tried the second option you suggested,but it didn't work,and I thought your could give me a hand:
https://netmftoolbox...pported devices
I connected everything exactly as the picture shows,but when the program run,it does not work.I've added a while loop in order to make it go forever,and used the onboard led to tell me when it's off(with a delay of 2 seconds),but nothing works.Both of the engines are off.
What can be the problem? Are they common mistakes out there that maybe I made?
Thank you very much!
Steve
Twiiter: https://twitter.com/Gutworks
#5
Posted 23 November 2012 - 12:44 AM
I'll try and setup the project later this evening and give you a hand with it. I saw that you were in chat earlier. Sorry I missed you.
Steve
Thank you for your help!
#6
Posted 23 November 2012 - 06:07 AM
Twiiter: https://twitter.com/Gutworks
#7
Posted 23 November 2012 - 06:16 AM
#8
Posted 23 November 2012 - 02:26 PM
- Don't start a project after 1 am.
- Hockey temporarily reduces mental capacity after each game.
Now that I have had some coffee, and the brain is slowly defrosting, I have seen the error of my ways, and the potential step we may have skipped.
First off, the error I was getting was a bad mistake of my part, and introduce when I created a while loop to continually test the motors. In haste I wrapped the HBridge constructor into the while loop, which is a no no.
So on each iteration of the loop I was attempting to instantiate the MotorDriver with the same pins, over and over again, thus causing my error. No worries, I have placed my dunce hat squarely on my head for the remainder of the day.
Obviously you were wiser than myself, and didn't make that same mistake, however you are still not seeing any movement on your motor. I believe what you may be missing is the external power source need for the VIN pin. This may not be obvious looking at the schematic alone, however you need to plug in an external power adapter such as a wall adapter power supply (wall wart) to the Netduino. I missed step myself, until I looked at the HBridge source code. In it Stefan has created a great ASCII pinout diagram, and mentions that on pin 8 (Vcc2) of the SN754410/L293D is the power source for the motors, such as Vin on the Netduino. The unregulated VIN pin on the Netduino is directly tied to the barrel jack and can be tapped into for external power sources.
When looking for an adapter to use, the most important issue to look at is the polarity of the barrel jack. As long as the centre tap is positive and the outer ring negative, you should be able to use any adapter that is between 7.5v and 12v. For more information you can search the forums or check out the pinout reference sheet.
If this doesn't correct your issue, then let's dig in a little further and get you up and spinning. It would then be helpful if you showed me the code you're using. You may be having issues with the references since the Toolbox samples are compiled using Netduino classic, and .NetMF 4.1.
Cheers,
Steve
Edit: corrected power adapter voltage for the Netduino and Netduino Plus 1.
Edited by Gutworks, 25 November 2012 - 03:37 AM.
Twiiter: https://twitter.com/Gutworks
#9
Posted 24 November 2012 - 11:06 PM
#10
Posted 25 November 2012 - 04:12 AM
Yes, this is correct. However I did misstate the voltage levels for the Netduino Plus 1. It's actually 7.5V-12V. And just as a side note, the new Netduino Plus 2 is 7.5-9V.I connected the Vin on the Netduino as shown on the diagram. So the reason it doesn't work,is because I need a 7-12V power to the Netduino?
Yes, this should work, but make sure that the centre tap is connected to positive and the outer ring is connected to the negative terminal. I believe there is reverse voltage protection on the Netduino in case you incorrectly wire it, but it's better to be safe than sorry.One more question - if I'll buy A 12V battery case,can I cut the cables of the wall adapter power supply with the proper jack and connect it to the battery case? Because I need the Netduino to be mobile.
As I mentioned before it's often a good idea to have two separate power sources, one dedicated to the motors, and another power the Netduino. Another neat alternative is to use a Lithium ion USB charger that many use to charge cell phones with. You simply plug a microUSB cable from the charger to the Netduino's USB port and, voila, you have a smooth source of 5V power. You can then wire the battery directly to the H-bridge, but make sure the grounds are shared (connect a wire from the battery's negative terminal to the GND on the breadboard or Netduino).
Cheers,
Steve
Twiiter: https://twitter.com/Gutworks
#11
Posted 25 November 2012 - 06:18 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users