Control de giro y velocidad PWM del motor ( Labview – Arduino )

Control de giro y velocidad PWM del motor ( Labview – Arduino )

Objetivos:

  1. Control giro de un motor DC desde un botón en Labview
  2. Controlar la velocidad del motor DC con desilizador desde Labview

Material

  1. Motor DC
  2. Ld293 o Ld298
  3. Arduino UNO
  4. Labview

 

Diagrama Proteus

 

Panel Frontal en Labview

 

 

Diagrama de bloques Labview

 

Programa en Arduino

 

// control de velocidad pwm de motor dc desde Labview
// microcontroladores.com.mx

int vel=0;
int giro=0;
int bandera=0;

String giroS;

char inChar;
String string="";

void setup() {

pinMode(10,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);

Serial.begin(9600);
string.reserve(200);
}

void loop() {

/// 1;255, 
if (Serial.available()>0){

inChar = Serial.read();
//Suma de caracteres en variable string

if ( inChar != ',') {

string+=inChar;

}
else { ///detecto el ,

String srting_giro=string.substring(0,1);
String string_vel=string.substring(1);

Serial.println(srting_giro);
Serial.println(string_vel);

giro =srting_giro.toInt();
vel= string_vel.toInt(); // velocidad a entero

string="";

}

if (giro==1){
digitalWrite(5,LOW);
digitalWrite(4,HIGH);
}
else {

digitalWrite(5,HIGH);
digitalWrite(4,LOW);
}

analogWrite(10,vel);

}

}

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *