08-12-2017 02:32 AM
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.
08-12-2017 06:28 AM
my vi does not send serial messages, can anyone see why? The serial write vi is in the consumer loop
thanks
08-12-2017 07:21 AM
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 '\'.