I am getting started with microcontrollers and have a presumably very
I have a constant current of 5V coming from my microcontroller*
and want to program the microcontroller to control a dc motor. Since
the current for my motor is constant, I need to use
a different microcontroller output to trigger the motor. How can I
accomplish this? I am a professional programmer, so the coding of this
is not the challenge.
Thank You for reading.
*I am using the Arduino Microcontroller, which has several digital and
analog output pins.
If you don't want to cause confusion and irritation, you really need to
be careful to use the correct terminology.
You have a *voltage* of 5v coming coming from one pin on your
microcontroller. It isn't constant, because you can switch that voltage
on and off, under software control. By varying the ratio of the time it
is on to the time it is off, the average value can be varied over a very
wide range. The motor speed will be determined by the average value
(plus a load of other factors we need not go into now).
One way to do this in software is to set up a loop:
output to high
output to low
delay (frame_width -x)
By varying x from 0 to the value of the frame_width constant, the motor
speed can be varied over a very wide range.
You can have fun setting the value of the frame_width constant -
calculating the optimum value is quite complex. A good place to start
for your small motor is a few mSec.
However, in general the output from a microcontroller is only capable of
producing, or absorbing, a tiny amount of power - no where near enough
to power a motor. However, you can buy little electronic modules, meant
for use by radio control model enthusiasts, that will take your
microcontrol output and drive a motor from it. That will constrain your
choice of frame_width constant to that used by these units though.
You might want to consider joining a local radio control model club -
they may be able to benefit from your programming skills and knowledge -
you will certainly benefit from their knowledge of the practicalities of
motor speed control. Including the challenges of reversing the direction
of motion of the motor... If you don't join a club, the local radio
control model shop may still be a very valuable resource.
Look at "buffers". The easiest is just a NPN transistor with the load
in the emitter, signal to the base +5v to the collector. Plus 5 on the
input gives you ~4.3v on the output.
That works for most things like lights and little DC motors. Use doide
protection with inductive loads. More complicated stuff, up to 240v
45a loads can be driven directly from CMOS logic with a fairly cheap
Solid State Relay.
I'm wondering how much looking you did
before deciding to post a microcontroller question to this group.
I was surprized to see that
didn't turn up in the hits.
Sometimes it seems anything that works on electricity gets a post in
this group. Some students in non-english speaking countries don't know
many other technical words other than electricity to begin their search,
and their country localized version of google doesn't have many pages.
Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here.
All logos and trade names are the property of their respective owners.