From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview control servo motor

Hello:

I'm a beginner of labview and I'm working on a project now. In this project I need to input a variable to labview, and this variable will be sent to arduino through VISA serial port. Then a servo motor connected to arduino will rotate a degree based on this variable. When I disconnect the motor, the VISA can work and I can see input variable on LCD (RX, RT LED keep ligiting). But when I execute the command "myservo.write()" in arduino, the VISA stop working. Nothing displayed on LCD and motor cannot rotate. If I stop the labview program, the labview will report error. So how can I fix this problem and let moror rotate? waiting for solution, Thanks.

 

Arduino code:

void setup()
{
// Initialize Serial Port With The Default Baud Rate
syncLV();

  // Place your custom setup code here
myservo1.attach(6);
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
myservo1.write(0);

}


/*********************************************************************************
** loop()
**
** The main loop. This loop runs continuously on the Arduino. It
** receives and processes serial commands from LabVIEW.
**
** Input: None
** Output: None
*********************************************************************************/
void loop()
{
// Check for commands from LabVIEW and process them.
checkForCommand();
// Place your custom loop code here (this may slow down communication with LabVIEW)
myservo1.write(0);
lcd.clear();
lcd.setCursor(0, 1);
lcd.clear();
inc = "";
while(Serial.available() > 0)
{
income = ((byte)Serial.read());
inc += income;
}
lcd.print(inc);
//delay(50);
unitX =(int)inc[2] - 48;
tenX = (int)inc[1] - 48;
hundredX = (int)inc[0] - 48;
positionX = 100 * hundredX + tenX * 10; + unitX;
lcd.setCursor(0, 1);
angle1 = positionX - 74;
lcd.print(positionX);
delay(100);
myservo1.write(angle1);
positionX = 0;
}

Download All
0 Kudos
Message 1 of 2
(2,640 Views)

Hi there!

 



When I disconnect the motor, the VISA can work and I can see input variable on LCD (RX, RT LED keep ligiting)

When you do have the server connected, are you still able to see the correct value on the LCD?

 



But when I execute the command "myservo.write()" in arduino, the VISA stop working.

Is the server still disconnected at this point or have you reconnected it when you see this behavior?

 

 

0 Kudos
Message 2 of 2
(2,565 Views)