01-26-2015 10:02 PM
Hello everybody, I´m getting data from the COM port, throught Arduino with Visa interface (Serial), the program that is loaded in my arduino is the attached in the txt file. In labview I had put a "Match pattern" to look in the string for the "T" and "H" variable as seen on the VI jpeg. The problem is when I run the program I get the following results of 0.000 exp after the frac/exp string to number instead to the real values of this variables, I need another "block" for the conversion?, what can I do to solve this problem please help me. 😞
01-26-2015 10:17 PM
01-26-2015 10:27 PM
Well a few days back, I found this on the web, I´m testing a few sensors though arduino, I can´t use the arduino toolkit because I need some libraries to acquire the data, so I´m trying to do some thing like the picture above. I´m attached another picture of the actually VI that I´m using and It´s works fine, but tha final thing that I want to do Is no to use a lot of "Bytes at port", just put patterns to find the variables of the string just like the picture above.
01-26-2015 10:44 PM
01-27-2015 12:52 PM
Excuse me, buth I don´t understand at all... I´m new on this, In the arduino, well you already saw the program that is running in the arduino, I put the data in variable (T and H), so how can I read that data in labview software, I´m already look for that in utube but without success 😞
01-27-2015 01:09 PM
All of the code I've seen from Arduinos sending data through the serial port append an End Of Line character to the end of the message. That is a Termination Character. It is a way of telling the reciever that the message is done. So with the VISA API, you want to enable the termination charcter and use 0xA (Line Feed) as the termination character. Both of those are the default settings if you leave them unwired on the VISA Configure Serial Port.
What the VISA Read will do from there is read all of the the data until one of three things happen: 1) the timeout has expired (default it 10 seconds), 2) the number of bytes you requested are read, or 3) the termination character is found. So what you want to do is get rid of that Bytes At Port node and tell the VISA Read to read a lot more bytes than you would ever expect. For instance, if the long message is 35 characters, tell the VISA Read to read 50 bytes.
So now that you have your message, I would use Search Split String to locate and split the messag at the ':' (colon). The string before match should then go into the case selector of a case structure. So you set up a case for each possible message you can receive. Inside each case, you do whatever decoding/parsing is necessary to get your data and update the UI.
01-27-2015 01:28 PM
How is the data read in from your VISA Read function getting to your Match Pattern functions?
Wire the "Read Buffer" output of the VISA Read to your Match Pattern functions!
01-27-2015 01:57 PM - edited 01-27-2015 02:01 PM
Thanks, but I´m already done but without success again in the conversion string to number part, shows me the value of zero instead of a real value. I have write the code below that is running on arduino (maybe I have wrong in there), I attached an image with a VI that´s it´s works fine (VISA_INTERFACE_TEST) to this message, the difference beetween that I want to do is only to use one single Bytes at Port instead of 1 for each variable that I want to read, just like the VI above, the one that have pressure, temp, long, lat, alt, sat, the largest VI one. This is the code that im running on the arduino, I want to read in labview the T and H variables.
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
if(Serial.available() >0)
{
in = (byte)Serial.read() & ~ (0x20);
if (in == 'T')
{
Serial.println(temp= dht.readTemperature());
}else if(in == 'H')
{
Serial.println(hum= dht.readHumidity());
}
}
delay(1000);
}
01-27-2015 02:10 PM
Again, GET RID OF THE BYTES AT PORT. That does nothing but add complications and race conditions. Your microcontroler is sending out the termination character. So why are you ignoring its usefulness? Set the number of bytes to read to 50 and the VISA Read will do on its own what you have while loops doing.
What is happening inside of your ReadTemperature() and ReadHumidity() functions? Are they returning data formatted into ASCII?
01-27-2015 02:13 PM
The bottom LabVIEW code has VISA Writes where the "H" and "T" are written to your device before an attempt to read H and T.
The top LabVIEW code does not have any VISA Writes.
Do you expect your device to send you H and T without first requesting it?