LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Arduino Serial Communication

Hi Everyone,

                    I am trying to get arduino to receive a message from labview and then run a function within arduino from this message. I am using the serial event architecture. Arduino function beginFunction() successfully sends a message to labview, but labview does not seem to send a message back. My arduino code is as follows:

 

void loop()
{
if(start==true)
{
beginFunction();
}
if(inputString.equals("move"))
{
moveUntilPos();
}
if(inputString.equals("scan"))
{
scan();
}
}
void serialEvent()
{
while (Serial.available())
{
char inChar = (char)Serial.read();
if (inChar != '\n') {
inputString += inChar;
}
if (inChar == '\n') {
stringComplete = true;
}
}
}

 

my labview file is attached.

 

It does not seem to register the message in arduino, does anyone know why?

 

Thanks,

Sam.

Message 1 of 3
(3,218 Views)

my vi does not send serial messages, can anyone see why? The serial write vi is in the consumer loop

 

thanks

0 Kudos
Message 2 of 3
(3,143 Views)

1. Go look at the advice I already gave you again (https://forums.ni.com/t5/LabVIEW/Indicators-change-too-fast/m-p/3674363#M1032820).  You should especially look at the example I gave you.

2. No need to initialize the same port twice.

3. You need to tell the VISA Read to read MORE bytes than your message.  I like to use 50.

4. Why do you have a 5 second wait in your write loop before sending a response?

5. For where you are sending the message, change your message to be in '\ Codes' mode.  You are not sending the Line Feed (0xA, \n).  You are actually sending a '\' and an 'n'.  When you switch to '\ Codes', then you will see "\\n".  "\\" is the code for a single '\'.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(3,126 Views)