I have some questions about controlling motor speed and using brake on a DC motor.
I am working on a set of electronic window blinds as a part of a school project.
For my project a DC motor is connected to a shaft which controls the blades’ angle, think Venetian blinds.
Anyways, the blades can rotate 0 ~ 180 degrees and at 0 and 180 degrees there are micro-switches which operate as a limit switches.
To control the motor, I am using High-Power Motor Driver 18v15 and Arduino Uno.
Also, I am using NI Labview as a controller interface for the blind.
Here are a list of my parts.
- High-Power Motor Driver 18v15 (https://www.pololu.com/catalog/product/755)
- Arduino Uno
- 12V DC motor (http://robokitsworld.com/index.php?main_page=product_info&cPath=2_3&products_id=186)
- Microswitch (2 units) (http://sensing.honeywell.com/index.cfm?ci_id=140301&la_id=1&pr_id=114331)
- 14.4VDC battery (http://www.dewalt.com/tools/cordless-batteries-dc9091.aspx)
The following is the program I wrote.
For this post, I am only including a part of my code, this parts deals with motor control in one direction and motor braking. I can post the the whole code if you need it.
So, when somebody pushes a button to change the blade’s angle on Labview’s front panel, the motor starts moving to adjust the angle.
When the button is released or when the arm attached to the motor shaft hits the micro-switch, the motor should stop.
int velo = 90; //velo: motor speed
int res = 2, dir = 8, pwm = 9; //res:RESET, dir: DIR, pwm: PWM on the motor driver
int lim = 4; //lim: microswitch
void setup(){
Serial.begin(9600);
pinMode(lim,INPUT);
pinMode(res, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(pwm, OUTPUT);
}
void loop(){
byte lab = 0; //lab: signal from Labview
int swi = 0; //swi: signal from microswitch
lab = Serial.read();
if (lab == 'f'){ //f: signal from Labview when the button was pushed
swi = digitalRead(4); // (motor starts moving)
while (swi == 0){
lab = Serial.read();
if (lab == 'e'){ //e: signal from Labview when the button was released
digitalWrite(pwm, LOW); // (brake operation)
digitalWrite(dir, LOW);
digitalWrite(res, LOW);
break;
}
digitalWrite(res, HIGH);
analogWrite(pwm, velo);
delay(10);
digitalWrite(pwm, HIGH);
delay(10);
digitalWrite(dir, HIGH);
swi = digitalRead(4);
}
digitalWrite(pwm, LOW); // (brake operation)
digitalWrite(dir, LOW);
digitalWrite(res, LOW);
}
else{
digitalWrite(res, LOW);
}
}
Using this program, the motor starts moving when I push the button and stops when the button is released.
However, I have a few questions I hope you can help me with.
-
I am trying to make the motor move slowly.
I applied 90 to PWM to set the motor speed at about 35 % of the full speed.
I wanted to make the motor move slower still, so I applied a number smaller than 90.
However, the motor did not move.
Is this because of a problem with my programming or because of a problem between the motor and the battery? -
I want to stop the motor movement instantaneously if i can.
I thought that applying LOW to PWM worked as a short break and that the break would stop the motor movement very quickly.
However, there is still a lot (~150 degrees) of over-run after the button is released or the microswitch is pushed.
Is it impossible to stop the motor movement faster?
Or is there a mistake in my program that is causing the brake operation to fail? -
Finally, are there any other suggestions you may have about my program?
I am a Mech. Engineering student and I do not know much about electronics or programming.
So I really need and really appreciate your help.
Thank you very much.