Pages: [1]   Go Down
Author Topic: Playing with DC motors  (Read 511 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This isn't a project per se. I'm just learning still and the plan is to learn PWM + arduino with initially an LED and then a DC motor.

I started with the LED and can make it fade in and out with a pot hooked up to an analog pin. Occasionally I blue screen my windows computer, but I think that has something to do with the motherboard protecting itself from some wild fluctuation in voltage coming off the USB connected to my pro mini. I also think that issue is begging to teach me where a capacitor needs to go. (I read isolation here at the bottom: http://www.thebox.myzen.co.uk/Workshop/Motors_2.html). I have a box of different size capacitors, but don't know for the LED where or what value I would need to keep that from happening. I'm powering the pro mini from the USB and then using one of the 5v out of the pro mini to run the breadboard (+ and gnd). The LED hangs off of pin 9.

When I switched to trying to vary a DC motor connected to the pro mini, the lessons started rolling in. Lesson 1 was learning I needed more than just the 5v to drive the motor. 1 PN2222 and a 1N4001 diode later I can make the motor run, but it's either on or off.

My DC motor already looks like it has a capacitor between the connectors (looks like a tiny ibuprofen pill). I can't recall if the computer has crashed when I'm running the motor though. Maybe that's just when I was using the LED.

(I'm posting some of this so someone can correct me if I'm missing some things I should be learning along the way.)

My actual question and reason for posting is that I can't vary the speed of the DC motor with the pot. I know I'm sending the transistor different duty cycles because it fades the LED when I'm using it. The motor when I connect it just runs though as if it's not listening to the pot/PWM.

My setup is exactly like this:
http://www.oomlout.com/oom.php/products/ardx/circ-03

...well like that plus a pot that the arduino uses to read and set the PWM for. (analog Pot pin /4) = the 0-255 variable that analogwrite wanted for PWM. Any ideas what I'm missing to make the motor speed up and slow down with that? I know I'm working in the dark without some specifics on the motor, but that's just the nature of using scavenged parts to play with.

I also have 555 timers, but this setup seemed easier than the instructable that was out there that claimed quick and dirty PWM with 555 timers.


Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check this out, it's one of the most common motor driver ICs out there  smiley

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That seems like an expensive chip compared to most I've purchased (lately all from Mouser).

I neglected to mention I also have and was going to play with next a  28BYJ-48 28BYJ48 DC 5V 4-Phase 5-Wire Arduino Stepper Motor with ULN2003 Driver Board.

Maybe I need to hook this DC motor up to the ULN2003 and see if I can make something happen.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wait. I think I'm having a discovery. I'm powering my transistor with a 5v rail on the breadboard and the pin 9. Looking at another web site (https://arduino-info.wikispaces.com/DC-Motors) , I think I missed the point where I'm supposed to provide additional power. The video you posted also has extra power. I don't see how that would address my lack of speed control issue though.

The quest for comprehension continues.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The schematic on that page you point to is awful (I must have a word with Aaron about it)!  I had to look at it about 4 times before I actually had it right in my mind.

Everything is in the wrong place and pointing the wrong way.

In general:
1: Power is at the top
2: Ground is at the bottom
3: Inputs are on the left
4: Outputs are on the right
5: NPN transistors have the collector at the top and the emitter at the bottom.

But oh no, that's not how they have it.  Yes the schematic describes the right circuit, but it's very badly drawn.

Here's the same circuit drawn better:

It should be easier to follow like that - now check that you have actually built your circuit like that...


* motor_1.png (12.1 KB, 550x426 - viewed 43 times.)
« Last Edit: March 30, 2013, 10:41:50 am by majenko » Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

majenko,

In your schematic Vcc at the top is supposed to be powered by something other than 5v off of the arduino right? 9v battery...or I have a pack for 6 AA batteries.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Unless your motor is really really tiny, you should *always* power it from something other than the Arduino.  The actual voltage you will need depends on your motor of course...
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That wouldn't be why it's not changing the speed huh? I can make it run off of pin 9 and the 5v out from the pro mini. I just can't manipulate the speed.
Logged

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10496
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd strongly recommend never putting a motor on the Arduino's 5V rail (or any other logic supply rail), since you risk
destroying a lot of expensive electronics if you get unlucky, and at best it will reset when the motor stalls.  Motors can
pull a _lot_ of current at start-up and under stall conditions (certainly more than USB is rated for), and can sometimes put
high-voltage spikes back onto the supply.   Use a separate motor supply for fewer unpleasant surprises.  Motor driver
chips have two supply rails, one for the motor and one for the logic.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Full Member
***
Karma: 2
Posts: 138
W9LZ
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That wouldn't be why it's not changing the speed huh? I can make it run off of pin 9 and the 5v out from the pro mini. I just can't manipulate the speed.

You are running that 2n2222 like a 'switch'. You already learned that it is in a Common Emitter configuration (emitter is grounded). The transistor needs to be 'biased' to act more linear than "off/on".  Put a 10,000 ohm resistor between the Collector and the Base. This should change how it behaves. You don't want much less than about 2500 ohms between the Collector and Base, if you are experimenting.
Logged

Pages: [1]   Go Up
Jump to: