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.
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.
03-28-2015 06:51 AM - edited 03-28-2015 06:53 AM
Hi Everyone
I have a simple program. I have used arduino to tranfer some string to labview.
And In Labview I want to Subset string. But, It is working only first string and the later strings not be subset.
Can you help me find my error?
Thank for reading
Here is my code and my error
Here is my Video: https://www.youtube.com/watch?v=Gm5nOrZ3iyo
Here is my arduino code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int i=0;
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x20 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
Serial.begin(9600);
// attachInterrupt(0,irt1,CHANGE);
attachInterrupt(1,irt2,FALLING);
// Print a message to the LCD.
lcd.backlight();
lcd.print("Hello, world!");
Serial.print("Hello, world\n");
delay(1000);
lcd.clear();
}
void loop()
{
while(Serial.available())
{
char r = (char) Serial.read();
if(r=='t')
{
lcd.setCursor(0,0);
lcd.print("you are robot");
// Serial.print("you are robot\n");
}
else if (r='a')
{
lcd.setCursor(0,0);
lcd.print("you are human");
// Serial.print("you are human\n");
}
}
}
void irt2()
{
delay(1500);
i++;
if(i%2)
{ Serial.print("ngaysinh010071992\n");}
else
{Serial.print("ngaysinh123455\n");}
}
Solved! Go to Solution.
03-28-2015 07:05 AM
That feedback node is keeping all of the read data. The first 7 bytes will never change since they will always be from the first message. Since I'm sure you just want to see the latest message, just wire the substring indicator to the data coming out of the VISA Read.
Let's take care of some other issues while we are at it.
1. Get rid of the Bytes At Port. You are using the Termination Character. So let VISA use it. The VISA Read will stop reading when it encounters the termination character or it reads the number of bytes specified, whichever comes first. So use a constant to tell the VISA Read to read a larger number of bytes than you would ever get from a message.
2. The VISA Clear isn't really needed.
03-28-2015 07:21 AM
thank for support.
Let me try again
03-28-2015 10:58 AM
Hi. I have tried but It still not working.
Morever, I want to compare input string with constant string. But It working only with first string
I know feedback node is problem, But I can not fix it.
Can you help me fix it?
thanks
03-28-2015 11:04 AM
Your Read Buffer is EVERYTHING that you have received. Any comparisons you want to do should only be on the CURRENT message. So the output of the VISA Read should be going to the Equals function, not the output of the Concatinate String.
03-28-2015 11:06 AM
How can I fix it? Please help me
03-28-2015 11:15 AM - edited 03-28-2015 11:16 AM
I went ahead and did some cleaning up of your diagram. See if this makes sense.