LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build regular expression for serial data from Arduino.

Solved!
Go to solution

RavensFan,

 

And Everyone else how helped. 

 

Thank you so much. 

 

All I had to do was enable my termination Char, and let the defaule \n take care of my input strings. The input is slow, less than 100 Hz, so I don't forsee a problem with my code timeing out. 

 

Here is the final working code. 

 

working_code.png

 

Thanks again,

 

Austin. 

 

Smiley LOL

 

 

 

0 Kudos
Message 11 of 18
(2,407 Views)

Glad to hear it is working better for you now.

 

But still get rid of the Bytes at Port node.  Just put a very large number in there for bytes to read.

 

Why?  Suppose the way things go in timing that it gets the number of bytes at port, but the whole message hasn't quite come in yet and you haven't got all the way to the linefeed.  You are expecting 123456789\n, but when the bytes at port executes, you've only gotten 123456,  and the 789\n hasn't quite gotten there yet.  Bytes at port will be 6.  You'll get 6 bytes "123456", and the 789\n is going to sit in the buffer until the next time around.  Put in a bigt number like 100 bytes to read (whatever is more than the longest message you expect to receive) and the VISA read will sit there waiting for the \n to come in.

 

One of the things I hate most about the LabVIEW serial port examples is that they all show the bytes at port node being used.  For about 99% of the serial port communication systems you'll see, it is the wrong thing to use and you should not use it.

0 Kudos
Message 12 of 18
(2,398 Views)

Your explanation makes perfect sense.  Thanks Again,

 

My code now looks like 

 

bytes to read gone.png

 

 

1 million may not be a "large number", but it seems to be working, and I will keep an eye on it as the code progresses. 

 

I really need to expand my understanding of how the LabVIEW serial and VISA functions work. 

 

Austin. 

 

 

 

 

 

 

 

 

0 Kudos
Message 13 of 18
(2,391 Views)

That should work.  And should be more than large enough number of bytesSmiley Happy

 

Don't forget to put a VISA close after your while loop.

 

Good luck with your application.

0 Kudos
Message 14 of 18
(2,379 Views)

Code crashes OS, and solution.

 

All,

 

First thanks for your help.  Second, after getting this code working I found that it crashed my computer.  I tried the code on a few different computers, (Windows 7, 8 and 10) with different LabVIEW versions (13, 14 and 15).  On four of five computers, running this code would cause a "Driver_IQRL_Not_less_or_equal" after about 90 seconds of runtime.  I have attached two pictures of the blue screen it causes.  

 

After a few weeks on and off With NI they were able to provide a solution.  Change the read VISA block form Asynchronous to Synchronous.  

 

I hope this helps someone in the future. 

 

A more in-depth dissuasion can be found here,

 

http://forums.ni.com/t5/LabVIEW/usbser-sys-BSOD-When-Arduino-sending-data-over-USB/td-p/2812202

 

 

Download All
0 Kudos
Message 15 of 18
(2,255 Views)

Glad you got a solution to the crashing problem.

 

Just curious, how does the device connect to the PC?

 

I have never seen this kind of problem with normal serial ports.  Is it connect using a USB cable?  Blue screens are almost always caused  by the driver, so I'm wondering if it is because it is a USB connection and the driver creates a virtual com port and that isn't playing nice.

0 Kudos
Message 16 of 18
(2,246 Views)

My computer does return a "virtual comport error" when I open CoolTerm.  This never showed up until I started running the above LabVIEW VI, however every thing seems to be working OK.

 

 

 

The Arduinos are connected via USB connection as shown below, 

 

 usb_uno.jpg

 

 

0 Kudos
Message 17 of 18
(2,231 Views)

I often come back to this thread when I travel or need to rewrite the code so I thought I would share a cleaner version of the code above.  I have included a picture and an 2013 VI.  I also posted this on my personal website to ease in handing it out to others who need it. 

 

http://adowney2.public.iastate.edu/projects/The_simplest_Arduino_LabView_data_logger/The_simplest_Ar...

 

Code.PNG

0 Kudos
Message 18 of 18
(1,787 Views)