Constant motor speed

I have to control the speed of a dc motor. The motor is connected to a 7-25V power supply so his speed is variabile to this voltage. Also, i have to maintain constant the speed of the motor when it reaches a certain voltage using the pwm of the arduino. Any ideas on how can I do that?

claudiasabadac41: I have to control the speed of a dc motor. The motor is connected to a 7-25V power supply so his speed is variabile to this voltage. Also, i have to maintain constant the speed of the motor when it reaches a certain voltage using the pwm of the arduino. Any ideas on how can I do that?

Sure, start by providing some feedback so the controller actually KNOWS the speed of the motor.

Paul

I am using a ir diode and fototransistor for that.

claudiasabadac41:
I am using a ir diode and fototransistor for that.

If you already have a program then post it so we can see what you are doing. Tell us what the program actually does and what you want it to do that is different.

Why are you powering the motor with a variable voltage power supply?

Life would be very much simpler if the motor is powered with a constant voltage and the variable voltage is separately used just to signal the required speed.

…R

The project I am working on requires that I use the variable power supply to power the motor

#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,6,5,4,3);
int pwm=9;
int pot=A0;
float value=0;
int percent;
float rev=0;
int rpm;
int oldtime=0;
int time;

void isr() 
routine
{
rev++;
}

void setup()
{
lcd.begin(16,2);             
attachInterrupt(0,isr,RISING);
}

void loop()
{
delay(1000);
detachInterrupt(0);          
time=millis()-oldtime;        
rpm=(rev/time)*60000;        
oldtime=millis();            
rev=0;
value=analogRead(pot);      
value=value/4;
analogWrite(pwm,value);      
percent=(value/255)*100;    
lcd.clear();
lcd.setCursor(0,0);
lcd.print("______");
lcd.setCursor(0,1);
lcd.print(rpm);
lcd.print(" RPM");
lcd.print("   ");
lcd.print(percent);
lcd.print("%");
attachInterrupt(0,isr,RISING);

}

claudiasabadac41: The project I am working on requires that I use the variable power supply to power the motor

Then tell us what the project is.

It is much easier to help when we understand the full context.

I don't have time to study your code now but you certainly should not have the interrupt detached for most of the time. And you probably should not have a huge delay()

...R

Basically, the motor is connected to the power source and its speed is dependent to the voltage. When the voltage reaches a certain voltage, let’s say 15V, the motor has to maintain the speed it has at 15V even if I increase the voltage from the power source. And I have to do that using the microcontroler.

How does the program know that the "certain voltage" has been reached? What is supposed to happen if the power supply drops below the "certain voltage". What is connected to the pin "pot"?

Steve

At a certain voltage the motor will have a certain RPM that’s how the program will know. That code is from a similar project i had. The pin pot was for the pwm signal

claudiasabadac41: At a certain voltage the motor will have a certain RPM that’s how the program will know. That code is from a similar project i had. The pin pot was for the pwm signal

This sounds as if you want the motor to run at whatever speed it is happy to run at until it reaches some upper limit of speed and even with a higher voltage you don't want it to exceed that speed.

Put another way, it seems like you don't want the Arduino to control the speed when it is below the max but you do want the Arduino to prevent it from exceeding the max.

Is that a proper interpretation of the requirement?

If so, what is the permitted maximum speed?

And you have still not told what this project is about? Why not? Is it something illegal?

...R

Robin2:
This sounds as if you want the motor to run at whatever speed it is happy to run at until it reaches some upper limit of speed and even with a higher voltage you don’t want it to exceed that speed.

Put another way, it seems like you don’t want the Arduino to control the speed when it is below the max but you do want the Arduino to prevent it from exceeding the max.

Is that a proper interpretation of the requirement?

If so, what is the permitted maximum speed?

And you have still not told what this project is about? Why not? Is it something illegal?

…R

Also known as a “governor”.

It’s nothing illegal, it’s a school project... it just tells me to do this. I can choose whatever speed limit I want

If you apply a fixed voltage to a DC motor with NO LOAD it will run at a certain RPM, now, if you apply a load to the motor, it will slow down, if you want to hold the original RPM, you need to increase the voltage to make up the speed loss caused by the extra load. You need a device that can sense the speed difference and cause the voltage source to increase voltage until the difference is 0. How are you controlling the voltage regulator now?

claudiasabadac41: It’s nothing illegal, it’s a school project... it just tells me to do this. I can choose whatever speed limit I want

How come you did not answer any of my other questions?

...R

-Yes, that is a proper interpretation of the requirement. -I can chose any maximum speed I want.

claudiasabadac41: -Yes, that is a proper interpretation of the requirement. -I can chose any maximum speed I want.

OK. Then it should be straightforward.

Can you measure the speed so that you can tell whether it is above of below your chosen maximum?

I posted some code to illustrate how to monitor speed here

...R

claudiasabadac41: It’s nothing illegal, it’s a school project... it just tells me to do this. I can choose whatever speed limit I want

Can you post an exact copy of the requirements of this project that the school has given you? You must have the project details on paper/email etc. Thanks.. Tom.. :)

Learn about PID loops - here your input is the motor speed, your output is the value to use in analogWrite to the motor controller/shield.

TomGeorge: Can you post an exact copy of the requirements of this project that the school has given you? You must have the project details on paper/email etc. Thanks.. Tom.. :)

"Title:Controlling the speed of a DC motor(using pwm)

Description:

Designing a system that controls a DC motor whose speed is variable. The motor will be powered by an external power source designed to output 7-25 V. The system will be capable to maintain a preset speed using the microcontroller. The RPM will be displayed on a LCD."

That's it:)!