LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA-Serial-Arduino

I'm working on a toy example in which Labview listens to a com port via VISA.  An Arduino sends data to the com port at 9600bps.  

 

I can get the VI below to capture most of the data sent by the Arduino, but some of the longer lines are garbled.  Wondering why this might be - perhaps something to do with the dynamic array indexing I'm using? Eg, dynamic array allocation is too slow, which leads to the incorrect combination of the first two lines of the message?

 

FWIW, this seems like a much more flexible way to get sensor data out of an Arduino than the LINX library.  It's not hard to imagine the Arduino using I2C, soft serial, etc to get data from GPS, or a set of fancy i2c sensors. 

 

nmoorewsu_0-1618058965503.png

 

Also, the example for this application (below) uses the feedback node with concatenate strings (and works fine with my arduino data sender).  Is string concatenation a cheaper operation memory-wise?

 

nmoorewsu_0-1618059344504.png

 

Finally, if this was arduino c++ code, there'd be a line that looks like 

if( serial.new_data() == TRUE ) {

   parse the message...

Is this the purpose of the shift register in carrying the VISA object to the VISA-READ object?

 

 

0 Kudos
Message 1 of 2
(1,467 Views)

Building of arrays will cause issues, as increasing memory allocations will make things slow.  So a couple of things I would do:

1. Get rid of the delay in your loop.  The VISA Read will limit your loop rate.

2. Process your data as you receive it.  I would highly recommend using a Producer/Consumer.  The Producer loop reads the data from your Arduino while the Consumer loop processes the data however it needs to (log, write to a chart, etc.) in parallel.


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 2 of 2
(1,406 Views)