Go Down

Topic: Controlling the speed of a DC motor (Read 3826 times) previous topic - next topic

liamorourke

I'm trying to control the speed of a DC motor using the circuit which i have attached along with this code: -
Code: [Select]

int motorSpeed = 30;

int motorPin = 9;

void setup(){
 
}
void loop(){
  analogWrite(motorPin, motorSpeed);
  delay(2);
}


The motor runs but I cannot change the speed by adjusting 'motorSpeed'
Can anyone see what I'm doing wrong here? Thanks

Paul__B



You seem to be attempting to power the motor from the Arduino.

You need to read up on this.

liamorourke

I tried it by powering it with a 9v dc mains adapter as well but got the same problem.

So are you saying that I can't power it with the arduino? If so what is this guy on about? - http://www.dummies.com/how-to/content/how-to-control-the-speed-of-a-dc-motor-with-the-ar.html

Grumpy_Mike

#3
Mar 31, 2016, 12:49 pm Last Edit: Mar 31, 2016, 12:50 pm by Grumpy_Mike
You can only control the speed of a DC motor with PWM if the motor has a significant mechanical load. A unloaded motor will just keep running unaffected during the off parts of the PWM cycle.

Attach a pot to control the PWM value and pinch the motor spindle between your fingers. Then you will feel the speed change.

Quote
what is this guy on about?
Making a very poor project probably designed only as an illustration but crap never the less.

liamorourke

thanks. i'll give it a go.

I actually need the motor to spin REALLY slow. Like one revolution every half an hour.

So am i right in thinking a DC motor is not the best option for this?

ecworks

i think you there is some mistakes in your program... you need to use PWM or use a while loop to control the speed of the motor...in while loop adjust the ON and OFF time of the pin 9.. if you increase the ON period then the speed of the motor will increase....

MarkT

i think you there is some mistakes in your program... you need to use PWM or use a while loop to control the speed of the motor...in while loop adjust the ON and OFF time of the pin 9.. if you increase the ON period then the speed of the motor will increase....

analogWrite() does PWM, pin 9 is one of the PWM pins - I don't get what you are trying to say?  loop() is
called in a while loop for you (well an infinite for loop to be precise).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

MarkT

thanks. i'll give it a go.

I actually need the motor to spin REALLY slow. Like one revolution every half an hour.

So am i right in thinking a DC motor is not the best option for this?

You mean you need a geared down motor?

Can you explain your requirements more fully (with actual numbers, that means)?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Grumpy_Mike

Quote
I actually need the motor to spin REALLY slow. Like one revolution every half an hour.

So am i right in thinking a DC motor is not the best option for this?
A DC motor is not any sort of option for this requirement. It is not possible to slow down a DC motor that much.

raschemmel

#9
Mar 31, 2016, 08:54 pm Last Edit: Apr 01, 2016, 12:32 am by raschemmel
I think the problem here is that you don't understand the physics or the behavior of dc motors. All dc motors have a rated voltage, current and rpm. If you take a motor rated for an rpm of 1200 at 12V and pwm it with 9 V with a 3.5% duty cycle , it is likely not going to turn at all. If it does turn it is going to try to turn at 42 rpm, if it moves at all. One revolution /half hour = 0.03 rpm. There is nothing you can do with any motor that you are likely to run across in your travels that is going to get you 0.03 rpm. This is a very specialized motor with a very high gear ratio.

1_rpm_gear_motor

Do the math.
1 REV/0.5HOURS = 2 REVS/HOUR
2 REVS /PER HOUR = 0.03 RPM


I have no idea what the rated rpm is for your motor because you have not posted any information about it. The above is just an example.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

dhiraj421

hi raschemel,as you said we can you pulse width modulation in ardunio controlling the speed of dc motors we can use the potentiometer ,we can control the speed ,how much speed we want we can make it

raschemmel

#11
Mar 31, 2016, 10:24 pm Last Edit: Mar 31, 2016, 11:07 pm by raschemmel
@dhiraj421,
This is not your thread. I'll answer your question this time but in the future start your own post if your question is not related to the OP's post.

Yes , you can use a pot with the Map function to control a PWM output.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

anarchy_1024

I actually need the motor to spin REALLY slow. Like one revolution every half an hour.

So am i right in thinking a DC motor is not the best option for this?
Why not try a stepper motor? It's more complicated to control, but since each step is a very precise angle, you can control how quickly/slowly it spins. You'll be able to get down to one rev/30 minutes, but it wouldn't be a completely smooth motion. You can't get a standard brushed DC motor to spin that slowly.

MarkT

Tell us what you are really doing!  This is beginning to sound http://xyproblem.info/ to me...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

pwillard


Go Up