Go Down

Topic: DC Motor Control - Arduino uno (Read 2186 times) previous topic - next topic

Maschinenbau

Hello everyone, i'm a newbie in this arduino stuff, and a have so much trouble doing the control of this motor. i'm making the control with a potentiometer and a switch (controlling the speed and the rotation respectively) with an ARDUINO UNO (i'm using the L293D chip), and i finally could made it (as you can see in the image), but now i would like to obtain the data from the motor in order to have a graphic, because then i muss compare the graphic with the transfer function of the motor.

I have made so much attempts but i couldn't made it, first at all i tried to use matlab with my serial port, and the program recognize the arduino, but i don't know how to configure the matlab in order to receive the data in real time ( i've used the matlab io arduino package) and the arduino either.
Ok then i tried to use the serial monitor option from arduino (in order to obtain the data), but now i discover that i muss have a sensor ( for example an encoder) in order to do that.

searching on the net, i found this place: http://letsmakerobots.com/node/12293?page=1, but still haven't found what i'm looking for.

If anyone can help me, i would really appreciate this.

the code that i've used in the arduino was:

"
// Proyecto final - Control motor con potenciómetro y pulsador
#define switchPin 2 // switch de entrada
#define motorPin1 3 // Entrada 1 para el L293D
#define motorPin2 4 // Entrada 2 para el L293D
#define speedPin 9 //
#define potPin 0 // Potenciómetro en el pin análogo 0
int Mspeed = 0; // velocidad
void setup() { // switch pin como entrada
pinMode (switchPin, INPUT); // mantiene los otros pines como salidas
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(speedPin, OUTPUT);
}

void loop() {
Mspeed = analogRead(potPin)/4; // lee un valor de velocidad del potenciómetro
analogWrite (speedPin, Mspeed); 
if (digitalRead(switchPin))
{  // si el switch está alto el motor gira horario
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
}
else { // si el switch está bajo el motor gira en el sentido antihorario
digitalWrite (motorPin1, HIGH);
digitalWrite (motorPin2, LOW);
}
}
"

P.s: i know that my english sucks, so if there's any mistake don't bother me, thank you so much.

Go Up